Project

General

Profile

Backport #4365

Ripper.sexp should return an :array node for words/qwords

Added by adgar (Michael Edgar) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal

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

ripper.words.diff (488 Bytes) ripper.words.diff adgar (Michael Edgar), 02/04/2011 07:14 AM

Associated revisions

Revision b1986003
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 30805
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

Revision 30805
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

Revision 30805
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

Revision 30805
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

Revision 30805
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

Revision 30805
Added by nobu (Nobuyoshi Nakada) over 8 years ago

  • parse.y (words, qwords): dispatch array events. based on a patch from Michael Edgar. [Bug #4365].

Revision 5b0cef85
Added by yugui (Yuki Sonoda) over 8 years ago

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].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 31510
Added by yugui (Yuki Sonoda) over 8 years ago

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].

History

#1

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Category set to core

=begin

=end

#2

Updated by nobu (Nobuyoshi Nakada) over 8 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
#3

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Closed to Assigned
  • Assignee set to yugui (Yuki Sonoda)

=begin

=end

#4

Updated by yugui (Yuki Sonoda) over 8 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].

Also available in: Atom PDF