2014-06-04 18:55:04 +02:00
|
|
|
module Parser
|
|
|
|
module Control
|
|
|
|
include Parslet
|
|
|
|
rule(:conditional) do
|
2015-09-15 17:57:31 +02:00
|
|
|
keyword_if >>
|
2015-10-09 11:42:50 +02:00
|
|
|
left_parenthesis >> (operator_expression|r_value).as(:conditional) >> right_parenthesis >>
|
2015-09-15 17:57:31 +02:00
|
|
|
expressions_else.as(:if_true) >> expressions_end.as(:if_false)
|
|
|
|
end
|
|
|
|
|
|
|
|
rule(:small_conditional) do
|
|
|
|
keyword_if >>
|
2015-10-09 11:42:50 +02:00
|
|
|
left_parenthesis >> (operator_expression|r_value).as(:conditional) >> right_parenthesis >>
|
2015-09-15 17:57:31 +02:00
|
|
|
expressions_end.as(:if_true)
|
2014-06-04 18:55:04 +02:00
|
|
|
end
|
2015-09-15 17:57:31 +02:00
|
|
|
|
2014-06-04 18:55:04 +02:00
|
|
|
rule(:while_do) do
|
2015-10-09 11:42:50 +02:00
|
|
|
keyword_while >> left_parenthesis >> (operator_expression|r_value).as(:while_cond) >>
|
2015-09-15 17:57:31 +02:00
|
|
|
right_parenthesis >> expressions_end.as(:body)
|
2014-06-04 18:55:04 +02:00
|
|
|
end
|
|
|
|
rule(:simple_return) do
|
2015-10-09 11:42:50 +02:00
|
|
|
keyword_return >> (operator_expression|r_value).as(:return_expression)
|
2014-06-04 18:55:04 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|