Class: Parser::AST::Processor

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

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



42
43
44
# File 'lib/parser/ast/processor.rb', line 42

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



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

def process_variable_node(node)
  on_var(node)
end

#on_cvasgnObject



65
66
67
# File 'lib/parser/ast/processor.rb', line 65

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_def(node) ⇒ Object



160
161
162
163
164
165
166
167
# File 'lib/parser/ast/processor.rb', line 160

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



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

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



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

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



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

def process_variable_node(node)
  on_var(node)
end

#on_gvasgnObject



64
65
66
# File 'lib/parser/ast/processor.rb', line 64

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_ivarObject



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

def process_variable_node(node)
  on_var(node)
end

#on_ivasgnObject



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

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



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

def process_variable_node(node)
  on_var(node)
end

#on_lvasgnObject



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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_match_varObject



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

def process_variable_node(node)
  on_var(node)
end

#on_nth_refObject



43
44
45
# File 'lib/parser/ast/processor.rb', line 43

def process_variable_node(node)
  on_var(node)
end

#on_numblock(node) ⇒ Object



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

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



70
71
72
73
74
75
76
# File 'lib/parser/ast/processor.rb', line 70

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



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

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



29
30
31
# File 'lib/parser/ast/processor.rb', line 29

def on_var(node)
  node
end

#on_vasgn(node) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/parser/ast/processor.rb', line 45

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_kwargs, on_irange, on_erange, on_and_asgn, on_or_asgn, on_mlhs, on_masgn, on_args, on_arg_expr, on_restarg_expr, on_blockarg_expr, on_block_pass, on_forwarded_restarg, on_forwarded_kwrestarg, 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_match_pattern, on_match_pattern_p, 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



12
13
14
# File 'lib/parser/ast/processor.rb', line 12

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

#process_var_asgn_node(node) ⇒ Object



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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#process_variable_node(node) ⇒ Object



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

def process_variable_node(node)
  on_var(node)
end