Skip to content

Instantly share code, notes, and snippets.

@txus
Created August 15, 2013 14:16
Show Gist options
  • Save txus/6241155 to your computer and use it in GitHub Desktop.
Save txus/6241155 to your computer and use it in GitHub Desktop.
Lexer structure
class Lani::Parser
macro
# our macros go here
rule
# our rules go here
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