Skip to content

Instantly share code, notes, and snippets.

@andoneve
Created August 20, 2013 13:03
Show Gist options
  • Save andoneve/6281067 to your computer and use it in GitHub Desktop.
Save andoneve/6281067 to your computer and use it in GitHub Desktop.
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