lib/code/parser/dictionnary.rb in code-ruby-parser-0.1.2 vs lib/code/parser/dictionnary.rb in code-ruby-parser-0.1.3
- old
+ new
@@ -11,37 +11,41 @@
dictionnary << parse_key_value while match(COMMA) && !end_of_input?
match(CLOSING_CURLY_BRACKET)
- { dictionnary: dictionnary.compact, comments: comments }
+ { dictionnary: dictionnary.compact, comments: comments }.compact
else
parse_subclass(::Code::Parser::List)
end
end
def parse_key_value
+ previous_cursor = cursor
+
comments_before = parse_comments
key = parse_subclass(::Code::Parser::Statement)
comments_after = parse_comments
- return unless key
+ if key
+ if match(COLON) || match(EQUAL + GREATER)
+ value = parse_code
+ else
+ value = nil
+ end
- if match(COLON) || match(EQUAL + GREATER)
{
key: key,
- value: parse_code,
+ value: value,
comments_before: comments_before,
comments_after: comments_after
}.compact
else
- {
- key: key,
- comments_before: comments_before,
- comments_after: comments_after
- }.compact
+ @cursor = previous_cursor
+ buffer!
+ return
end
end
end
end
end