at least basic tests work again
This commit is contained in:
parent
034ae4f7ca
commit
9c2dfe79da
@ -19,13 +19,13 @@ module Parser
|
|||||||
rule(:plus) { str('+') }
|
rule(:plus) { str('+') }
|
||||||
rule(:equal_sign) { str('=') >> space?}
|
rule(:equal_sign) { str('=') >> space?}
|
||||||
rule(:sign) { plus | minus }
|
rule(:sign) { plus | minus }
|
||||||
rule(:dot) { str('.') }
|
rule(:dot) { str('.') }
|
||||||
rule(:digit) { match('[0-9]') }
|
rule(:digit) { match('[0-9]') }
|
||||||
rule(:exponent) { (str('e')| str('E')) }
|
rule(:exponent) { (str('e')| str('E')) }
|
||||||
|
|
||||||
rule(:true) { str('true').as(:true) >> space?}
|
rule(:true) { str('true').as(:true) >> space?}
|
||||||
rule(:false) { str('false').as(:false) >> space?}
|
rule(:false){ str('false').as(:false) >> space?}
|
||||||
rule(:nil) { str('null').as(:nil) >> space?}
|
rule(:nil) { str('null').as(:nil) >> space?}
|
||||||
|
|
||||||
# identifier must start with lower case
|
# identifier must start with lower case
|
||||||
rule(:name) { (match['a-z'] >> match['a-zA-Z0-9'].repeat).as(:name) >> space? }
|
rule(:name) { (match['a-z'] >> match['a-zA-Z0-9'].repeat).as(:name) >> space? }
|
||||||
|
@ -26,11 +26,11 @@ module Parser
|
|||||||
rule(:function_call) { name.as(:function_call) >> argument_list }
|
rule(:function_call) { name.as(:function_call) >> argument_list }
|
||||||
|
|
||||||
rule(:assignment) { name.as(:asignee) >> equal_sign >> expression.as(:asigned) }
|
rule(:assignment) { name.as(:asignee) >> equal_sign >> expression.as(:asigned) }
|
||||||
|
#| (name >> space? >> equal_sign.absent?)
|
||||||
rule(:expression) { conditional | function_call | integer | string | (name >> space? >> equal_sign.absent?) }
|
rule(:expression) { conditional | function_call | integer | string }
|
||||||
|
|
||||||
def delimited_expressions( delimit )
|
def delimited_expressions( delimit )
|
||||||
( space? >> (delimit.absent? >> (assignment | expression)).repeat(1)).as(:expressions) >> delimit
|
( (delimit.absent? >> (assignment | expression)).repeat(1)).as(:expressions) >> delimit
|
||||||
end
|
end
|
||||||
|
|
||||||
rule(:conditional) {
|
rule(:conditional) {
|
||||||
|
@ -26,9 +26,7 @@ class TestBasic < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_string
|
def test_string
|
||||||
@string_input = <<HERE
|
@string_input = "\"hello\""
|
||||||
"hello"
|
|
||||||
HERE
|
|
||||||
@parse_output = {:string=>"hello"}
|
@parse_output = {:string=>"hello"}
|
||||||
@transform_output = Ast::StringExpression.new('hello')
|
@transform_output = Ast::StringExpression.new('hello')
|
||||||
@parser = @parser.string
|
@parser = @parser.string
|
||||||
|
Loading…
Reference in New Issue
Block a user