From 129f9f5c57485ad9adbf7f3e527bdcb9210b88cf Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 28 Apr 2014 22:07:13 +0300 Subject: [PATCH] space and order fiddling (gets assignments to work better) --- lib/parser/composed.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/parser/composed.rb b/lib/parser/composed.rb index 4766fcda..1ede3b7c 100644 --- a/lib/parser/composed.rb +++ b/lib/parser/composed.rb @@ -25,12 +25,12 @@ module Parser rule(:function_call) { name.as(:function_call) >> argument_list } - rule(:assignment) { name.as(:asignee) >> equal_sign >> expression.as(:asigned) >> eol } + rule(:assignment) { name.as(:asignee) >> equal_sign >> expression.as(:asigned) } - rule(:expression) { conditional | function_call | integer | name } + rule(:expression) { conditional | function_call | integer | (name >> space? >> equal_sign.absent?) } def delimited_expressions( delimit ) - ((delimit.absent? >> expression).repeat(1)).as(:expressions) >> delimit + ( space? >> (delimit.absent? >> (assignment | expression)).repeat(1)).as(:expressions) >> delimit end rule(:conditional) { @@ -42,8 +42,6 @@ module Parser rule(:expressions_else) { delimited_expressions(keyword_else) } rule(:expressions_end) { delimited_expressions(keyword_end) } -# rule(:expressions_end) { ((keyword_end.absent? >> expression).repeat(1)).as(:expressions) >> keyword_end } - rule(:function_definition) { keyword_def >> name.as(:function_definition) >> parmeter_list >> expressions_end }