Class: Parser::AST::Processor

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

Instance Method Summary collapse

Instance Method Details

#on_argObject


120
121
122
# File 'lib/parser/ast/processor.rb', line 120

def process_argument_node(node)
  on_argument(node)
end

#on_argument(node) ⇒ Object


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

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


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

def process_variable_node(node)
  on_var(node)
end

#on_blockargObject


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

def process_argument_node(node)
  on_argument(node)
end

#on_casgn(node) ⇒ Object


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

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


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

def on_const(node)
  scope_node, name = *node

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

#on_cvarObject


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

def process_variable_node(node)
  on_var(node)
end

#on_cvasgnObject


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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_def(node) ⇒ Object


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

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


164
165
166
167
168
169
170
171
# File 'lib/parser/ast/processor.rb', line 164

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


283
284
285
# File 'lib/parser/ast/processor.rb', line 283

def on_empty_else(node)
  node
end

#on_forward_argObject


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

def process_argument_node(node)
  on_argument(node)
end

#on_gvarObject


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

def process_variable_node(node)
  on_var(node)
end

#on_gvasgnObject


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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_ivarObject


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

def process_variable_node(node)
  on_var(node)
end

#on_ivasgnObject


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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_kwargObject


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

def process_argument_node(node)
  on_argument(node)
end

#on_kwoptargObject


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

def process_argument_node(node)
  on_argument(node)
end

#on_kwrestargObject


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

def process_argument_node(node)
  on_argument(node)
end

#on_lvarObject


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

def process_variable_node(node)
  on_var(node)
end

#on_lvasgnObject


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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#on_match_varObject


248
249
250
# File 'lib/parser/ast/processor.rb', line 248

def process_variable_node(node)
  on_var(node)
end

#on_nth_refObject


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

def process_variable_node(node)
  on_var(node)
end

#on_numblock(node) ⇒ Object


193
194
195
196
197
198
199
# File 'lib/parser/ast/processor.rb', line 193

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


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

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


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

def process_argument_node(node)
  on_argument(node)
end

#on_procarg0(node) ⇒ Object


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

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


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

def process_argument_node(node)
  on_argument(node)
end

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


176
177
178
179
180
181
182
183
# File 'lib/parser/ast/processor.rb', line 176

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


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

def process_argument_node(node)
  on_argument(node)
end

#on_var(node) ⇒ Object


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

def on_var(node)
  node
end

#on_vasgn(node) ⇒ Object


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

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


116
117
118
# File 'lib/parser/ast/processor.rb', line 116

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_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


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


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

def process_var_asgn_node(node)
  on_vasgn(node)
end

#process_variable_node(node) ⇒ Object


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

def process_variable_node(node)
  on_var(node)
end