fix array and hash constants, now seperated out

This commit is contained in:
Torsten Ruger
2015-10-09 17:29:24 +03:00
parent dff0e8fab4
commit b424306156
7 changed files with 34 additions and 40 deletions

View File

@ -5,15 +5,15 @@ module Parser
rule(:array_constant) do
left_bracket >>
( ((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) >>
( (r_value.as(:array_element) >> space? >>
(comma >> space? >> 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|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)>>
rule(:hash_pair) { basic_type.as(:hash_key) >> association >> 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 }
end
end
end