fix array and hash constants, now seperated out
This commit is contained in:
parent
dff0e8fab4
commit
b424306156
@ -5,12 +5,12 @@ module Parser
|
|||||||
|
|
||||||
rule(:array_constant) do
|
rule(:array_constant) do
|
||||||
left_bracket >>
|
left_bracket >>
|
||||||
( ((operator_expression|r_value).as(:array_element) >> space? >>
|
( (r_value.as(:array_element) >> space? >>
|
||||||
(comma >> space? >> (operator_expression|r_value).as(:array_element)).repeat(0)).repeat(0,1)).as(:array_constant) >>
|
(comma >> space? >> r_value.as(:array_element)).repeat(0)).repeat(0,1)).as(:array_constant) >>
|
||||||
space? >> right_bracket
|
space? >> right_bracket
|
||||||
end
|
end
|
||||||
|
|
||||||
rule(:hash_pair) { basic_type.as(:hash_key) >> association >> (operator_expression|r_value).as(:hash_value) }
|
rule(:hash_pair) { basic_type.as(:hash_key) >> association >> r_value.as(:hash_value) }
|
||||||
rule(:hash_constant) { left_brace >> ((hash_pair.as(:hash_pair) >>
|
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)>>
|
(comma >> space? >> hash_pair.as(:hash_pair)).repeat(0)).repeat(0,1)).as(:hash_constant)>>
|
||||||
space? >> right_brace }
|
space? >> right_brace }
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
[42, foo]
|
[42, foo]
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:array,
|
||||||
s(:array,
|
|
||||||
s(:int, 42),
|
s(:int, 42),
|
||||||
s(:name, :foo)))
|
s(:name, :foo))
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
[ 3 + 4 , foo(22) ]
|
[ 3 + 4 , foo(22) ]
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:array,
|
||||||
s(:array,
|
s(:operator_value, :+,
|
||||||
s(:operator, "+",
|
|
||||||
s(:int, 3),
|
s(:int, 3),
|
||||||
s(:int, 4)),
|
s(:int, 4)),
|
||||||
s(:call,
|
s(:call,
|
||||||
s(:name, :foo),
|
s(:name, :foo),
|
||||||
s(:arguments,
|
s(:arguments,
|
||||||
s(:int, 22)))))
|
s(:int, 22))))
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
[42]
|
[42]
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:array,
|
||||||
s(:array,
|
s(:int, 42))
|
||||||
s(:int, 42)))
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{ foo => 33 }
|
{ foo => 33 }
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:hash,
|
||||||
s(:hash,
|
|
||||||
s(:assoc,
|
s(:assoc,
|
||||||
s(:name, :foo),
|
s(:name, :foo),
|
||||||
s(:int, 33))))
|
s(:int, 33)))
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{ foo => true }
|
{ foo => true }
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:hash,
|
||||||
s(:hash,
|
|
||||||
s(:assoc,
|
s(:assoc,
|
||||||
s(:name, :foo),
|
s(:name, :foo),
|
||||||
s(:true))))
|
s(:true)))
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
{foo => 33 , bar => 42}
|
{foo => 33 , bar => 42}
|
||||||
-- -- --
|
-- -- --
|
||||||
s(:expressions,
|
s(:hash,
|
||||||
s(:hash,
|
|
||||||
s(:assoc,
|
s(:assoc,
|
||||||
s(:name, :foo),
|
s(:name, :foo),
|
||||||
s(:int, 33)),
|
s(:int, 33)),
|
||||||
s(:assoc,
|
s(:assoc,
|
||||||
s(:name, :bar),
|
s(:name, :bar),
|
||||||
s(:int, 42))))
|
s(:int, 42)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user