diff --git a/lib/parser/compound_types.rb b/lib/parser/compound_types.rb index f09443da..f43cb9d6 100644 --- a/lib/parser/compound_types.rb +++ b/lib/parser/compound_types.rb @@ -1,12 +1,12 @@ module Parser # Compound types are Arrays and Hashes - module CompundTypes + module CompoundTypes include Parslet rule(:array) do left_bracket >> - ( ((operator_expression|value_expression).as(:element) >> space? >> - (comma >> space? >> (operator_expression|value_expression).as(:element)).repeat(0)).repeat(0,1)).as(:array) >> + ( ((operator_expression|value_expression).as(:array_element) >> space? >> + (comma >> space? >> (operator_expression|value_expression).as(:array_element)).repeat(0)).repeat(0,1)).as(:array) >> space? >> right_bracket end diff --git a/lib/parser/crystal.rb b/lib/parser/crystal.rb index 1e4c6198..9c4081cd 100644 --- a/lib/parser/crystal.rb +++ b/lib/parser/crystal.rb @@ -20,7 +20,7 @@ module Parser class Crystal < Parslet::Parser include BasicTypes - include CompundTypes + include CompoundTypes include Tokens include Keywords include Control diff --git a/lib/parser/transform.rb b/lib/parser/transform.rb index d7740a89..9ecfc2b5 100644 --- a/lib/parser/transform.rb +++ b/lib/parser/transform.rb @@ -11,7 +11,7 @@ module Parser rule(:name => simple(:name)) { Ast::NameExpression.new(name.to_s) } rule(:array => sequence(:array) ) { Ast::ArrayExpression.new(array) } - rule(:element => simple(:element)) { element } + rule(:array_element => simple(:array_element)) { array_element } rule(:hash => sequence(:hash) ) { Ast::HashExpression.new(hash) } rule(:hash_key => simple(:hash_key) , :hash_value => simple(:hash_value)) { Ast::AssociationExpression.new(hash_key,hash_value) } rule(:hash_pair => simple(:hash_pair) ) { hash_pair }