Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created September 24, 2008 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunkt/12454 to your computer and use it in GitHub Desktop.
Save defunkt/12454 to your computer and use it in GitHub Desktop.
# 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