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, except hash and array literals

Instance Method Summary collapse

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
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 124

def process_at_tstring_content(exp)
  _, string, = exp.shift 3
  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/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/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/literals.rb', line 91

def process_regexp(exp)
  _, *rest = shift_all exp
  string, rest = extract_string_parts(rest)
  s(:regexp, 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.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 72

def process_regexp_literal(exp)
  _, content, (_, flags,) = exp.shift 3

  string, rest = process(content).sexp_body
  numflags = character_flags_to_numerical flags

  if rest.empty?
    s(:lit, Regexp.new(string, numflags))
  else
    rest << numflags if numflags > 0
    sexp_type = if flags =~ /o/
                  :dregx_once
                else
                  :dregx
                end
    s(sexp_type, string, *rest)
  end
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.



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 44

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.



10
11
12
13
14
15
16
17
18
19
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 10

def process_string_content(exp)
  _, *rest = shift_all exp
  string, rest = extract_string_parts(rest)

  if rest.empty?
    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.



38
39
40
41
42
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 38

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.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 23

def process_string_embexpr(exp)
  _, list = exp.shift 2

  val = process(list.sexp_body.first)

  case val.sexp_type
  when :str
    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.



5
6
7
8
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 5

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/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/literals.rb', line 97

def process_symbol_literal(exp)
  _, symbol = exp.shift 2
  process(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/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.



62
63
64
65
66
67
68
69
70
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 62

def process_xstring(exp)
  _, *rest = shift_all exp
  string, rest = extract_string_parts(rest)
  if rest.empty?
    s(:xstr, string)
  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.



57
58
59
60
# File 'lib/ripper_ruby_parser/sexp_handlers/literals.rb', line 57

def process_xstring_literal(exp)
  _, content = exp.shift 2
  process(content)
end