Created
August 20, 2013 13:03
-
-
Save andoneve/6281067 to your computer and use it in GitHub Desktop.
This file contains 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
class Lani::Parser | |
macro | |
BLANK [\ \t]+ | |
rule | |
BLANK # no action | |
\d+ { [:INTEGER, text.to_i] } | |
\+ { [:ADD, text] } | |
inner | |
# here we put any ruby code we want to extend our lexer with. | |
# for example, our own tokenize method. | |
def tokenize(code) | |
scan_setup(code) | |
tokens = [] | |
while token = next_token | |
tokens << token | |
end | |
tokens | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment