Created
August 10, 2011 13:28
-
-
Save jeremytregunna/1136794 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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