starting to deompose the parser

This commit is contained in:
Torsten Ruger
2014-04-27 16:30:32 +03:00
parent 96a9cd3270
commit f628c67188
6 changed files with 23 additions and 8 deletions

View File

@@ -29,5 +29,13 @@ module Parser
rule(:func => simple(:func),
:params => sequence(:params),
:body => simple(:body)) { Vm::FunctionExpression.new(func.name, params, body) }
#shortcut to get the ast tree for a given string
# optional second arguement specifies a rule that will be parsed (mainly for testing)
def self.ast string , rule = :root
syntax = Parser.new.send(rule).parse(string)
tree = Transform.new.apply(syntax)
tree
end
end
end