retrying with the root of the directory
comes from finally tightning the root and not allowing random expression code ala ruby
This commit is contained in:
@ -8,7 +8,7 @@ module ParserHelper
|
||||
|
||||
def self.included(base)
|
||||
base.send :include, InstanceMethods #provides helpers and setup
|
||||
base.send :include, AST::if_true
|
||||
base.send :include, AST::true_statements
|
||||
base.send :extend, ClassMethods #gets the method creation going
|
||||
end
|
||||
|
||||
|
@ -17,10 +17,3 @@ 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
|
||||
|
@ -10,7 +10,13 @@ class TestAll < MiniTest::Test
|
||||
def check_file file
|
||||
inn , out = File.new(file).read.split(SEPERATOR)
|
||||
sexp = eval(out)
|
||||
syntax = Parser::Salama.new.parse_with_debug(inn)
|
||||
begin
|
||||
syntax = Parser::Salama.new.parse(inn)
|
||||
rescue
|
||||
root = file.split("/")[2]
|
||||
parser = Parser::Salama.new.send root.to_sym
|
||||
syntax = parser.parse_with_debug(inn )
|
||||
end
|
||||
result = Parser::Transform.new.apply(syntax)
|
||||
equal = (sexp == result)
|
||||
unless equal
|
||||
|
Reference in New Issue
Block a user