2014-05-10 10:14:34 +02:00
|
|
|
module Parser
|
|
|
|
module Expression
|
|
|
|
include Parslet
|
|
|
|
|
|
|
|
rule(:simple_expression) { function_call | integer | string | name }
|
2014-05-12 11:14:04 +02:00
|
|
|
rule(:expression) { (while_do | conditional | simple_expression ) >> newline.maybe }
|
2014-05-10 10:14:34 +02:00
|
|
|
|
|
|
|
def delimited_expressions( delimit )
|
2014-05-11 17:37:26 +02:00
|
|
|
( (delimit.absent? >> (operator_expression | expression)).repeat(1)).as(:expressions) >> delimit >> newline.maybe
|
2014-05-10 10:14:34 +02:00
|
|
|
end
|
|
|
|
|
2014-05-12 11:14:04 +02:00
|
|
|
rule(:expressions_do) { delimited_expressions(keyword_do) }
|
2014-05-10 10:14:34 +02:00
|
|
|
rule(:expressions_else) { delimited_expressions(keyword_else) }
|
|
|
|
rule(:expressions_end) { delimited_expressions(keyword_end) }
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|