Project

General

Profile

Actions

Backport #4365

closed

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

Added by adgar (Michael Edgar) about 13 years ago. Updated almost 13 years ago.

Status:
Closed

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
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 13 years ago

  • Category set to core

=begin

=end

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 13 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
Actions #3

Updated by nobu (Nobuyoshi Nakada) about 13 years ago

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

=begin

=end

Actions #4

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0