Skip to content

Instantly share code, notes, and snippets.

@jeremytregunna
Created August 10, 2011 13:28
Show Gist options
  • Select an option

  • Save jeremytregunna/1136794 to your computer and use it in GitHub Desktop.

Select an option

Save jeremytregunna/1136794 to your computer and use it in GitHub Desktop.
Lexer := Object clone do(
inputString := Sequence clone
current ::= nil
next ::= nil
with := method(str, self clone setInputString(str))
setInputString := method(str,
inputString = str
self
)
currentIndentationLevel := method(
indentationLevel := 0
inputString foreach(c,
if(c asCharacter == " " or c asCharacter == "\t",
indentationLevel = indentationLevel + 1
,
break
)
)
indentationLevel
)
advance := method(
setInputString(inputString exSlice(1, inputString size))
)
pending := method(inputString at(0) asCharacter)
)%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment