soml-parser/lib/parser/expression.rb

20 lines
662 B
Ruby
Raw Normal View History

2014-06-04 18:55:04 +02:00
module Parser
module Expression
include Parslet
2015-09-15 17:57:31 +02:00
2015-09-20 11:50:06 +02:00
rule(:value_expression) { call_site | field_access |basic_type }
2014-06-04 18:55:04 +02:00
rule(:expression) { (simple_return | while_do | small_conditional | conditional |
operator_expression | call_site | field | hash_constant | array_constant) }
2014-06-04 18:55:04 +02:00
def delimited_expressions( delimit )
( (delimit.absent? >> expression).repeat(1)).as(:expressions) >> delimit
end
rule(:expressions_do) { delimited_expressions(keyword_do) }
rule(:expressions_else) { delimited_expressions(keyword_else) }
rule(:expressions_end) { delimited_expressions(keyword_end) }
end
end