restrict the root, but expand for testing

This commit is contained in:
Torsten Ruger 2015-10-09 12:39:31 +03:00
parent 486e24514b
commit 77cb8ce90a
2 changed files with 8 additions and 2 deletions

View File

@ -31,8 +31,7 @@ module Parser
include Operators
include ModuleDef
rule(:root_body) {( class_definition | function_definition |
expression | operator_expression | call_site )}
rule(:root_body) {( class_definition | function_definition )}
rule(:root) { root_body.repeat.as(:expression_list) }
end
end

View File

@ -17,3 +17,10 @@ require 'salama-reader'
require "minitest"
require "minitest/autorun"
# for testing add expression as allowed root
# bit of a hack: the directory name should be passed as the root if the parse fails
# but moving on (and coming back)
Parser::Salama.class_eval do
rule(:root_body) {( class_definition | function_definition | expression )}
end