rename value_expression to r_value

This commit is contained in:
Torsten Ruger 2015-10-09 12:42:50 +03:00
parent 77cb8ce90a
commit 308c0efc05
5 changed files with 10 additions and 10 deletions

View File

@ -41,7 +41,7 @@ module Parser
# TODO rule forbit names like if_true, because it starts with a keyword. a little looser please!
rule(:name) { (keyword|type).absent? >> (match['a-z_'] >> match['a-zA-Z0-9_'].repeat).as(:name) >> space? }
# fields have type
rule(:field) { type >> name >> (assign >> value_expression.as(:value) ).maybe}
rule(:field) { type >> name >> (assign >> r_value.as(:value) ).maybe}
rule(:class_field) { keyword_field >> field }
# and class/module names must start with capital
rule(:class_name) { keyword.absent? >> (match['A-Z'] >> match['a-zA-Z0-9_'].repeat).as(:class_name) >> space? }

View File

@ -5,12 +5,12 @@ module Parser
rule(:array_constant) do
left_bracket >>
( ((operator_expression|value_expression).as(:array_element) >> space? >>
(comma >> space? >> (operator_expression|value_expression).as(:array_element)).repeat(0)).repeat(0,1)).as(:array_constant) >>
( ((operator_expression|r_value).as(:array_element) >> space? >>
(comma >> space? >> (operator_expression|r_value).as(:array_element)).repeat(0)).repeat(0,1)).as(:array_constant) >>
space? >> right_bracket
end
rule(:hash_pair) { basic_type.as(:hash_key) >> association >> (operator_expression|value_expression).as(:hash_value) }
rule(:hash_pair) { basic_type.as(:hash_key) >> association >> (operator_expression|r_value).as(:hash_value) }
rule(:hash_constant) { left_brace >> ((hash_pair.as(:hash_pair) >>
(comma >> space? >> hash_pair.as(:hash_pair)).repeat(0)).repeat(0,1)).as(:hash_constant)>>
space? >> right_brace }

View File

@ -3,22 +3,22 @@ module Parser
include Parslet
rule(:conditional) do
keyword_if >>
left_parenthesis >> (operator_expression|value_expression).as(:conditional) >> right_parenthesis >>
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|value_expression).as(:conditional) >> right_parenthesis >>
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|value_expression).as(:while_cond) >>
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|value_expression).as(:return_expression)
keyword_return >> (operator_expression|r_value).as(:return_expression)
end
end
end

View File

@ -2,7 +2,7 @@ module Parser
module Expression
include Parslet
rule(:value_expression) { call_site | field_access |basic_type }
rule(:r_value) { call_site | field_access |basic_type }
rule(:expression) { (simple_return | while_do | small_conditional | conditional |
operator_expression | call_site | class_field | field |

View File

@ -23,7 +23,7 @@ module Parser
#infix doing the heavy lifting here,
# is defined as an expressions and array of [atoms,priority,binding] triples
rule(:operator_expression) do infix_expression(value_expression,
rule(:operator_expression) do infix_expression(r_value,
[exponent, 120, :left] ,
[multiply, 120, :left] ,
[plus, 110, :left],