2014-06-04 19:55:04 +03:00
|
|
|
module Parser
|
|
|
|
module Control
|
|
|
|
include Parslet
|
2015-10-09 17:28:13 +03:00
|
|
|
rule(:while_statement) do
|
|
|
|
keyword_while >> left_parenthesis >> r_value.as(:condition) >>
|
|
|
|
right_parenthesis >> statements_end.as(:body)
|
|
|
|
end
|
|
|
|
|
|
|
|
rule(:if_statement) do
|
2015-09-15 18:57:31 +03:00
|
|
|
keyword_if >>
|
2015-10-09 17:28:13 +03:00
|
|
|
left_parenthesis >> r_value.as(:conditional) >> right_parenthesis >>
|
|
|
|
statements_else.as(:true_statements) >> statements_end.as(:false_statements)
|
2015-09-15 18:57:31 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
rule(:small_conditional) do
|
|
|
|
keyword_if >>
|
2015-10-09 17:28:13 +03:00
|
|
|
left_parenthesis >> r_value.as(:conditional) >> right_parenthesis >>
|
|
|
|
statements_end.as(:true_statements)
|
2014-06-04 19:55:04 +03:00
|
|
|
end
|
2015-09-15 18:57:31 +03:00
|
|
|
|
2015-10-09 17:28:13 +03:00
|
|
|
rule(:return_statement) do
|
|
|
|
keyword_return >> r_value.as(:return_statement)
|
2014-06-04 19:55:04 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|