Module: RipperRubyParser::SexpHandlers::Literals Private
- Defined in:
- lib/ripper_ruby_parser/sexp_handlers/literals.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Sexp handlers for literals
Constant Summary collapse
- INTERPOLATING_HEREDOC =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^<<[-~]?[^-~']/.freeze
- NON_INTERPOLATING_HEREDOC =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^<<[-~]?'/.freeze
- INTERPOLATING_STRINGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
['"', '`', ':"', /^%Q.$/, /^%.$/].freeze
- NON_INTERPOLATING_STRINGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
["'", ":'", /^%q.$/].freeze
- INTERPOLATING_WORD_LIST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^%[WI].$/.freeze
- NON_INTERPOLATING_WORD_LIST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^%[wi].$/.freeze
- REGEXP_LITERALS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
['/', /^%r.$/].freeze
Instance Method Summary collapse
- #process_array(exp) ⇒ Object private
- #process_assoc_splat(exp) ⇒ Object private
- #process_at_tstring_content(exp) ⇒ Object private
- #process_dyna_symbol(exp) ⇒ Object private
-
#process_hash(exp) ⇒ Object
private
Handle hash literals sexps.
- #process_qsymbols(exp) ⇒ Object private
- #process_regexp(exp) ⇒ Object private
- #process_regexp_literal(exp) ⇒ Object private
- #process_string_concat(exp) ⇒ Object private
- #process_string_content(exp) ⇒ Object (also: #process_word) private
- #process_string_dvar(exp) ⇒ Object private
- #process_string_embexpr(exp) ⇒ Object private
- #process_string_literal(exp) ⇒ Object private
- #process_symbol(exp) ⇒ Object private
- #process_symbol_literal(exp) ⇒ Object private
- #process_symbols(exp) ⇒ Object private
- #process_xstring(exp) ⇒ Object private
- #process_xstring_literal(exp) ⇒ Object private
Instance Method Details
#process_array(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
137 138 139 140 141 142 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 137 def process_array(exp) _, elems = exp.shift 2 return s(:array) if elems.nil? process(elems).tap { |arr| arr.sexp_type = :array } end |
#process_assoc_splat(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 164 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 161 def process_assoc_splat(exp) _, param = exp.shift 2 s(:kwsplat, process(param)) end |
#process_at_tstring_content(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 133 134 135 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 130 def process_at_tstring_content(exp) _, content, pos, delim = exp.shift 4 string = handle_string_unescaping(content, delim) string = handle_string_encoding(string, delim) with_position(pos, s(:str, string)) end |
#process_dyna_symbol(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
105 106 107 108 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 105 def process_dyna_symbol(exp) _, node = exp.shift 2 handle_dyna_symbol_content(node) end |
#process_hash(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Handle hash literals sexps. These can be either empty, or contain a nested :assoclist_from_args Sexp.
151 152 153 154 155 156 157 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 151 def process_hash(exp) _, body = exp.shift 2 return s(:hash) unless body _, elems = body s(:hash, *make_hash_items(elems)) end |
#process_qsymbols(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
110 111 112 113 114 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 110 def process_qsymbols(exp) _, *items = shift_all(exp) items = items.map { |item| handle_symbol_content(item) } s(:qsymbols, *items) end |
#process_regexp(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 92 93 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 89 def process_regexp(exp) _, *rest = shift_all exp line, string, rest = extract_string_parts(rest) with_line_number(line, s(:dregx, string, *rest)) end |
#process_regexp_literal(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 74 def process_regexp_literal(exp) _, content, (_, flags,) = exp.shift 3 content = process(content) numflags = character_flags_to_numerical flags if content.length == 2 return with_line_number(content.line, s(:lit, Regexp.new(content.last, numflags))) end content.sexp_type = :dregx_once if flags =~ /o/ content << numflags unless numflags == 0 content end |
#process_string_concat(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 46 def process_string_concat(exp) _, left, right = exp.shift 3 left = process(left) right = process(right) if left.sexp_type == :str merge_left_into_right(left, right) else merge_right_into_left(left, right) end end |
#process_string_content(exp) ⇒ Object Also known as: process_word
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 12 def process_string_content(exp) _, *rest = shift_all exp line, string, rest = extract_string_parts(rest) if rest.empty? with_line_number(line, s(:str, string)) else s(:dstr, string, *rest) end end |
#process_string_dvar(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 40 def process_string_dvar(exp) _, list = exp.shift 2 val = process(list) s(:dstr, '', s(:evstr, val)) end |
#process_string_embexpr(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 25 def process_string_embexpr(exp) _, list = exp.shift 2 val = process(list.sexp_body.first) case val.sexp_type when :str, :dstr val when :void_stmt s(:dstr, '', s(:evstr)) else s(:dstr, '', s(:evstr, val)) end end |
#process_string_literal(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 7 def process_string_literal(exp) _, content = exp.shift 2 process(content) end |
#process_symbol(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
100 101 102 103 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 100 def process_symbol(exp) _, node = exp.shift 2 handle_symbol_content(node) end |
#process_symbol_literal(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 98 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 95 def process_symbol_literal(exp) _, symbol = exp.shift 2 handle_symbol_content(symbol) end |
#process_symbols(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 117 118 119 120 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 116 def process_symbols(exp) _, *items = shift_all(exp) items = items.map { |item| handle_dyna_symbol_content(item) } s(:symbols, *items) end |
#process_xstring(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 67 68 69 70 71 72 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 64 def process_xstring(exp) _, *rest = shift_all exp line, string, rest = extract_string_parts(rest) if rest.empty? s(:xstr, string).line(line) else s(:dxstr, string, *rest) end end |
#process_xstring_literal(exp) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 62 |
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 59 def process_xstring_literal(exp) _, content = exp.shift 2 process(content) end |