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:
parent
f7dcf2a2ff
commit
97cf5e5bea
@ -38,7 +38,7 @@ Syntax (and semantics) of Phisol are just forming, but some things are clear:
|
||||
- call syntax as already discussed, ie message based
|
||||
|
||||
Some things we shall leave behind from the ruby approach are a lot of sugar, like missing brackets,
|
||||
random code everywhere, expressions galore . . .
|
||||
random code everywhere, statements galore . . .
|
||||
|
||||
|
||||
### Parser
|
||||
@ -52,10 +52,10 @@ Most names are quite self explanatory, but here is a list:
|
||||
- call_site is a function call. May be qualified, but currently must still have braches
|
||||
- compound types are hash and array definitions. Hashes still need curlies
|
||||
- control is if statement which still must have an else
|
||||
- expression is a helper for all code allowed in a function
|
||||
- statement is a helper for all code allowed in a function
|
||||
- function definition must have braces too
|
||||
- keywords is just a list of them
|
||||
- operator expression are binary operators (see also below). There's a surprising amount
|
||||
- operator statement are binary operators (see also below). There's a surprising amount
|
||||
- return statement are straightforward
|
||||
- while still needs a do, though i think in ruby a newline is sufficient
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user