Backport #4365
closedRipper.sexp should return an :array node for words/qwords
Description
=begin
Currently, Ripper has no rule for the words/qwords base rule. It simply returns the array of string literals (and embexprs... etc) contained within the qwords/words expression. Example:
[:program,
[[
[:@tstring_content, "abc", [1, 3]], [:@tstring_content, "def", [1, 7]]]]]
pp Ripper.sexp('["abc", "def"]')
[:program,
[[:array,
[[:string_literal, [:string_content, [:@tstring_content, "abc", [1, 2]]]],
[:string_literal,
[:string_content, [:@tstring_content, "def", [1, 9]]]]]]]]
Note that in the first example, the root node of the program (after the :program node) does not have a node type at all. I believe this is an error, and makes discovering words/qwords nodes in an AST quite difficult. I feel that for consistency with array literals, it should create an array node, or at least have a node type of its own. I'd prefer that:
['a', 'b', 'c']
and
%w(a b c)
return the same AST, as the latter is merely syntactic sugar for the former. I've attached a small patch to that effect, though if a different node type is desired for words/qwords, that's more than possible by renaming the node in the added calls to dispatch1.
=end
Files
Updated by nobu (Nobuyoshi Nakada) almost 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r30805.
Michael, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- parse.y (words, qwords): dispatch array events. based on a
patch from Michael Edgar. [Bug #4365].
=end
Updated by nobu (Nobuyoshi Nakada) almost 14 years ago
- Status changed from Closed to Assigned
- Assignee set to yugui (Yuki Sonoda)
=begin
=end
Updated by yugui (Yuki Sonoda) over 13 years ago
- Status changed from Assigned to Closed
This issue was solved with changeset r31510.
Michael, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merges r30805 and r30809 from trunk into ruby_1_9_2. fixes #4365¶
- parse.y (words, qwords): dispatch array events. based on a
patch from Michael Edgar. [Bug #4365].