soml-parser/lib/parser/expression.rb

21 lines
702 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 |
2015-09-27 11:05:35 +02:00
operator_expression | call_site | class_field | 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