Module: RipperRubyParser::SexpHandlers::StringLiterals Private
- Defined in:
- lib/ripper_ruby_parser/sexp_handlers/string_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 string and stringlike literals
Instance Method Summary collapse
- #process_at_tstring_content(exp) ⇒ Object private
- #process_dyna_symbol(exp) ⇒ Object private
- #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_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.
124 125 126 127 128 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 124 def process_at_tstring_content(exp) _, content, pos, delim = exp.shift 4 string = handle_string_unescaping(content, 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.
107 108 109 110 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 107 def process_dyna_symbol(exp) _, node = exp.shift 2 handle_dyna_symbol_content(node) 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.
112 113 114 115 116 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 112 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.
91 92 93 94 95 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 91 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.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 76 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.include?("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/string_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/string_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/string_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/string_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/string_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.
102 103 104 105 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 102 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.
97 98 99 100 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 97 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.
118 119 120 121 122 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 118 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 73 74 |
# File 'lib/ripper_ruby_parser/sexp_handlers/string_literals.rb', line 64 def process_xstring(exp) _, *rest = shift_all exp line, string, rest = extract_string_parts(rest) result = if rest.empty? s(:xstr, string) else s(:dxstr, string, *rest) end result.line = line result 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/string_literals.rb', line 59 def process_xstring_literal(exp) _, content = exp.shift 2 process(content) end |