25 lines
800 B
Ruby
25 lines
800 B
Ruby
module Parser
|
|
module Control
|
|
include Parslet
|
|
rule(:conditional) do
|
|
keyword_if >>
|
|
left_parenthesis >> (operator_expression|r_value).as(:conditional) >> right_parenthesis >>
|
|
expressions_else.as(:if_true) >> expressions_end.as(:if_false)
|
|
end
|
|
|
|
rule(:small_conditional) do
|
|
keyword_if >>
|
|
left_parenthesis >> (operator_expression|r_value).as(:conditional) >> right_parenthesis >>
|
|
expressions_end.as(:if_true)
|
|
end
|
|
|
|
rule(:while_do) do
|
|
keyword_while >> left_parenthesis >> (operator_expression|r_value).as(:while_cond) >>
|
|
right_parenthesis >> expressions_end.as(:body)
|
|
end
|
|
rule(:simple_return) do
|
|
keyword_return >> (operator_expression|r_value).as(:return_expression)
|
|
end
|
|
end
|
|
end
|