Class: Parser::AST::Processor

Inherits:
AST::Processor
  • Object
show all
Defined in:
lib/parser/ast/processor.rb

Direct Known Subclasses

Rewriter, TreeRewriter

Instance Method Summary collapse

Instance Method Details

#on_argObject


122
123
124
# File 'lib/parser/ast/processor.rb', line 122

def process_argument_node(node)
  on_argument(node)
end

#on_argument(node) ⇒ Object


105
106
107
108
109
110
111
112
113
114
115
# File 'lib/parser/ast/processor.rb', line 105

def on_argument(node)
  arg_name, value_node = *node

  if !value_node.nil?
    node.updated(nil, [
      arg_name, process(value_node)
    ])
  else
    node
  end
end

#on_back_refObject


39
40
41
# File 'lib/parser/ast/processor.rb', line 39

def process_variable_node(node)
  on_var(node)
end

#on_blockargObject


125
126
127
# File 'lib/parser/ast/processor.rb', line 125

def process_argument_node(node)
  on_argument(node)
end

#on_casgn(node) ⇒ Object


89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/parser/ast/processor.rb', line 89

def on_casgn(node)
  scope_node, name, value_node = *node

  if !value_node.nil?
    node.updated(nil, [
      process(scope_node), name, process(value_node)
    ])
  else
    node.updated(nil, [
      process(scope_node), name
    ])
  end
end

#on_const(node) ⇒ Object


81
82
83
84
85
86
87
# File 'lib/parser/ast/processor.rb', line 81

def on_const(node)
  scope_node, name = *node

  node.updated(nil, [
    process(scope_node), name
  ])
end

#on_cvarObject


38
39
40
# File 'lib/parser/ast/processor.rb', line 38

def process_variable_node(node)
  on_var(node)
end

#on_cvasgnObject


62
63
64
# File 'lib/parser/ast/processor.rb', line 62

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_def(node) ⇒ Object Also known as: on_def_e


157
158
159
160
161
162
163
164
# File 'lib/parser/ast/processor.rb', line 157

def on_def(node)
  name, args_node, body_node = *node

  node.updated(nil, [
    name,
    process(args_node), process(body_node)
  ])
end

#on_defs(node) ⇒ Object Also known as: on_defs_e


168
169
170
171
172
173
174
175
# File 'lib/parser/ast/processor.rb', line 168

def on_defs(node)
  definee_node, name, args_node, body_node = *node

  node.updated(nil, [
    process(definee_node), name,
    process(args_node), process(body_node)
  ])
end

#on_empty_else(node) ⇒ Object


287
288
289
# File 'lib/parser/ast/processor.rb', line 287

def on_empty_else(node)
  node
end

#on_forward_argObject


130
131
132
# File 'lib/parser/ast/processor.rb', line 130

def process_argument_node(node)
  on_argument(node)
end

#on_gvarObject


37
38
39
# File 'lib/parser/ast/processor.rb', line 37

def process_variable_node(node)
  on_var(node)
end

#on_gvasgnObject


61
62
63
# File 'lib/parser/ast/processor.rb', line 61

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_ivarObject


36
37
38
# File 'lib/parser/ast/processor.rb', line 36

def process_variable_node(node)
  on_var(node)
end

#on_ivasgnObject


60
61
62
# File 'lib/parser/ast/processor.rb', line 60

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_kwargObject


127
128
129
# File 'lib/parser/ast/processor.rb', line 127

def process_argument_node(node)
  on_argument(node)
end

#on_kwoptargObject


128
129
130
# File 'lib/parser/ast/processor.rb', line 128

def process_argument_node(node)
  on_argument(node)
end

#on_kwrestargObject


129
130
131
# File 'lib/parser/ast/processor.rb', line 129

def process_argument_node(node)
  on_argument(node)
end

#on_lvarObject


35
36
37
# File 'lib/parser/ast/processor.rb', line 35

def process_variable_node(node)
  on_var(node)
end

#on_lvasgnObject


59
60
61
# File 'lib/parser/ast/processor.rb', line 59

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_match_varObject


252
253
254
# File 'lib/parser/ast/processor.rb', line 252

def process_variable_node(node)
  on_var(node)
end

#on_nth_refObject


40
41
42
# File 'lib/parser/ast/processor.rb', line 40

def process_variable_node(node)
  on_var(node)
end

#on_numblock(node) ⇒ Object


199
200
201
202
203
204
205
# File 'lib/parser/ast/processor.rb', line 199

def on_numblock(node)
  method_call, max_numparam, body = *node

  node.updated(nil, [
    process(method_call), max_numparam, process(body)
  ])
end

#on_op_asgn(node) ⇒ Object


67
68
69
70
71
72
73
# File 'lib/parser/ast/processor.rb', line 67

def on_op_asgn(node)
  var_node, method_name, value_node = *node

  node.updated(nil, [
    process(var_node), method_name, process(value_node)
  ])
end

#on_optargObject


123
124
125
# File 'lib/parser/ast/processor.rb', line 123

def process_argument_node(node)
  on_argument(node)
end

#on_procarg0(node) ⇒ Object


132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/parser/ast/processor.rb', line 132

def on_procarg0(node)
  if node.children[0].is_a?(Symbol)
    # This branch gets executed when the builder
    # is not configured to emit and 'arg' inside 'procarg0', i.e. when
    #   Parser::Builders::Default.emit_arg_inside_procarg0
    # is set to false.
    #
    # If this flag is set to true this branch is unreachable.
    # s(:procarg0, :a)
    on_argument(node)
  else
    # s(:procarg0, s(:arg, :a), s(:arg, :b))
    process_regular_node(node)
  end
end

#on_restargObject


124
125
126
# File 'lib/parser/ast/processor.rb', line 124

def process_argument_node(node)
  on_argument(node)
end

#on_send(node) ⇒ Object Also known as: on_csend


182
183
184
185
186
187
188
189
# File 'lib/parser/ast/processor.rb', line 182

def on_send(node)
  receiver_node, method_name, *arg_nodes = *node

  receiver_node = process(receiver_node) if receiver_node
  node.updated(nil, [
    receiver_node, method_name, *process_all(arg_nodes)
  ])
end

#on_shadowargObject


126
127
128
# File 'lib/parser/ast/processor.rb', line 126

def process_argument_node(node)
  on_argument(node)
end

#on_var(node) ⇒ Object


26
27
28
# File 'lib/parser/ast/processor.rb', line 26

def on_var(node)
  node
end

#on_vasgn(node) ⇒ Object


42
43
44
45
46
47
48
49
50
51
52
# File 'lib/parser/ast/processor.rb', line 42

def on_vasgn(node)
  name, value_node = *node

  if !value_node.nil?
    node.updated(nil, [
      name, process(value_node)
    ])
  else
    node
  end
end

#process_argument_node(node) ⇒ Object


118
119
120
# File 'lib/parser/ast/processor.rb', line 118

def process_argument_node(node)
  on_argument(node)
end

#process_regular_node(node) ⇒ Object Also known as: on_dstr, on_dsym, on_regexp, on_xstr, on_splat, on_kwsplat, on_array, on_pair, on_hash, on_irange, on_erange, on_and_asgn, on_or_asgn, on_mlhs, on_masgn, on_rasgn, on_mrasgn, on_args, on_arg_expr, on_restarg_expr, on_blockarg_expr, on_block_pass, on_module, on_class, on_sclass, on_undef, on_alias, on_index, on_indexasgn, on_block, on_lambda, on_while, on_while_post, on_until, on_until_post, on_for, on_return, on_break, on_next, on_redo, on_retry, on_super, on_yield, on_defined?, on_not, on_and, on_or, on_if, on_when, on_case, on_iflipflop, on_eflipflop, on_match_current_line, on_match_with_lvasgn, on_resbody, on_rescue, on_ensure, on_begin, on_kwbegin, on_preexe, on_postexe, on_case_match, on_in_match, on_in_pattern, on_if_guard, on_unless_guard, on_match_rest, on_pin, on_match_alt, on_match_as, on_array_pattern, on_array_pattern_with_tail, on_hash_pattern, on_const_pattern, on_find_pattern


10
11
12
# File 'lib/parser/ast/processor.rb', line 10

def process_regular_node(node)
  node.updated(nil, process_all(node))
end

#process_var_asgn_node(node) ⇒ Object


55
56
57
# File 'lib/parser/ast/processor.rb', line 55

def process_var_asgn_node(node)
  on_vasgn(node)
end

#process_variable_node(node) ⇒ Object


31
32
33
# File 'lib/parser/ast/processor.rb', line 31

def process_variable_node(node)
  on_var(node)
end