Created
September 24, 2008 01:32
-
-
Save defunkt/12454 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
# Treetop file for the never released Oil | |
# Oil's spiritual successor is the released Jasper [ http://github.com/defunkt/jasper ] | |
module Oil | |
grammar Grammar | |
rule program | |
(space expression space)* | |
end | |
rule expression | |
'(' list ')' <Oil::Expression> | |
end | |
rule list | |
(space element:(comment / slot_access / token / expression) space)* | |
end | |
rule slot_access | |
receiver:token slots:('.' symbol)+ <Oil::SlotAccess> | |
end | |
rule token | |
string / float / number / symbol | |
end | |
rule string | |
'"' inner_text:(!'"' . / '\"')* '"' <Oil::String> | |
end | |
rule float | |
number '.' number | |
end | |
rule number | |
'-'? [0-9]+ <Oil::Number> | |
end | |
rule comment | |
"#" comment_string* <Oil::Comment> | |
end | |
rule comment_string | |
'(' comment_string ')' / space [^()]+ space | |
end | |
rule space | |
[ \n]* | |
end | |
rule symbol | |
[a-zA-Z`~!@$%^&*_=+\[\]{}|;:',<>/?-]+ <Oil::Symbol> | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment