rubyx/lib/parser/control.rb

16 lines
595 B
Ruby
Raw Normal View History

2014-05-10 10:14:34 +02:00
module Parser
module Control
2014-05-10 10:14:34 +02:00
include Parslet
rule(:conditional) do
keyword_if >> left_parenthesis >> (simple_expression|operator_expression).as(:conditional) >> right_parenthesis >> newline >>
expressions_else.as(:if_true) >> newline >> expressions_end.as(:if_false)
end
2014-05-10 18:02:51 +02:00
rule(:while_do) do
keyword_while >> left_parenthesis >> (simple_expression|operator_expression).as(:while_cond) >>
right_parenthesis >> keyword_do >> newline >>
expressions_end.as(:body)
end
2014-05-10 10:14:34 +02:00
end
end