Parent

Methods

RubyParser

Attributes

canonicalize_conditions[RW]

Canonicalize conditionals. Eg:

not x ? a : b

becomes:

x ? b : a
comments[R]
env[R]
file[RW]
in_def[RW]
in_single[RW]
lexer[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/ruby_parser_extras.rb, line 333
def initialize(options = {})
  super()
  self.lexer = RubyLexer.new
  self.lexer.parser = self
  @env = Environment.new
  @comments = []

  @canonicalize_conditions = true

  self.reset
end

Public Instance Methods

_reduce_1(val, _values, result) click to toggle source

reduce 0 omitted

# File lib/ruby_parser.rb, line 2938
def _reduce_1(val, _values, result)
                      self.lexer.lex_state = :expr_beg
                    
    result
end
_reduce_10(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2985
def _reduce_10(val, _values, result)
                      result = s(:alias, val[1], val[3]).line(val[2])
                    
    result
end
_reduce_100(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3516
def _reduce_100(val, _values, result)
                      lexer.lex_state = :expr_end
                      result = val[0]
                    
    result
end
_reduce_103(val, _values, result) click to toggle source

reduce 102 omitted

# File lib/ruby_parser.rb, line 3527
def _reduce_103(val, _values, result)
 result = s(:lit, val[0].to_sym) 
    result
end
_reduce_105(val, _values, result) click to toggle source

reduce 104 omitted

# File lib/ruby_parser.rb, line 3534
def _reduce_105(val, _values, result)
                      result = new_undef val[0]
                    
    result
end
_reduce_106(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3540
def _reduce_106(val, _values, result)
                      lexer.lex_state = :expr_fname
                    
    result
end
_reduce_107(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3546
def _reduce_107(val, _values, result)
                      result = new_undef val[0], val[3]
                    
    result
end
_reduce_11(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2991
def _reduce_11(val, _values, result)
                      result = s(:valias, val[1].to_sym, val[2].to_sym)
                    
    result
end
_reduce_12(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2997
def _reduce_12(val, _values, result)
                      result = s(:valias, val[1].to_sym, :"$#{val[2]}")
                    
    result
end
_reduce_13(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3003
def _reduce_13(val, _values, result)
                      yyerror "can't make alias for the number variables"
                    
    result
end
_reduce_14(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3009
def _reduce_14(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_15(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3015
def _reduce_15(val, _values, result)
                      result = new_if val[2], val[0], nil
                    
    result
end
_reduce_16(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3021
def _reduce_16(val, _values, result)
                      result = new_if val[2], nil, val[0]
                    
    result
end
_reduce_17(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3027
def _reduce_17(val, _values, result)
                      result = new_while val[0], val[2], true
                    
    result
end
_reduce_175(val, _values, result) click to toggle source

reduce 174 omitted

# File lib/ruby_parser.rb, line 3686
def _reduce_175(val, _values, result)
                      result = self.node_assign val[0], val[2]
                    
    result
end
_reduce_176(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3692
def _reduce_176(val, _values, result)
                      result = self.node_assign val[0], s(:rescue, val[2], s(:resbody, s(:array), val[4]))
                      # result.line = val[0].line
                    
    result
end
_reduce_177(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3699
def _reduce_177(val, _values, result)
                      result = new_op_asgn val
                    
    result
end
_reduce_178(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3705
def _reduce_178(val, _values, result)
                      result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
                      val[2][0] = :arglist
                    
    result
end
_reduce_179(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3712
def _reduce_179(val, _values, result)
                      result = s(:op_asgn2, val[0], :"#{val[2]}=", val[3].to_sym, val[4])
                    
    result
end
_reduce_18(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3033
def _reduce_18(val, _values, result)
                      result = new_until val[0], val[2], true
                    
    result
end
_reduce_180(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3718
def _reduce_180(val, _values, result)
                      result = s(:op_asgn2, val[0], :"#{val[2]}=", val[3].to_sym, val[4])
                    
    result
end
_reduce_181(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3724
def _reduce_181(val, _values, result)
                      result = s(:op_asgn, val[0], val[4], val[2], val[3])
                    
    result
end
_reduce_182(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3730
def _reduce_182(val, _values, result)
                      yyerror "constant re-assignment"
                    
    result
end
_reduce_183(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3736
def _reduce_183(val, _values, result)
                      yyerror "constant re-assignment"
                    
    result
end
_reduce_184(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3742
def _reduce_184(val, _values, result)
                      self.backref_assign_error val[0]
                    
    result
end
_reduce_185(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3748
def _reduce_185(val, _values, result)
                      v1, v2 = val[0], val[2]
                      if v1.node_type == :lit and v2.node_type == :lit and Fixnum === v1.last and Fixnum === v2.last then
                        result = s(:lit, (v1.last)..(v2.last))
                      else
                        result = s(:dot2, v1, v2)
                      end
                    
    result
end
_reduce_186(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3759
def _reduce_186(val, _values, result)
                      v1, v2 = val[0], val[2]
                      if v1.node_type == :lit and v2.node_type == :lit and Fixnum === v1.last and Fixnum === v2.last then
                        result = s(:lit, (v1.last)...(v2.last))
                      else
                        result = s(:dot3, v1, v2)
                      end
                    
    result
end
_reduce_187(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3770
def _reduce_187(val, _values, result)
                      result = new_call val[0], :+, s(:arglist, val[2])
                    
    result
end
_reduce_188(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3776
def _reduce_188(val, _values, result)
                      result = new_call val[0], :-, s(:arglist, val[2])
                    
    result
end
_reduce_189(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3782
def _reduce_189(val, _values, result)
                      result = new_call val[0], :*, s(:arglist, val[2])
                    
    result
end
_reduce_19(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3039
def _reduce_19(val, _values, result)
                      result = s(:rescue, val[0], s(:resbody, s(:array), val[2]))
                    
    result
end
_reduce_190(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3788
def _reduce_190(val, _values, result)
                      result = new_call val[0], :"/", s(:arglist, val[2])
                    
    result
end
_reduce_191(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3794
def _reduce_191(val, _values, result)
                      result = new_call val[0], :%, s(:arglist, val[2])
                    
    result
end
_reduce_192(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3800
def _reduce_192(val, _values, result)
                      result = new_call val[0], :**, s(:arglist, val[2])
                    
    result
end
_reduce_193(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3806
def _reduce_193(val, _values, result)
                      result = new_call(new_call(s(:lit, val[1]), :"**", s(:arglist, val[3])), :"-@", s(:arglist))
                    
    result
end
_reduce_194(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3812
def _reduce_194(val, _values, result)
                      result = new_call(new_call(s(:lit, val[1]), :"**", s(:arglist, val[3])), :"-@", s(:arglist))
                    
    result
end
_reduce_195(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3818
def _reduce_195(val, _values, result)
                      if val[1][0] == :lit then
                        result = val[1]
                      else
                        result = new_call val[1], :"+@", s(:arglist)
                      end
                    
    result
end
_reduce_196(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3828
def _reduce_196(val, _values, result)
                      result = new_call val[1], :"-@", s(:arglist)
                    
    result
end
_reduce_197(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3834
def _reduce_197(val, _values, result)
                      result = new_call val[0], :"|", s(:arglist, val[2])
                    
    result
end
_reduce_198(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3840
def _reduce_198(val, _values, result)
                      result = new_call val[0], :"^", s(:arglist, val[2])
                    
    result
end
_reduce_199(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3846
def _reduce_199(val, _values, result)
                      result = new_call val[0], :"&", s(:arglist, val[2])
                    
    result
end
_reduce_2(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2944
def _reduce_2(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_20(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3045
def _reduce_20(val, _values, result)
                      if (self.in_def || self.in_single > 0) then
                        yyerror "BEGIN in method"
                      end
                      self.env.extend
                    
    result
end
_reduce_200(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3852
def _reduce_200(val, _values, result)
                      result = new_call val[0], :"<=>", s(:arglist, val[2])
                    
    result
end
_reduce_201(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3858
def _reduce_201(val, _values, result)
                      result = new_call val[0], :">", s(:arglist, val[2])
                    
    result
end
_reduce_202(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3864
def _reduce_202(val, _values, result)
                      result = new_call val[0], :">=", s(:arglist, val[2])
                    
    result
end
_reduce_203(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3870
def _reduce_203(val, _values, result)
                      result = new_call val[0], :"<", s(:arglist, val[2])
                    
    result
end
_reduce_204(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3876
def _reduce_204(val, _values, result)
                      result = new_call val[0], :"<=", s(:arglist, val[2])
                    
    result
end
_reduce_205(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3882
def _reduce_205(val, _values, result)
                      result = new_call val[0], :"==", s(:arglist, val[2])
                    
    result
end
_reduce_206(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3888
def _reduce_206(val, _values, result)
                      result = new_call val[0], :"===", s(:arglist, val[2])
                    
    result
end
_reduce_207(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3894
def _reduce_207(val, _values, result)
                      val[0] = value_expr val[0] # TODO: port call_op and clean these
                      val[2] = value_expr val[2]
                      result = s(:not, new_call(val[0], :"==", s(:arglist, val[2])))
                    
    result
end
_reduce_208(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3902
def _reduce_208(val, _values, result)
                      result = self.get_match_node val[0], val[2]
                    
    result
end
_reduce_209(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3908
def _reduce_209(val, _values, result)
                      result = s(:not, self.get_match_node(val[0], val[2]))
                    
    result
end
_reduce_21(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3054
def _reduce_21(val, _values, result)
                      result = new_iter s(:preexe), nil, val[3] # TODO: add test?
                      result = nil # TODO: since it isn't supposed to go in the AST
                    
    result
end
_reduce_210(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3914
def _reduce_210(val, _values, result)
                      result = s(:not, val[1])
                    
    result
end
_reduce_211(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3920
def _reduce_211(val, _values, result)
                      val[2] = value_expr val[2]
                      result = new_call val[1], :"~", s(:arglist)
                    
    result
end
_reduce_212(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3927
def _reduce_212(val, _values, result)
                      val[0] = value_expr val[0]
                      val[2] = value_expr val[2]
                      result = new_call val[0], :"\<\<", s(:arglist, val[2])
                    
    result
end
_reduce_213(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3935
def _reduce_213(val, _values, result)
                      val[0] = value_expr val[0]
                      val[2] = value_expr val[2]
                      result = new_call val[0], :">>", s(:arglist, val[2])
                    
    result
end
_reduce_214(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3943
def _reduce_214(val, _values, result)
                      result = logop(:and, val[0], val[2])
                    
    result
end
_reduce_215(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3949
def _reduce_215(val, _values, result)
                      result = logop(:or, val[0], val[2])
                    
    result
end
_reduce_216(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3955
def _reduce_216(val, _values, result)
                      result = s(:defined, val[2])
                    
    result
end
_reduce_217(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3961
def _reduce_217(val, _values, result)
                      result = s(:if, val[0], val[2], val[4])
                    
    result
end
_reduce_219(val, _values, result) click to toggle source

reduce 218 omitted

# File lib/ruby_parser.rb, line 3969
def _reduce_219(val, _values, result)
                      result = value_expr(val[0])
                    
    result
end
_reduce_22(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3061
def _reduce_22(val, _values, result)
                      if (self.in_def || self.in_single > 0) then
                        yyerror "END in method; use at_exit"
                      end
                      result = new_iter s(:postexe), nil, val[2]
                    
    result
end
_reduce_221(val, _values, result) click to toggle source

reduce 220 omitted

# File lib/ruby_parser.rb, line 3977
def _reduce_221(val, _values, result)
                      warning 'parenthesize argument(s) for future version'
                      result = s(:array, val[0])
                    
    result
end
_reduce_222(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3984
def _reduce_222(val, _values, result)
                      result = val[0]
                    
    result
end
_reduce_223(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3990
def _reduce_223(val, _values, result)
                      result = self.arg_concat val[0], val[3]
                    
    result
end
_reduce_224(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3996
def _reduce_224(val, _values, result)
                      result = s(:array, s(:hash, *val[0].values))
                    
    result
end
_reduce_225(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4002
def _reduce_225(val, _values, result)
                      result = s(:array, s(:splat, val[1]))
                    
    result
end
_reduce_226(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4008
def _reduce_226(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_227(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4014
def _reduce_227(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_228(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4020
def _reduce_228(val, _values, result)
                      warning "parenthesize argument(s) for future version"
                      result = s(:array, val[1])
                    
    result
end
_reduce_229(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4027
def _reduce_229(val, _values, result)
                      warning "parenthesize argument(s) for future version"
                      result = val[1].add val[3]
                    
    result
end
_reduce_23(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3070
def _reduce_23(val, _values, result)
                      result = self.node_assign val[0], val[2]
                    
    result
end
_reduce_232(val, _values, result) click to toggle source

reduce 231 omitted

# File lib/ruby_parser.rb, line 4038
def _reduce_232(val, _values, result)
                      warning "parenthesize argument(s) for future version"
                      result = s(:array, val[0])
                    
    result
end
_reduce_233(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4045
def _reduce_233(val, _values, result)
                      result = self.arg_blk_pass val[0], val[1]
                    
    result
end
_reduce_234(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4051
def _reduce_234(val, _values, result)
                      result = self.arg_concat val[0], val[3]
                      result = self.arg_blk_pass result, val[4]
                    
    result
end
_reduce_235(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4058
def _reduce_235(val, _values, result)
                      result = s(:array, s(:hash, *val[0].values))
                      result = self.arg_blk_pass result, val[1]
                    
    result
end
_reduce_236(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4065
def _reduce_236(val, _values, result)
                      result = self.arg_concat s(:array, s(:hash, *val[0].values)), val[3]
                      result = self.arg_blk_pass result, val[4]
                    
    result
end
_reduce_237(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4072
def _reduce_237(val, _values, result)
                      result = val[0] << s(:hash, *val[2].values)
                      result = self.arg_blk_pass result, val[3]
                    
    result
end
_reduce_238(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4079
def _reduce_238(val, _values, result)
                      val[0] << s(:hash, *val[2].values)
                      result = self.arg_concat val[0], val[5]
                      result = self.arg_blk_pass result, val[6]
                    
    result
end
_reduce_239(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4087
def _reduce_239(val, _values, result)
                      result = self.arg_blk_pass s(:splat, val[1]), val[2]
                    
    result
end
_reduce_24(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3076
def _reduce_24(val, _values, result)
                      result = new_masgn val[0], val[2], :wrap
                    
    result
end
_reduce_241(val, _values, result) click to toggle source

reduce 240 omitted

# File lib/ruby_parser.rb, line 4095
def _reduce_241(val, _values, result)
                      args = self.list_prepend val[0], val[2]
                      result = self.arg_blk_pass args, val[3]
                    
    result
end
_reduce_242(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4102
def _reduce_242(val, _values, result)
                      result = self.arg_blk_pass val[0], val[2]
                    
    result
end
_reduce_243(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4108
def _reduce_243(val, _values, result)
                      result = self.arg_concat s(:array, val[0]), val[3]
                      result = self.arg_blk_pass result, val[4]
                    
    result
end
_reduce_244(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4115
def _reduce_244(val, _values, result)
                      result = self.arg_concat s(:array, val[0], s(:hash, *val[2].values)), val[5]
                      result = self.arg_blk_pass result, val[6]
                    
    result
end
_reduce_245(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4122
def _reduce_245(val, _values, result)
                      result = s(:array, s(:hash, *val[0].values))
                      result = self.arg_blk_pass result, val[1]
                    
    result
end
_reduce_246(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4129
def _reduce_246(val, _values, result)
                      result = s(:array, s(:hash, *val[0].values), val[3])
                      result = self.arg_blk_pass result, val[4]
                    
    result
end
_reduce_247(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4136
def _reduce_247(val, _values, result)
                      result = s(:array, val[0], s(:hash, *val[2].values))
                      result = self.arg_blk_pass result, val[3]
                    
    result
end
_reduce_248(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4143
def _reduce_248(val, _values, result)
                      result = s(:array, val[0]).add_all(val[2]).add(s(:hash, *val[4].values))
                      result = self.arg_blk_pass result, val[5]
                    
    result
end
_reduce_249(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4150
def _reduce_249(val, _values, result)
                      result = self.arg_concat s(:array, val[0]).add(s(:hash, *val[2].values)), val[5]
                      result = self.arg_blk_pass result, val[6]
                    
    result
end
_reduce_25(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3082
def _reduce_25(val, _values, result)
                      result = new_op_asgn val
                    
    result
end
_reduce_250(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4157
def _reduce_250(val, _values, result)
                      result = self.arg_concat s(:array, val[0]).add_all(val[2]).add(s(:hash, *val[4].values)), val[7]
                      result = self.arg_blk_pass result, val[8]
                    
    result
end
_reduce_251(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4164
def _reduce_251(val, _values, result)
                      result = self.arg_blk_pass s(:splat, val[1]), val[2]
                    
    result
end
_reduce_253(val, _values, result) click to toggle source

reduce 252 omitted

# File lib/ruby_parser.rb, line 4172
def _reduce_253(val, _values, result)
                      result = lexer.cmdarg.stack.dup
                      lexer.cmdarg.push true
                    
    result
end
_reduce_254(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4179
def _reduce_254(val, _values, result)
                      lexer.cmdarg.stack.replace val[0]
                      result = val[1]
                    
    result
end
_reduce_256(val, _values, result) click to toggle source

reduce 255 omitted

# File lib/ruby_parser.rb, line 4188
def _reduce_256(val, _values, result)
                      lexer.lex_state = :expr_endarg
                    
    result
end
_reduce_257(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4194
def _reduce_257(val, _values, result)
                      warning "don't put space before argument parentheses"
                      result = nil
                    
    result
end
_reduce_258(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4201
def _reduce_258(val, _values, result)
                      lexer.lex_state = :expr_endarg
                    
    result
end
_reduce_259(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4207
def _reduce_259(val, _values, result)
                      warning "don't put space before argument parentheses"
                      result = val[1]
                    
    result
end
_reduce_26(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3088
def _reduce_26(val, _values, result)
                      result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
                    
    result
end
_reduce_260(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4214
def _reduce_260(val, _values, result)
                      result = s(:block_pass, val[1])
                    
    result
end
_reduce_261(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4220
def _reduce_261(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_263(val, _values, result) click to toggle source

reduce 262 omitted

# File lib/ruby_parser.rb, line 4228
def _reduce_263(val, _values, result)
                      result = s(:array, val[0])
                    
    result
end
_reduce_264(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4234
def _reduce_264(val, _values, result)
                      result = self.list_append val[0], val[2]
                    
    result
end
_reduce_265(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4240
def _reduce_265(val, _values, result)
                      result = val[0] << val[2]
                    
    result
end
_reduce_266(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4246
def _reduce_266(val, _values, result)
                      result = self.arg_concat val[0], val[3]
                    
    result
end
_reduce_267(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4252
def _reduce_267(val, _values, result)
                      result = s(:splat, val[1])
                    
    result
end
_reduce_27(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3094
def _reduce_27(val, _values, result)
                      result = s(:op_asgn, val[0], val[4], val[2], val[3])
                    
    result
end
_reduce_276(val, _values, result) click to toggle source

reduce 275 omitted

# File lib/ruby_parser.rb, line 4274
def _reduce_276(val, _values, result)
                      result = new_call nil, val[0].to_sym
                    
    result
end
_reduce_277(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4280
def _reduce_277(val, _values, result)
                      result = self.lexer.lineno
                    
    result
end
_reduce_278(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4286
def _reduce_278(val, _values, result)
                      unless val[2] then
                        result = s(:nil)
                      else
                        result = s(:begin, val[2])
                      end

                      result.line = val[1]
                    
    result
end
_reduce_279(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4298
def _reduce_279(val, _values, result)
                      lexer.lex_state = :expr_endarg
                    
    result
end
_reduce_28(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3100
def _reduce_28(val, _values, result)
                      result = s(:op_asgn, val[0], val[4], val[2], val[3])
                    
    result
end
_reduce_280(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4304
def _reduce_280(val, _values, result)
                      warning "(...) interpreted as grouped expression"
                      result = val[1]
                    
    result
end
_reduce_281(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4311
def _reduce_281(val, _values, result)
                      result = val[1] || s(:nil)
                      result.paren = true
                    
    result
end
_reduce_282(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4318
def _reduce_282(val, _values, result)
                      result = s(:colon2, val[0], val[2].to_sym)
                    
    result
end
_reduce_283(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4324
def _reduce_283(val, _values, result)
                      result = s(:colon3, val[1].to_sym)
                    
    result
end
_reduce_284(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4330
def _reduce_284(val, _values, result)
                      result = new_aref val
                    
    result
end
_reduce_285(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4336
def _reduce_285(val, _values, result)
                      result = val[1] || s(:array)
                    
    result
end
_reduce_286(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4342
def _reduce_286(val, _values, result)
                      result = s(:hash, *val[1].values)
                    
    result
end
_reduce_287(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4348
def _reduce_287(val, _values, result)
                      result = s(:return)
                    
    result
end
_reduce_288(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4354
def _reduce_288(val, _values, result)
                      result = new_yield val[2]
                    
    result
end
_reduce_289(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4360
def _reduce_289(val, _values, result)
                      result = new_yield
                    
    result
end
_reduce_29(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3106
def _reduce_29(val, _values, result)
                      result = s(:op_asgn, val[0], val[4], val[2], val[3])
                    
    result
end
_reduce_290(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4366
def _reduce_290(val, _values, result)
                      result = new_yield
                    
    result
end
_reduce_291(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4372
def _reduce_291(val, _values, result)
                      result = s(:defined, val[3])
                    
    result
end
_reduce_292(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4378
def _reduce_292(val, _values, result)
                      oper, iter = val[0], val[1]
                      call = new_call(nil, oper.to_sym)
                      iter.insert 1, call
                      result = iter
                      call.line = iter.line
                    
    result
end
_reduce_294(val, _values, result) click to toggle source

reduce 293 omitted

# File lib/ruby_parser.rb, line 4390
def _reduce_294(val, _values, result)
                      call, iter = val[0], val[1]
                      iter.insert 1, call
                      result = iter
                    
    result
end
_reduce_295(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4398
def _reduce_295(val, _values, result)
                      result = new_if val[1], val[3], val[4]
                    
    result
end
_reduce_296(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4404
def _reduce_296(val, _values, result)
                      result = new_if val[1], val[4], val[3]
                    
    result
end
_reduce_297(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4410
def _reduce_297(val, _values, result)
                      lexer.cond.push true
                    
    result
end
_reduce_298(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4416
def _reduce_298(val, _values, result)
                      lexer.cond.pop
                    
    result
end
_reduce_299(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4422
def _reduce_299(val, _values, result)
                      result = new_while val[5], val[2], true
                    
    result
end
_reduce_3(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2950
def _reduce_3(val, _values, result)
                      result = new_body val
                    
    result
end
_reduce_30(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3112
def _reduce_30(val, _values, result)
                      self.backref_assign_error val[0]
                    
    result
end
_reduce_300(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4428
def _reduce_300(val, _values, result)
                      lexer.cond.push true
                    
    result
end
_reduce_301(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4434
def _reduce_301(val, _values, result)
                      lexer.cond.pop
                    
    result
end
_reduce_302(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4440
def _reduce_302(val, _values, result)
                      result = new_until val[5], val[2], true
                    
    result
end
_reduce_303(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4446
def _reduce_303(val, _values, result)
                      result = new_case val[1], val[3]
                    
    result
end
_reduce_304(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4452
def _reduce_304(val, _values, result)
                      result = new_case nil, val[2]
                    
    result
end
_reduce_305(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4458
def _reduce_305(val, _values, result)
                      result = new_case nil, val[3]
                    
    result
end
_reduce_306(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4464
def _reduce_306(val, _values, result)
                      lexer.cond.push true
                    
    result
end
_reduce_307(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4470
def _reduce_307(val, _values, result)
                      lexer.cond.pop
                    
    result
end
_reduce_308(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4476
def _reduce_308(val, _values, result)
                      result = new_for val[4], val[1], val[7]
                    
    result
end
_reduce_309(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4482
def _reduce_309(val, _values, result)
                      result = self.lexer.lineno
                    
    result
end
_reduce_31(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3118
def _reduce_31(val, _values, result)
                      result = self.node_assign val[0], s(:svalue, val[2])
                    
    result
end
_reduce_310(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4488
def _reduce_310(val, _values, result)
                      self.comments.push self.lexer.comments
                      if (self.in_def || self.in_single > 0) then
                        yyerror "class definition in method body"
                      end
                      self.env.extend
                    
    result
end
_reduce_311(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4498
def _reduce_311(val, _values, result)
                      result = new_class val
                      self.env.unextend
                    
    result
end
_reduce_312(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4505
def _reduce_312(val, _values, result)
                      result = self.lexer.lineno
                    
    result
end
_reduce_313(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4511
def _reduce_313(val, _values, result)
                      result = self.in_def
                      self.in_def = false
                    
    result
end
_reduce_314(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4518
def _reduce_314(val, _values, result)
                      result = self.in_single
                      self.in_single = 0
                      self.env.extend
                    
    result
end
_reduce_315(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4526
def _reduce_315(val, _values, result)
                      result = new_sclass val
                      self.env.unextend
                    
    result
end
_reduce_316(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4533
def _reduce_316(val, _values, result)
                      result = self.lexer.lineno
                    
    result
end
_reduce_317(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4539
def _reduce_317(val, _values, result)
                      self.comments.push self.lexer.comments
                      yyerror "module definition in method body" if
                        self.in_def or self.in_single > 0

                      self.env.extend
                    
    result
end
_reduce_318(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4549
def _reduce_318(val, _values, result)
                      result = new_module val
                      self.env.unextend
                    
    result
end
_reduce_319(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4556
def _reduce_319(val, _values, result)
                      self.comments.push self.lexer.comments
                      self.in_def = true
                      self.env.extend
                      result = lexer.lineno, lexer.src.beginning_of_line?
                    
    result
end
_reduce_32(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3124
def _reduce_32(val, _values, result)
                      result = new_masgn val[0], val[2], :wrap
                    
    result
end
_reduce_320(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4565
def _reduce_320(val, _values, result)
                      result = new_defn val
                      self.env.unextend
                      self.in_def = false
                    
    result
end
_reduce_321(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4573
def _reduce_321(val, _values, result)
                      self.comments.push self.lexer.comments
                      lexer.lex_state = :expr_fname
                    
    result
end
_reduce_322(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4580
def _reduce_322(val, _values, result)
                      self.in_single += 1
                      self.env.extend
                      lexer.lex_state = :expr_end # force for args
                    
    result
end
_reduce_323(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4588
def _reduce_323(val, _values, result)
                      result = new_defs val

                      self.env.unextend
                      self.in_single -= 1
                    
    result
end
_reduce_324(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4597
def _reduce_324(val, _values, result)
                      result = s(:break)
                    
    result
end
_reduce_325(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4603
def _reduce_325(val, _values, result)
                      result = s(:next)
                    
    result
end
_reduce_326(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4609
def _reduce_326(val, _values, result)
                      result = s(:redo)
                    
    result
end
_reduce_327(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4615
def _reduce_327(val, _values, result)
                      result = s(:retry)
                    
    result
end
_reduce_328(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4621
def _reduce_328(val, _values, result)
                      result = value_expr(val[0])
                    
    result
end
_reduce_33(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3130
def _reduce_33(val, _values, result)
                      result = new_masgn val[0], val[2]
                    
    result
end
_reduce_337(val, _values, result) click to toggle source

reduce 336 omitted

# File lib/ruby_parser.rb, line 4643
def _reduce_337(val, _values, result)
                      result = s(:if, val[1], val[3], val[4])
                    
    result
end
_reduce_339(val, _values, result) click to toggle source

reduce 338 omitted

# File lib/ruby_parser.rb, line 4651
def _reduce_339(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_341(val, _values, result) click to toggle source

reduce 340 omitted

# File lib/ruby_parser.rb, line 4659
def _reduce_341(val, _values, result)
                      val[0].delete_at 1 if val[0][1].nil? # HACK
                    
    result
end
_reduce_343(val, _values, result) click to toggle source

reduce 342 omitted

# File lib/ruby_parser.rb, line 4667
def _reduce_343(val, _values, result)
                      result = 0
                      self.lexer.command_start = true
                    
    result
end
_reduce_344(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4674
def _reduce_344(val, _values, result)
                      result = 0
                      self.lexer.command_start = true
                    
    result
end
_reduce_345(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4681
def _reduce_345(val, _values, result)
                      result = val[1]
                      self.lexer.command_start = true
                    
    result
end
_reduce_346(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4688
def _reduce_346(val, _values, result)
                      self.env.extend :dynamic
                      result = self.lexer.lineno
                    
    result
end
_reduce_347(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4695
def _reduce_347(val, _values, result)
                      result = self.env.dynamic.keys
                    
    result
end
_reduce_348(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4701
def _reduce_348(val, _values, result)
                      vars   = val[2]
                      body   = val[4]
                      result = new_iter nil, vars, body
                      result.line = val[1]

                      self.env.unextend
                    
    result
end
_reduce_349(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4712
def _reduce_349(val, _values, result)
                      raise SyntaxError, "Both block arg and actual block given." if
                        val[0] && val[0][0] == :blockpass

                      result = val[1]
                      result.insert 1, val[0]
                    
    result
end
_reduce_350(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4722
def _reduce_350(val, _values, result)
                      result = new_call val[0], val[2], val[3]
                    
    result
end
_reduce_351(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4728
def _reduce_351(val, _values, result)
                      result = new_call val[0], val[2], val[3]
                    
    result
end
_reduce_352(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4734
def _reduce_352(val, _values, result)
                      result = self.lexer.lineno
                    
    result
end
_reduce_353(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4740
def _reduce_353(val, _values, result)
                      result = new_call nil, val[0].to_sym, val[2]
                    
    result
end
_reduce_354(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4746
def _reduce_354(val, _values, result)
                      result = new_call val[0], val[2].to_sym, val[3]
                    
    result
end
_reduce_355(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4752
def _reduce_355(val, _values, result)
                      result = new_call val[0], val[2].to_sym, val[3]
                    
    result
end
_reduce_356(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4758
def _reduce_356(val, _values, result)
                      result = new_call val[0], val[2].to_sym
                    
    result
end
_reduce_357(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4764
def _reduce_357(val, _values, result)
                      result = new_super val[1]
                    
    result
end
_reduce_358(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4770
def _reduce_358(val, _values, result)
                      result = s(:zsuper)
                    
    result
end
_reduce_359(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4776
def _reduce_359(val, _values, result)
                      self.env.extend :dynamic
                      result = self.lexer.lineno
                    
    result
end
_reduce_36(val, _values, result) click to toggle source

reduce 35 omitted

# File lib/ruby_parser.rb, line 3140
def _reduce_36(val, _values, result)
                      result = logop(:and, val[0], val[2])
                    
    result
end
_reduce_360(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4783
def _reduce_360(val, _values, result)
                      result = self.env.dynamic.keys
                    
    result
end
_reduce_361(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4789
def _reduce_361(val, _values, result)
                      # REFACTOR
                      args   = val[2]
                      body   = val[4]
                      result = new_iter nil, args, body
                      self.env.unextend
                      result.line = val[1]
                    
    result
end
_reduce_362(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4800
def _reduce_362(val, _values, result)
                      self.env.extend :dynamic
                      result = self.lexer.lineno
                    
    result
end
_reduce_363(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4807
def _reduce_363(val, _values, result)
                      result = self.env.dynamic.keys
                    
    result
end
_reduce_364(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4813
def _reduce_364(val, _values, result)
                      args = val[2]
                      body = val[4]
                      result = new_iter nil, args, body
                      self.env.unextend
                      result.line = val[1]
                    
    result
end
_reduce_365(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4823
def _reduce_365(val, _values, result)
                      result = self.lexer.lineno
                    
    result
end
_reduce_366(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4829
def _reduce_366(val, _values, result)
                      result = s(:when, val[2], val[4])
                      result.line = val[1]
                      result << val[5] if val[5]
                    
    result
end
_reduce_368(val, _values, result) click to toggle source

reduce 367 omitted

# File lib/ruby_parser.rb, line 4839
def _reduce_368(val, _values, result)
                      result = self.list_append val[0], s(:when, val[3], nil)
                    
    result
end
_reduce_369(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4845
def _reduce_369(val, _values, result)
                      result = s(:array, s(:when, val[1], nil))
                    
    result
end
_reduce_37(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3146
def _reduce_37(val, _values, result)
                      result = logop(:or, val[0], val[2])
                    
    result
end
_reduce_372(val, _values, result) click to toggle source

reduce 371 omitted

# File lib/ruby_parser.rb, line 4855
def _reduce_372(val, _values, result)
                      klasses, var, body, rest = val[1], val[2], val[4], val[5]

                      klasses ||= s(:array)
                      klasses << node_assign(var, s(:gvar, :"$!")) if var

                      result = s(:resbody, klasses, body)
                      result << rest if rest # UGH, rewritten above
                    
    result
end
_reduce_373(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4867
def _reduce_373(val, _values, result)
                      result = nil
                    
    result
end
_reduce_374(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4873
def _reduce_374(val, _values, result)
                      result = s(:array, val[0])
                    
    result
end
_reduce_377(val, _values, result) click to toggle source

reduce 376 omitted

# File lib/ruby_parser.rb, line 4883
def _reduce_377(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_379(val, _values, result) click to toggle source

reduce 378 omitted

# File lib/ruby_parser.rb, line 4891
def _reduce_379(val, _values, result)
                      if (val[1] != nil) then
                        result = val[1]
                      else
                        result = s(:nil)
                      end
                    
    result
end
_reduce_38(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3152
def _reduce_38(val, _values, result)
                      result = s(:not, val[1])
                    
    result
end
_reduce_381(val, _values, result) click to toggle source

reduce 380 omitted

# File lib/ruby_parser.rb, line 4903
def _reduce_381(val, _values, result)
 result = s(:lit, val[0]) 
    result
end
_reduce_382(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4908
def _reduce_382(val, _values, result)
 result = s(:lit, val[0]) 
    result
end
_reduce_384(val, _values, result) click to toggle source

reduce 383 omitted

# File lib/ruby_parser.rb, line 4915
def _reduce_384(val, _values, result)
                      val[0] = s(:dstr, val[0].value) if val[0][0] == :evstr
                      result = val[0]
                    
    result
end
_reduce_386(val, _values, result) click to toggle source

reduce 385 omitted

# File lib/ruby_parser.rb, line 4924
def _reduce_386(val, _values, result)
                      result = self.literal_concat val[0], val[1]
                    
    result
end
_reduce_387(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4930
def _reduce_387(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_388(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4936
def _reduce_388(val, _values, result)
                      result = s(:str, val[0])
                    
    result
end
_reduce_389(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4942
def _reduce_389(val, _values, result)
                      result = new_xstring val[1]
                    
    result
end
_reduce_39(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3158
def _reduce_39(val, _values, result)
                      result = s(:not, val[1])
                    
    result
end
_reduce_390(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4948
def _reduce_390(val, _values, result)
                      result = new_regexp val
                    
    result
end
_reduce_391(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4954
def _reduce_391(val, _values, result)
                      result = s(:array)
                    
    result
end
_reduce_392(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4960
def _reduce_392(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_393(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4966
def _reduce_393(val, _values, result)
                      result = s(:array)
                    
    result
end
_reduce_394(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4972
def _reduce_394(val, _values, result)
                      word = val[1][0] == :evstr ? s(:dstr, "", val[1]) : val[1]
                      result = val[0] << word
                    
    result
end
_reduce_396(val, _values, result) click to toggle source

reduce 395 omitted

# File lib/ruby_parser.rb, line 4981
def _reduce_396(val, _values, result)
                      result = self.literal_concat val[0], val[1]
                    
    result
end
_reduce_397(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4987
def _reduce_397(val, _values, result)
                      result = s(:array)
                    
    result
end
_reduce_398(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4993
def _reduce_398(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_399(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 4999
def _reduce_399(val, _values, result)
                      result = s(:array)
                    
    result
end
_reduce_4(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2956
def _reduce_4(val, _values, result)
                      result = new_compstmt val
                    
    result
end
_reduce_400(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5005
def _reduce_400(val, _values, result)
                      result = val[0] << s(:str, val[1])
                    
    result
end
_reduce_401(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5011
def _reduce_401(val, _values, result)
                      result = s(:str, "")
                    
    result
end
_reduce_402(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5017
def _reduce_402(val, _values, result)
                      result = literal_concat(val[0], val[1])
                    
    result
end
_reduce_403(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5023
def _reduce_403(val, _values, result)
                      result = nil
                    
    result
end
_reduce_404(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5029
def _reduce_404(val, _values, result)
                      result = literal_concat(val[0], val[1])
                    
    result
end
_reduce_405(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5035
def _reduce_405(val, _values, result)
                      result = s(:str, val[0])
                    
    result
end
_reduce_406(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5041
def _reduce_406(val, _values, result)
                      result = lexer.lex_strterm
                      lexer.lex_strterm = nil
                      lexer.lex_state = :expr_beg
                    
    result
end
_reduce_407(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5049
def _reduce_407(val, _values, result)
                      lexer.lex_strterm = val[1]
                      result = s(:evstr, val[2])
                    
    result
end
_reduce_408(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5056
def _reduce_408(val, _values, result)
                      result = lexer.lex_strterm
                      lexer.lex_strterm = nil
                      lexer.lex_state = :expr_beg
                      lexer.cond.push false
                      lexer.cmdarg.push false
                    
    result
end
_reduce_409(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5066
def _reduce_409(val, _values, result)
                      lexer.lex_strterm = val[1]
                      lexer.cond.lexpop
                      lexer.cmdarg.lexpop

                      case val[2]
                      when Sexp then
                        case val[2][0]
                        when :str, :dstr, :evstr then
                          result = val[2]
                        else
                          result = s(:evstr, val[2])
                        end
                      when nil then
                        result = s(:evstr)
                      else
                        raise "unknown rescue body: #{val[2].inspect}"
                      end
                    
    result
end
_reduce_41(val, _values, result) click to toggle source

reduce 40 omitted

# File lib/ruby_parser.rb, line 3166
def _reduce_41(val, _values, result)
                      result = value_expr(val[0])
                    
    result
end
_reduce_410(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5088
def _reduce_410(val, _values, result)
 result = s(:gvar, val[0].to_sym) 
    result
end
_reduce_411(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5093
def _reduce_411(val, _values, result)
 result = s(:ivar, val[0].to_sym) 
    result
end
_reduce_412(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5098
def _reduce_412(val, _values, result)
 result = s(:cvar, val[0].to_sym) 
    result
end
_reduce_414(val, _values, result) click to toggle source

reduce 413 omitted

# File lib/ruby_parser.rb, line 5105
def _reduce_414(val, _values, result)
                      lexer.lex_state = :expr_end
                      result = val[1].to_sym
                    
    result
end
_reduce_415(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5112
def _reduce_415(val, _values, result)
                      result = val[0].to_sym
                    
    result
end
_reduce_420(val, _values, result) click to toggle source

reduce 419 omitted

# File lib/ruby_parser.rb, line 5126
def _reduce_420(val, _values, result)
                      lexer.lex_state = :expr_end
                      result = val[1]

                      yyerror "empty symbol literal" if
                        result.nil? or result.empty?

                      case result[0]
                      when :dstr then
                        result[0] = :dsym
                      when :str then
                        result = s(:lit, result.last.intern)
                      else
                        result = s(:dsym, "", result)
                      end
                    
    result
end
_reduce_423(val, _values, result) click to toggle source

reduce 422 omitted

# File lib/ruby_parser.rb, line 5149
def _reduce_423(val, _values, result)
                      result = -val[1] # TODO: pt_testcase
                    
    result
end
_reduce_424(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5155
def _reduce_424(val, _values, result)
                      result = -val[1] # TODO: pt_testcase
                    
    result
end
_reduce_430(val, _values, result) click to toggle source

reduce 429 omitted

# File lib/ruby_parser.rb, line 5171
def _reduce_430(val, _values, result)
 result = s(:nil)   
    result
end
_reduce_431(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5176
def _reduce_431(val, _values, result)
 result = s(:self)  
    result
end
_reduce_432(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5181
def _reduce_432(val, _values, result)
 result = s(:true)  
    result
end
_reduce_433(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5186
def _reduce_433(val, _values, result)
 result = s(:false) 
    result
end
_reduce_434(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5191
def _reduce_434(val, _values, result)
 result = s(:str, self.file) 
    result
end
_reduce_435(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5196
def _reduce_435(val, _values, result)
 result = s(:lit, lexer.src.current_line) 
    result
end
_reduce_436(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5201
def _reduce_436(val, _values, result)
                      var = val[0]
                      result = Sexp === var ? var : self.gettable(var)
                    
    result
end
_reduce_437(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5208
def _reduce_437(val, _values, result)
                      result = self.assignable val[0]
                    
    result
end
_reduce_438(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5214
def _reduce_438(val, _values, result)
 result = s(:nth_ref,  val[0]) 
    result
end
_reduce_439(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5219
def _reduce_439(val, _values, result)
 result = s(:back_ref, val[0]) 
    result
end
_reduce_44(val, _values, result) click to toggle source

reduce 43 omitted

# File lib/ruby_parser.rb, line 3176
def _reduce_44(val, _values, result)
                      line = val[0].last
                      result = s(:return, ret_args(val[1])).line(line)
                    
    result
end
_reduce_440(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5224
def _reduce_440(val, _values, result)
                      result = nil
                    
    result
end
_reduce_441(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5230
def _reduce_441(val, _values, result)
                      lexer.lex_state = :expr_beg
                    
    result
end
_reduce_442(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5236
def _reduce_442(val, _values, result)
                      result = val[2]
                    
    result
end
_reduce_443(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5242
def _reduce_443(val, _values, result)
                      yyerrok
                      result = nil
                    
    result
end
_reduce_444(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5249
def _reduce_444(val, _values, result)
                      result = val[1]
                      lexer.lex_state = :expr_beg
                      self.lexer.command_start = true
                    
    result
end
_reduce_445(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5257
def _reduce_445(val, _values, result)
                      result = val[0]
                    
    result
end
_reduce_446(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5263
def _reduce_446(val, _values, result)
                      result = args val[0], val[2], val[4], val[5]
                    
    result
end
_reduce_447(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5269
def _reduce_447(val, _values, result)
                      result = args val[0], val[2],    nil, val[3]
                    
    result
end
_reduce_448(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5275
def _reduce_448(val, _values, result)
                      result = args val[0],    nil, val[2], val[3]
                    
    result
end
_reduce_449(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5281
def _reduce_449(val, _values, result)
                      result = args val[0],    nil,    nil, val[1]
                    
    result
end
_reduce_45(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3183
def _reduce_45(val, _values, result)
                      line = val[0].last
                      result = s(:break, ret_args(val[1])).line(line)
                    
    result
end
_reduce_450(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5287
def _reduce_450(val, _values, result)
                      result = args    nil, val[0], val[2], val[3]
                    
    result
end
_reduce_451(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5293
def _reduce_451(val, _values, result)
                      result = args    nil, val[0],    nil, val[1]
                    
    result
end
_reduce_452(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5299
def _reduce_452(val, _values, result)
                      result = args    nil,    nil, val[0], val[1]
                    
    result
end
_reduce_453(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5305
def _reduce_453(val, _values, result)
                      result = args    nil,    nil,    nil, val[0]
                    
    result
end
_reduce_454(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5311
def _reduce_454(val, _values, result)
                      result = args    nil,    nil,    nil,    nil
                    
    result
end
_reduce_455(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5317
def _reduce_455(val, _values, result)
                      yyerror "formal argument cannot be a constant: #{val[0]}"
                    
    result
end
_reduce_456(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5323
def _reduce_456(val, _values, result)
                      yyerror "formal argument cannot be an instance variable"
                    
    result
end
_reduce_457(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5329
def _reduce_457(val, _values, result)
                      yyerror "formal argument cannot be a class variable"
                    
    result
end
_reduce_458(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5335
def _reduce_458(val, _values, result)
                      identifier = val[0].to_sym
                      self.env[identifier] = :lvar

                      result = val[0]
                    
    result
end
_reduce_459(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5344
def _reduce_459(val, _values, result)
                      result = s(:args)
                      result << val[0].to_sym
                    
    result
end
_reduce_46(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3190
def _reduce_46(val, _values, result)
                      line = val[0].last
                      result = s(:next, ret_args(val[1])).line(line)
                    
    result
end
_reduce_460(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5351
def _reduce_460(val, _values, result)
                      val[0] << val[2].to_sym
                      result = val[0]
                    
    result
end
_reduce_461(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5358
def _reduce_461(val, _values, result)
                      result = self.assignable val[0], val[2]
                      # TODO: detect duplicate names
                    
    result
end
_reduce_462(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5365
def _reduce_462(val, _values, result)
                      result = s(:block, val[0])
                    
    result
end
_reduce_463(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5371
def _reduce_463(val, _values, result)
                      result = self.block_append val[0], val[2]
                    
    result
end
_reduce_466(val, _values, result) click to toggle source

reduce 465 omitted

# File lib/ruby_parser.rb, line 5381
def _reduce_466(val, _values, result)
                      # TODO: differs from parse.y - needs tests
                      name = val[1].to_sym
                      self.assignable name
                      result = :"*#{name}"
                    
    result
end
_reduce_467(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5390
def _reduce_467(val, _values, result)
                      name = :"*"
                      self.env[name] = :lvar
                      result = name
                    
    result
end
_reduce_470(val, _values, result) click to toggle source

reduce 469 omitted

# File lib/ruby_parser.rb, line 5402
def _reduce_470(val, _values, result)
                      identifier = val[1].to_sym

                      self.env[identifier] = :lvar
                      result = s(:block_arg, identifier.to_sym)
                    
    result
end
_reduce_471(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5411
def _reduce_471(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_472(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5417
def _reduce_472(val, _values, result)
                      result = nil
                    
    result
end
_reduce_474(val, _values, result) click to toggle source

reduce 473 omitted

# File lib/ruby_parser.rb, line 5425
def _reduce_474(val, _values, result)
                      lexer.lex_state = :expr_beg
                    
    result
end
_reduce_475(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5431
def _reduce_475(val, _values, result)
                      result = val[2]
                      yyerror "Can't define single method for literals." if
                        result[0] == :lit
                    
    result
end
_reduce_476(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5439
def _reduce_476(val, _values, result)
                      result = s(:array)
                    
    result
end
_reduce_477(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5445
def _reduce_477(val, _values, result)
                      result = val[0]
                    
    result
end
_reduce_478(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5451
def _reduce_478(val, _values, result)
                      size = val[0].size
                      if (size % 2 != 1) then # != 1 because of leading :array
                        yyerror "Odd number (#{size}) list for Hash. #{val[0].inspect}"
                      end
                      result = val[0]
                    
    result
end
_reduce_48(val, _values, result) click to toggle source

reduce 47 omitted

# File lib/ruby_parser.rb, line 3199
def _reduce_48(val, _values, result)
                      result = new_call val[0], val[2], val[3]
                    
    result
end
_reduce_480(val, _values, result) click to toggle source

reduce 479 omitted

# File lib/ruby_parser.rb, line 5463
def _reduce_480(val, _values, result)
                      list = val[0].dup
                      more = val[2][1..-1]
                      list.push(*more) unless more.empty?
                      result = list
                    
    result
end
_reduce_481(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5472
def _reduce_481(val, _values, result)
                      result = s(:array, val[0], val[2])
                    
    result
end
_reduce_49(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3205
def _reduce_49(val, _values, result)
                      result = new_call val[0], val[2], val[3]
                    
    result
end
_reduce_50(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3211
def _reduce_50(val, _values, result)
                      self.env.extend(:dynamic)
                      result = self.lexer.lineno
                    
    result
end
_reduce_501(val, _values, result) click to toggle source

reduce 500 omitted

# File lib/ruby_parser.rb, line 5516
def _reduce_501(val, _values, result)
 yyerrok 
    result
end
_reduce_504(val, _values, result) click to toggle source

reduce 503 omitted

# File lib/ruby_parser.rb, line 5525
def _reduce_504(val, _values, result)
 yyerrok 
    result
end
_reduce_505(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5530
def _reduce_505(val, _values, result)
 result = nil 
    result
end
_reduce_506(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5535
def _reduce_506(val, _values, result)
 result = nil 
    result
end
_reduce_51(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3218
def _reduce_51(val, _values, result)
                      result = self.env.dynamic.keys
                    
    result
end
_reduce_52(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3224
def _reduce_52(val, _values, result)
                      result = new_iter nil, val[2], val[4]
                      self.env.unextend
                    
    result
end
_reduce_53(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3231
def _reduce_53(val, _values, result)
                      result = new_call nil, val[0].to_sym, val[1]
                    
    result
end
_reduce_54(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3237
def _reduce_54(val, _values, result)
                      result = new_call nil, val[0].to_sym, val[1]
                      if val[2] then
                        if result[0] == :block_pass then
                          raise "both block arg and actual block given"
                        end
                        result, operation = val[2], result
                        result.insert 1, operation
                      end
                    
    result
end
_reduce_55(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3250
def _reduce_55(val, _values, result)
                      result = new_call val[0], val[2].to_sym, val[3]
                    
    result
end
_reduce_56(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3256
def _reduce_56(val, _values, result)
                      result = new_call val[0], val[2].to_sym, val[3]
                    
    result
end
_reduce_57(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3262
def _reduce_57(val, _values, result)
                      result = new_call val[0], val[2].to_sym, val[3]
                    
    result
end
_reduce_58(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3268
def _reduce_58(val, _values, result)
                      result = new_call val[0], val[2].to_sym, val[3]
                      if val[4] then
                        if result[0] == :block_pass then # REFACTOR
                          raise "both block arg and actual block given"
                        end
                        val[2] << result
                        result = val[2]
                      end
                    
    result
end
_reduce_59(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3281
def _reduce_59(val, _values, result)
                      result = new_super val[1]
                    
    result
end
_reduce_60(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3287
def _reduce_60(val, _values, result)
                      result = new_yield val[1]
                    
    result
end
_reduce_62(val, _values, result) click to toggle source

reduce 61 omitted

# File lib/ruby_parser.rb, line 3295
def _reduce_62(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_64(val, _values, result) click to toggle source

reduce 63 omitted

# File lib/ruby_parser.rb, line 3303
def _reduce_64(val, _values, result)
                      result = s(:masgn, s(:array, val[1]))
                    
    result
end
_reduce_65(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3309
def _reduce_65(val, _values, result)
                      result = s(:masgn, val[0])
                    
    result
end
_reduce_66(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3315
def _reduce_66(val, _values, result)
                      result = s(:masgn, val[0] << val[1].compact)
                    
    result
end
_reduce_67(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3321
def _reduce_67(val, _values, result)
                      result = s(:masgn, val[0] << s(:splat, val[2]))
                    
    result
end
_reduce_68(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3327
def _reduce_68(val, _values, result)
                      result = s(:masgn, val[0] << s(:splat))
                    
    result
end
_reduce_69(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3333
def _reduce_69(val, _values, result)
                      result = s(:masgn, s(:array, s(:splat, val[1])))
                    
    result
end
_reduce_7(val, _values, result) click to toggle source

reduce 6 omitted

# File lib/ruby_parser.rb, line 2966
def _reduce_7(val, _values, result)
                      result = self.block_append val[0], val[2]
                    
    result
end
_reduce_70(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3339
def _reduce_70(val, _values, result)
                      result = s(:masgn, s(:array, s(:splat)))
                    
    result
end
_reduce_72(val, _values, result) click to toggle source

reduce 71 omitted

# File lib/ruby_parser.rb, line 3347
def _reduce_72(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_73(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3353
def _reduce_73(val, _values, result)
                      result = s(:array, val[0])
                    
    result
end
_reduce_74(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3359
def _reduce_74(val, _values, result)
                      result = val[0] << val[1].compact
                    
    result
end
_reduce_75(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3365
def _reduce_75(val, _values, result)
                      result = self.assignable val[0]
                    
    result
end
_reduce_76(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3371
def _reduce_76(val, _values, result)
                      result = self.aryset val[0], val[2]
                    
    result
end
_reduce_77(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3377
def _reduce_77(val, _values, result)
                      result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist))
                    
    result
end
_reduce_78(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3383
def _reduce_78(val, _values, result)
                      result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist))
                    
    result
end
_reduce_79(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3389
def _reduce_79(val, _values, result)
                      result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist))
                    
    result
end
_reduce_8(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2972
def _reduce_8(val, _values, result)
                      result = val[1]
                    
    result
end
_reduce_80(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3395
def _reduce_80(val, _values, result)
                      if (self.in_def || self.in_single > 0) then
                        yyerror "dynamic constant assignment"
                      end

                      result = s(:const, s(:colon2, val[0], val[2].to_sym), nil)
                    
    result
end
_reduce_81(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3405
def _reduce_81(val, _values, result)
                      if (self.in_def || self.in_single > 0) then
                        yyerror "dynamic constant assignment"
                      end

                      result = s(:const, nil, s(:colon3, val[1].to_sym))
                    
    result
end
_reduce_82(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3415
def _reduce_82(val, _values, result)
                      self.backref_assign_error val[0]
                    
    result
end
_reduce_83(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3421
def _reduce_83(val, _values, result)
                      result = self.assignable val[0]
                    
    result
end
_reduce_84(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3427
def _reduce_84(val, _values, result)
                      result = self.aryset val[0], val[2]
                    
    result
end
_reduce_85(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3433
def _reduce_85(val, _values, result)
                      result = s(:attrasgn, val[0], :"#{val[2]}=")
                    
    result
end
_reduce_86(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3439
def _reduce_86(val, _values, result)
                      result = s(:attrasgn, val[0], :"#{val[2]}=")
                    
    result
end
_reduce_87(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3445
def _reduce_87(val, _values, result)
                      result = s(:attrasgn, val[0], :"#{val[2]}=")
                    
    result
end
_reduce_88(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3451
def _reduce_88(val, _values, result)
                      if (self.in_def || self.in_single > 0) then
                        yyerror "dynamic constant assignment"
                      end

                      result = s(:const, s(:colon2, val[0], val[2].to_sym))
                    
    result
end
_reduce_89(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3461
def _reduce_89(val, _values, result)
                      if (self.in_def || self.in_single > 0) then
                        yyerror "dynamic constant assignment"
                      end

                      result = s(:const, s(:colon3, val[1].to_sym))
                    
    result
end
_reduce_9(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 2978
def _reduce_9(val, _values, result)
                      lexer.lex_state = :expr_fname
                      result = self.lexer.lineno
                    
    result
end
_reduce_90(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3471
def _reduce_90(val, _values, result)
                      self.backref_assign_error val[0]
                    
    result
end
_reduce_91(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3477
def _reduce_91(val, _values, result)
                      yyerror "class/module name must be CONSTANT"
                    
    result
end
_reduce_93(val, _values, result) click to toggle source

reduce 92 omitted

# File lib/ruby_parser.rb, line 3485
def _reduce_93(val, _values, result)
                      result = s(:colon3, val[1].to_sym)
                    
    result
end
_reduce_94(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3491
def _reduce_94(val, _values, result)
                      result = val[0].to_sym
                    
    result
end
_reduce_95(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 3497
def _reduce_95(val, _values, result)
                      result = s(:colon2, val[0], val[2].to_sym)
                    
    result
end
_reduce_99(val, _values, result) click to toggle source

reduce 98 omitted

# File lib/ruby_parser.rb, line 3509
def _reduce_99(val, _values, result)
                      lexer.lex_state = :expr_end
                      result = val[0]
                    
    result
end
_reduce_none(val, _values, result) click to toggle source
# File lib/ruby_parser.rb, line 5540
def _reduce_none(val, _values, result)
  val[0]
end
arg_add(node1, node2) click to toggle source
# File lib/ruby_parser_extras.rb, line 131
def arg_add(node1, node2) # TODO: nuke
  return s(:arglist, node2) unless node1

  node1[0] = :arglist if node1[0] == :array
  return node1 << node2 if node1[0] == :arglist

  return s(:arglist, node1, node2)
end
arg_blk_pass(node1, node2) click to toggle source
# File lib/ruby_parser_extras.rb, line 140
def arg_blk_pass node1, node2 # TODO: nuke
  node1 = s(:arglist, node1) unless [:arglist, :array].include? node1.first
  node1 << node2 if node2
  node1
end
arg_concat(node1, node2) click to toggle source
# File lib/ruby_parser_extras.rb, line 146
def arg_concat node1, node2 # TODO: nuke
  raise "huh" unless node2
  node1 << s(:splat, node2).compact
  node1
end
args(arg, optarg, rest_arg, block_arg) click to toggle source
# File lib/ruby_parser_extras.rb, line 152
def args arg, optarg, rest_arg, block_arg
  arg ||= s(:args)

  result = arg
  if optarg then
    optarg[1..-1].each do |lasgn| # FIX clean sexp iter
      raise "wtf? #{lasgn.inspect}" unless lasgn[0] == :lasgn
      result << lasgn[1]
    end
  end

  result << rest_arg  if rest_arg
  result << :"&#{block_arg.last}" if block_arg
  result << optarg    if optarg # TODO? huh - processed above as well

  result
end
aryset(receiver, index) click to toggle source
# File lib/ruby_parser_extras.rb, line 170
def aryset receiver, index
  index[0] = :arglist if index[0] == :array
  s(:attrasgn, receiver, :"[]=", index)
end
assignable(lhs, value = nil) click to toggle source
# File lib/ruby_parser_extras.rb, line 175
def assignable(lhs, value = nil)
  id = lhs.to_sym
  id = id.to_sym if Sexp === id

  raise SyntaxError, "Can't change the value of #{id}" if
    id.to_s =~ /^(?:self|nil|true|false|__LINE__|__FILE__)$/

  result = case id.to_s
           when /^@@/ then
             asgn = in_def || in_single > 0
             s((asgn ? :cvasgn : :cvdecl), id)
           when /^@/ then
             s(:iasgn, id)
           when /^\$/ then
             s(:gasgn, id)
           when /^[A-Z]/ then
             s(:cdecl, id)
           else
             case self.env[id]
             when :lvar then
               s(:lasgn, id)
             when :dvar, nil then
               if self.env.current[id] == :dvar then
                 s(:lasgn, id)
               elsif self.env[id] == :dvar then
                 self.env.use(id)
                 s(:lasgn, id)
               elsif ! self.env.dynamic? then
                 s(:lasgn, id)
               else
                 s(:lasgn, id)
               end
             else
               raise "wtf? unknown type: #{self.env[id]}"
             end
           end

  self.env[id] ||= :lvar

  result << value if value

  return result
end
block_append(head, tail) click to toggle source
# File lib/ruby_parser_extras.rb, line 219
def block_append(head, tail)
  return head if tail.nil?
  return tail if head.nil?

  case head[0]
  when :lit, :str then
    return tail
  end

  line = [head.line, tail.line].compact.min

  head = remove_begin(head)
  head = s(:block, head) unless head.node_type == :block

  head.line = line
  head << tail
end
cond(node) click to toggle source
# File lib/ruby_parser_extras.rb, line 237
def cond node
  return nil if node.nil?
  node = value_expr node

  case node.first
  when :lit then
    if Regexp === node.last then
      return s(:match, node)
    else
      return node
    end
  when :and then
    return s(:and, cond(node[1]), cond(node[2]))
  when :or then
    return s(:or,  cond(node[1]), cond(node[2]))
  when :dot2 then
    label = "flip#{node.hash}"
    env[label] = :lvar
    return s(:flip2, node[1], node[2])
  when :dot3 then
    label = "flip#{node.hash}"
    env[label] = :lvar
    return s(:flip3, node[1], node[2])
  else
    return node
  end
end
do_parse() click to toggle source

for pure ruby systems only

# File lib/ruby_parser_extras.rb, line 268
def do_parse
  _racc_do_parse_rb(_racc_setup, false)
end
get_match_node(lhs, rhs) click to toggle source
# File lib/ruby_parser_extras.rb, line 272
def get_match_node lhs, rhs # TODO: rename to new_match
  if lhs then
    case lhs[0]
    when :dregx, :dregx_once then
      return s(:match2, lhs, rhs).line(lhs.line)
    when :lit then
      return s(:match2, lhs, rhs).line(lhs.line) if Regexp === lhs.last
    end
  end

  if rhs then
    case rhs[0]
    when :dregx, :dregx_once then
      return s(:match3, rhs, lhs).line(lhs.line)
    when :lit then
      return s(:match3, rhs, lhs).line(lhs.line) if Regexp === rhs.last
    end
  end

  return s(:call, lhs, :"=~", s(:arglist, rhs)).line(lhs.line)
end
gettable(id) click to toggle source
# File lib/ruby_parser_extras.rb, line 294
def gettable(id)
  id = id.to_sym if String === id

  result = case id.to_s
           when /^@@/ then
             s(:cvar, id)
           when /^@/ then
             s(:ivar, id)
           when /^\$/ then
             s(:gvar, id)
           when /^[A-Z]/ then
             s(:const, id)
           else
             type = env[id]
             if type then
               s(type, id)
             elsif env.dynamic? and :dvar == env[id] then
               s(:lvar, id)
             else
               s(:call, nil, id, s(:arglist))
             end
           end

  raise "identifier #{id.inspect} is not valid" unless result

  result
end
list_append(list, item) click to toggle source
# File lib/ruby_parser_extras.rb, line 345
def list_append list, item # TODO: nuke me *sigh*
  return s(:array, item) unless list
  list = s(:array, list) unless Sexp === list && list.first == :array
  list << item
end
list_prepend(item, list) click to toggle source
# File lib/ruby_parser_extras.rb, line 351
def list_prepend item, list # TODO: nuke me *sigh*
  list = s(:array, list) unless Sexp === list && list[0] == :array
  list.insert 1, item
  list
end
literal_concat(head, tail) click to toggle source
# File lib/ruby_parser_extras.rb, line 357
def literal_concat head, tail
  return tail unless head
  return head unless tail

  htype, ttype = head[0], tail[0]

  head = s(:dstr, '', head) if htype == :evstr

  case ttype
  when :str then
    if htype == :str
      head[-1] << tail[-1]
    elsif htype == :dstr and head.size == 2 then
      head[-1] << tail[-1]
    else
      head << tail
    end
  when :dstr then
    if htype == :str then
      tail[1] = head[-1] + tail[1]
      head = tail
    else
      tail[0] = :array
      tail[1] = s(:str, tail[1])
      tail.delete_at 1 if tail[1] == s(:str, '')

      head.push(*tail[1..-1])
    end
  when :evstr then
    head[0] = :dstr if htype == :str
    if head.size == 2 and tail.size > 1 and tail[1][0] == :str then
      head[-1] << tail[1][-1]
      head[0] = :str if head.size == 2 # HACK ?
    else
      head.push(tail)
    end
  else
    x = [head, tail]
    raise "unknown type: #{x.inspect}"
  end

  return head
end
logop(type, left, right) click to toggle source
# File lib/ruby_parser_extras.rb, line 401
  def logop(type, left, right) # TODO: rename logical_op
    left = value_expr left

    if left and left[0] == type and not left.paren then
      node, second = left, nil

      while (second = node[2]) && second[0] == type and not second.paren do
        node = second
      end

      node[2] = s(type, second, right)

      return left
    end

    return s(type, left, right)
  end

  def new_aref val
    val[2] ||= s(:arglist)
    val[2][0] = :arglist if val[2][0] == :array # REFACTOR
    if val[0].node_type == :self then
      result = new_call nil, :"[]", val[2]
    else
      result = new_call val[0], :"[]", val[2]
    end
    result
  end

  def new_body val
    result = val[0]

    if val[1] then
      result = s(:rescue)
      result << val[0] if val[0]

      resbody = val[1]

      while resbody do
        result << resbody
        resbody = resbody.resbody(true)
      end

      result << val[2] if val[2]

      result.line = (val[0] || val[1]).line
    elsif not val[2].nil? then
      warning("else without rescue is useless")
      result = block_append(result, val[2])
    end

    result = s(:ensure, result, val[3]).compact if val[3]
    return result
  end

  def new_call recv, meth, args = nil
    result = s(:call, recv, meth)
    result.line = recv.line if recv

    args ||= s(:arglist)
    args[0] = :arglist if args.first == :array
    args = s(:arglist, args) unless args.first == :arglist
    result << args
    result
  end

  def new_case expr, body
    result = s(:case, expr)
    line = (expr || body).line

    while body and body.node_type == :when
      result << body
      body = body.delete_at 3
    end

    # else
    body = nil if body == s(:block)
    result << body

    result.line = line
    result
  end

  def new_class val
    line, path, superclass, body = val[1], val[2], val[3], val[5]
    scope = s(:scope, body).compact
    result = s(:class, path, superclass, scope)
    result.line = line
    result.comments = self.comments.pop
    result
  end

  def new_compstmt val
    result = void_stmts(val[0])
    result = remove_begin(result) if result
    result
  end

  def new_defn val
    (_, line), name, args, body = val[0], val[1], val[3], val[4]
    body ||= s(:nil)

    body ||= s(:block)
    body = s(:block, body) unless body.first == :block

    result = s(:defn, name.to_sym, args, s(:scope, body))
    result.line = line
    result.comments = self.comments.pop
    result
  end

  def new_defs val
    recv, name, args, body = val[1], val[4], val[6], val[7]

    body ||= s(:block)
    body = s(:block, body) unless body.first == :block

    result = s(:defs, recv, name.to_sym, args, s(:scope, body))
    result.line = recv.line
    result.comments = self.comments.pop
    result
  end

  def new_for expr, var, body
    result = s(:for, expr, var).line(var.line)
    result << body if body
    result
  end

  def new_if c, t, f
    l = [c.line, t && t.line, f && f.line].compact.min
    c = cond c
    c, t, f = c.last, f, t if c[0] == :not and canonicalize_conditions
    s(:if, c, t, f).line(l)
  end

  def new_iter call, args, body
    result = s(:iter)
    result << call if call
    result << args
    result << body if body
    result
  end

  def new_masgn lhs, rhs, wrap = false
    rhs = value_expr(rhs)
    rhs = lhs[1] ? s(:to_ary, rhs) : s(:array, rhs) if wrap

    lhs.delete_at 1 if lhs[1].nil?
    lhs << rhs

    lhs
  end

  def new_module val
    line, path, body = val[1], val[2], val[4]
    body = s(:scope, body).compact
    result = s(:module, path, body)
    result.line = line
    result.comments = self.comments.pop
    result
  end

  def new_op_asgn val
    lhs, asgn_op, arg = val[0], val[1].to_sym, val[2]
    name = lhs.value
    arg = remove_begin(arg)
    result = case asgn_op # REFACTOR
             when :"||" then
               lhs << arg
               s(:op_asgn_or, self.gettable(name), lhs)
             when :"&&" then
               lhs << arg
               s(:op_asgn_and, self.gettable(name), lhs)
             else
               # TODO: why [2] ?
               lhs[2] = new_call(self.gettable(name), asgn_op,
                                 s(:arglist, arg))
               lhs
             end
    result.line = lhs.line
    result
  end

  def new_regexp val
    node = val[1] || s(:str, '')
    options = val[2]

    o, k = 0, nil
    options.split(//).uniq.each do |c| # FIX: this has a better home
      v = {
        'x' => Regexp::EXTENDED,
        'i' => Regexp::IGNORECASE,
        'm' => Regexp::MULTILINE,
        'o' => Regexp::ONCE,
        'n' => Regexp::ENC_NONE,
        'e' => Regexp::ENC_EUC,
        's' => Regexp::ENC_SJIS,
        'u' => Regexp::ENC_UTF8,
      }[c]
      raise "unknown regexp option: #{c}" unless v
      o += v
      k = c if c =~ /[esu]/
    end

    case node[0]
    when :str then
      node[0] = :lit
      node[1] = if k then
                  Regexp.new(node[1], o, k)
                else
                  Regexp.new(node[1], o)
                end
    when :dstr then
      if options =~ /o/ then
        node[0] = :dregx_once
      else
        node[0] = :dregx
      end
      node << o if o and o != 0
    else
      node = s(:dregx, '', node);
      node[0] = :dregx_once if options =~ /o/
      node << o if o and o != 0
    end

    node
  end

  def new_sclass val
    recv, in_def, in_single, body = val[3], val[4], val[6], val[7]
    scope = s(:scope, body).compact
    result = s(:sclass, recv, scope)
    result.line = val[2]
    self.in_def = in_def
    self.in_single = in_single
    result
  end

  def new_super args
    if args && args.node_type == :block_pass then
      s(:super, args)
    else
      args ||= s(:arglist)
      s(:super, *args[1..-1])
    end
  end

  def new_undef n, m = nil
    if m then
      block_append(n, s(:undef, m))
    else
      s(:undef, n)
    end
  end

  def new_until_or_while type, block, expr, pre
    other = type == :until ? :while : :until
    line = [block && block.line, expr.line].compact.min
    block, pre = block.last, false if block && block[0] == :begin

    expr = cond expr

    result = unless expr.first == :not and canonicalize_conditions then
               s(type,  expr,      block, pre)
             else
               s(other, expr.last, block, pre)
             end

    result.line = line
    result
  end

  def new_until block, expr, pre
    new_until_or_while :until, block, expr, pre
  end

  def new_while block, expr, pre
    new_until_or_while :while, block, expr, pre
  end

  def new_xstring str
    if str then
      case str[0]
      when :str
        str[0] = :xstr
      when :dstr
        str[0] = :dxstr
      else
        str = s(:dxstr, '', str)
      end
      str
    else
      s(:xstr, '')
    end
  end

  def new_yield args = nil
    # TODO: raise args.inspect unless [:arglist].include? args.first # HACK
    raise SyntaxError, "Block argument should not be given." if
      args && args.node_type == :block_pass

    args ||= s(:arglist)

    # TODO: I can prolly clean this up
    args[0] = :arglist       if args.first == :array
    args = s(:arglist, args) unless args.first == :arglist

    return s(:yield, *args[1..-1])
  end

  def next_token
    if self.lexer.advance then
      return self.lexer.token, self.lexer.yacc_value
    else
      return [false, '$end']
    end
  end

  def node_assign(lhs, rhs) # TODO: rename new_assign
    return nil unless lhs

    rhs = value_expr rhs

    case lhs[0]
    when :gasgn, :iasgn, :lasgn, :dasgn, :dasgn_curr,
      :masgn, :cdecl, :cvdecl, :cvasgn then
      lhs << rhs
    when :attrasgn, :call then
      args = lhs.pop unless Symbol === lhs.last
      lhs << arg_add(args, rhs)
    when :const then
      lhs[0] = :cdecl
      lhs << rhs
    else
      raise "unknown lhs #{lhs.inspect}"
    end

    lhs
  end

  def process(str, file = "(string)")
    raise "bad val: #{str.inspect}" unless String === str

    self.file = file
    self.lexer.src = str

    @yydebug = ENV.has_key? 'DEBUG'

    do_parse
  end
  alias :parse :process

  def remove_begin node
    oldnode = node
    if node and :begin == node[0] and node.size == 2 then
      node = node[-1]
      node.line = oldnode.line
    end
    node
  end

  def reset
    lexer.reset
    self.in_def = false
    self.in_single = 0
    self.env.reset
    self.comments.clear
  end

  def ret_args node
    if node then
      raise SyntaxError, "block argument should not be given" if
        node[0] == :block_pass

      node = node.last if node[0] == :array && node.size == 2
      # HACK matz wraps ONE of the FOUR splats in a newline to
      # distinguish. I use paren for now. ugh
      node = s(:svalue, node) if node[0] == :splat and not node.paren
      node[0] = :svalue if node[0] == :arglist && node[1][0] == :splat
    end

    node
  end

  def s(*args)
    result = Sexp.new(*args)
    result.line ||= lexer.lineno if lexer.src          # otherwise...
    result.file = self.file
    result
  end

  def value_expr oldnode # HACK
    node = remove_begin oldnode
    node.line = oldnode.line if oldnode
    node[2] = value_expr(node[2]) if node and node[0] == :if
    node
  end

  def void_stmts node
    return nil unless node
    return node unless node[0] == :block

    node[1..-1] = node[1..-1].map { |n| remove_begin(n) }
    node
  end

  def warning s
    # do nothing for now
  end

  alias :old_yyerror :yyerror
  def yyerror msg
    # for now do nothing with the msg
    old_yyerror
  end

  class Keyword
    class KWtable
      attr_accessor :name, :state, :id0, :id1
      def initialize(name, id=[], state=nil)
        @name  = name
        @id0, @id1 = id
        @state = state
      end
    end

    ##
    # :stopdoc:
    #
    # :expr_beg    = ignore newline, +/- is a sign.
    # :expr_end    = newline significant, +/- is a operator.
    # :expr_arg    = newline significant, +/- is a operator.
    # :expr_cmdarg = newline significant, +/- is a operator.
    # :expr_endarg = newline significant, +/- is a operator.
    # :expr_mid    = newline significant, +/- is a operator.
    # :expr_fname  = ignore newline, no reserved words.
    # :expr_dot    = right after . or ::, no reserved words.
    # :expr_class  = immediate after class, no here document.

    wordlist = [
                ["end",      [:kEND,      :kEND        ], :expr_end   ],
                ["else",     [:kELSE,     :kELSE       ], :expr_beg   ],
                ["case",     [:kCASE,     :kCASE       ], :expr_beg   ],
                ["ensure",   [:kENSURE,   :kENSURE     ], :expr_beg   ],
                ["module",   [:kMODULE,   :kMODULE     ], :expr_beg   ],
                ["elsif",    [:kELSIF,    :kELSIF      ], :expr_beg   ],
                ["def",      [:kDEF,      :kDEF        ], :expr_fname ],
                ["rescue",   [:kRESCUE,   :kRESCUE_MOD ], :expr_mid   ],
                ["not",      [:kNOT,      :kNOT        ], :expr_beg   ],
                ["then",     [:kTHEN,     :kTHEN       ], :expr_beg   ],
                ["yield",    [:kYIELD,    :kYIELD      ], :expr_arg   ],
                ["for",      [:kFOR,      :kFOR        ], :expr_beg   ],
                ["self",     [:kSELF,     :kSELF       ], :expr_end   ],
                ["false",    [:kFALSE,    :kFALSE      ], :expr_end   ],
                ["retry",    [:kRETRY,    :kRETRY      ], :expr_end   ],
                ["return",   [:kRETURN,   :kRETURN     ], :expr_mid   ],
                ["true",     [:kTRUE,     :kTRUE       ], :expr_end   ],
                ["if",       [:kIF,       :kIF_MOD     ], :expr_beg   ],
                ["defined?", [:kDEFINED,  :kDEFINED    ], :expr_arg   ],
                ["super",    [:kSUPER,    :kSUPER      ], :expr_arg   ],
                ["undef",    [:kUNDEF,    :kUNDEF      ], :expr_fname ],
                ["break",    [:kBREAK,    :kBREAK      ], :expr_mid   ],
                ["in",       [:kIN,       :kIN         ], :expr_beg   ],
                ["do",       [:kDO,       :kDO         ], :expr_beg   ],
                ["nil",      [:kNIL,      :kNIL        ], :expr_end   ],
                ["until",    [:kUNTIL,    :kUNTIL_MOD  ], :expr_beg   ],
                ["unless",   [:kUNLESS,   :kUNLESS_MOD ], :expr_beg   ],
                ["or",       [:kOR,       :kOR         ], :expr_beg   ],
                ["next",     [:kNEXT,     :kNEXT       ], :expr_mid   ],
                ["when",     [:kWHEN,     :kWHEN       ], :expr_beg   ],
                ["redo",     [:kREDO,     :kREDO       ], :expr_end   ],
                ["and",      [:kAND,      :kAND        ], :expr_beg   ],
                ["begin",    [:kBEGIN,    :kBEGIN      ], :expr_beg   ],
                ["__LINE__", [:k__LINE__, :k__LINE__   ], :expr_end   ],
                ["class",    [:kCLASS,    :kCLASS      ], :expr_class ],
                ["__FILE__", [:k__FILE__, :k__FILE__   ], :expr_end   ],
                ["END",      [:klEND,     :klEND       ], :expr_end   ],
                ["BEGIN",    [:klBEGIN,   :klBEGIN     ], :expr_end   ],
                ["while",    [:kWHILE,    :kWHILE_MOD  ], :expr_beg   ],
                ["alias",    [:kALIAS,    :kALIAS      ], :expr_fname ],
               ].map { |args| KWtable.new(*args) }

    # :startdoc:

    WORDLIST = Hash[*wordlist.map { |o| [o.name, o] }.flatten] unless
      defined? WORDLIST

    def self.keyword str
      WORDLIST[str]
    end
  end

  class Environment
    attr_reader :env, :dyn

    def [] k
      self.all[k]
    end

    def []= k, v
      raise "no" if v == true
      self.current[k] = v
    end

    def all
      idx = @dyn.index(false) || 0
      @env[0..idx].reverse.inject { |env, scope| env.merge scope }
    end

    def current
      @env.first
    end

    def dynamic
      idx = @dyn.index false
      @env[0...idx].reverse.inject { |env, scope| env.merge scope } || {}
    end

    def dynamic?
      @dyn[0] != false
    end

    def extend dyn = false
      @dyn.unshift dyn
      @env.unshift({})
      @use.unshift({})
    end

    def initialize dyn = false
      @dyn = []
      @env = []
      @use = []
      self.reset
    end

    def reset
      @dyn.clear
      @env.clear
      @use.clear
      self.extend
    end

    def unextend
      @dyn.shift
      @env.shift
      @use.shift
      raise "You went too far unextending env" if @env.empty?
    end

    def use id
      @env.each_with_index do |env, i|
        if env[id] then
          @use[i][id] = true
        end
      end
    end

    def used? id
      idx = @dyn.index false # REFACTOR
      u = @use[0...idx].reverse.inject { |env, scope| env.merge scope } || {}
      u[id]
    end
  end

  class StackState
    attr_reader :stack

    def initialize(name)
      @name = name
      @stack = [false]
    end

    def inspect
      "StackState(#{@name}, #{@stack.inspect})"
    end

    def is_in_state
      @stack.last
    end

    def lexpop
      raise if @stack.size == 0
      a = @stack.pop
      b = @stack.pop
      @stack.push(a || b)
    end

    def pop
      r = @stack.pop
      @stack.push false if @stack.size == 0
      r
    end

    def push val
      @stack.push val
    end
  end
end
new_aref(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 419
def new_aref val
  val[2] ||= s(:arglist)
  val[2][0] = :arglist if val[2][0] == :array # REFACTOR
  if val[0].node_type == :self then
    result = new_call nil, :"[]", val[2]
  else
    result = new_call val[0], :"[]", val[2]
  end
  result
end
new_body(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 430
def new_body val
  result = val[0]

  if val[1] then
    result = s(:rescue)
    result << val[0] if val[0]

    resbody = val[1]

    while resbody do
      result << resbody
      resbody = resbody.resbody(true)
    end

    result << val[2] if val[2]

    result.line = (val[0] || val[1]).line
  elsif not val[2].nil? then
    warning("else without rescue is useless")
    result = block_append(result, val[2])
  end

  result = s(:ensure, result, val[3]).compact if val[3]
  return result
end
new_call(recv, meth, args = nil) click to toggle source
# File lib/ruby_parser_extras.rb, line 456
def new_call recv, meth, args = nil
  result = s(:call, recv, meth)
  result.line = recv.line if recv

  args ||= s(:arglist)
  args[0] = :arglist if args.first == :array
  args = s(:arglist, args) unless args.first == :arglist
  result << args
  result
end
new_case(expr, body) click to toggle source
# File lib/ruby_parser_extras.rb, line 467
def new_case expr, body
  result = s(:case, expr)
  line = (expr || body).line

  while body and body.node_type == :when
    result << body
    body = body.delete_at 3
  end

  # else
  body = nil if body == s(:block)
  result << body

  result.line = line
  result
end
new_class(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 484
def new_class val
  line, path, superclass, body = val[1], val[2], val[3], val[5]
  scope = s(:scope, body).compact
  result = s(:class, path, superclass, scope)
  result.line = line
  result.comments = self.comments.pop
  result
end
new_compstmt(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 493
def new_compstmt val
  result = void_stmts(val[0])
  result = remove_begin(result) if result
  result
end
new_defn(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 499
def new_defn val
  (_, line), name, args, body = val[0], val[1], val[3], val[4]
  body ||= s(:nil)

  body ||= s(:block)
  body = s(:block, body) unless body.first == :block

  result = s(:defn, name.to_sym, args, s(:scope, body))
  result.line = line
  result.comments = self.comments.pop
  result
end
new_defs(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 512
def new_defs val
  recv, name, args, body = val[1], val[4], val[6], val[7]

  body ||= s(:block)
  body = s(:block, body) unless body.first == :block

  result = s(:defs, recv, name.to_sym, args, s(:scope, body))
  result.line = recv.line
  result.comments = self.comments.pop
  result
end
new_for(expr, var, body) click to toggle source
# File lib/ruby_parser_extras.rb, line 524
def new_for expr, var, body
  result = s(:for, expr, var).line(var.line)
  result << body if body
  result
end
new_if(c, t, f) click to toggle source
# File lib/ruby_parser_extras.rb, line 530
def new_if c, t, f
  l = [c.line, t && t.line, f && f.line].compact.min
  c = cond c
  c, t, f = c.last, f, t if c[0] == :not and canonicalize_conditions
  s(:if, c, t, f).line(l)
end
new_iter(call, args, body) click to toggle source
# File lib/ruby_parser_extras.rb, line 537
def new_iter call, args, body
  result = s(:iter)
  result << call if call
  result << args
  result << body if body
  result
end
new_masgn(lhs, rhs, wrap = false) click to toggle source
# File lib/ruby_parser_extras.rb, line 545
def new_masgn lhs, rhs, wrap = false
  rhs = value_expr(rhs)
  rhs = lhs[1] ? s(:to_ary, rhs) : s(:array, rhs) if wrap

  lhs.delete_at 1 if lhs[1].nil?
  lhs << rhs

  lhs
end
new_module(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 555
def new_module val
  line, path, body = val[1], val[2], val[4]
  body = s(:scope, body).compact
  result = s(:module, path, body)
  result.line = line
  result.comments = self.comments.pop
  result
end
new_op_asgn(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 564
def new_op_asgn val
  lhs, asgn_op, arg = val[0], val[1].to_sym, val[2]
  name = lhs.value
  arg = remove_begin(arg)
  result = case asgn_op # REFACTOR
           when :"||" then
             lhs << arg
             s(:op_asgn_or, self.gettable(name), lhs)
           when :"&&" then
             lhs << arg
             s(:op_asgn_and, self.gettable(name), lhs)
           else
             # TODO: why [2] ?
             lhs[2] = new_call(self.gettable(name), asgn_op,
                               s(:arglist, arg))
             lhs
           end
  result.line = lhs.line
  result
end
new_regexp(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 585
def new_regexp val
  node = val[1] || s(:str, '')
  options = val[2]

  o, k = 0, nil
  options.split(//).uniq.each do |c| # FIX: this has a better home
    v = {
      'x' => Regexp::EXTENDED,
      'i' => Regexp::IGNORECASE,
      'm' => Regexp::MULTILINE,
      'o' => Regexp::ONCE,
      'n' => Regexp::ENC_NONE,
      'e' => Regexp::ENC_EUC,
      's' => Regexp::ENC_SJIS,
      'u' => Regexp::ENC_UTF8,
    }[c]
    raise "unknown regexp option: #{c}" unless v
    o += v
    k = c if c =~ /[esu]/
  end

  case node[0]
  when :str then
    node[0] = :lit
    node[1] = if k then
                Regexp.new(node[1], o, k)
              else
                Regexp.new(node[1], o)
              end
  when :dstr then
    if options =~ /o/ then
      node[0] = :dregx_once
    else
      node[0] = :dregx
    end
    node << o if o and o != 0
  else
    node = s(:dregx, '', node);
    node[0] = :dregx_once if options =~ /o/
    node << o if o and o != 0
  end

  node
end
new_sclass(val) click to toggle source
# File lib/ruby_parser_extras.rb, line 630
def new_sclass val
  recv, in_def, in_single, body = val[3], val[4], val[6], val[7]
  scope = s(:scope, body).compact
  result = s(:sclass, recv, scope)
  result.line = val[2]
  self.in_def = in_def
  self.in_single = in_single
  result
end
new_super(args) click to toggle source
# File lib/ruby_parser_extras.rb, line 640
def new_super args
  if args && args.node_type == :block_pass then
    s(:super, args)
  else
    args ||= s(:arglist)
    s(:super, *args[1..-1])
  end
end
new_undef(n, m = nil) click to toggle source
# File lib/ruby_parser_extras.rb, line 649
def new_undef n, m = nil
  if m then
    block_append(n, s(:undef, m))
  else
    s(:undef, n)
  end
end
new_until(block, expr, pre) click to toggle source
# File lib/ruby_parser_extras.rb, line 674
def new_until block, expr, pre
  new_until_or_while :until, block, expr, pre
end
new_until_or_while(type, block, expr, pre) click to toggle source
# File lib/ruby_parser_extras.rb, line 657
def new_until_or_while type, block, expr, pre
  other = type == :until ? :while : :until
  line = [block && block.line, expr.line].compact.min
  block, pre = block.last, false if block && block[0] == :begin

  expr = cond expr

  result = unless expr.first == :not and canonicalize_conditions then
             s(type,  expr,      block, pre)
           else
             s(other, expr.last, block, pre)
           end

  result.line = line
  result
end
new_while(block, expr, pre) click to toggle source
# File lib/ruby_parser_extras.rb, line 678
def new_while block, expr, pre
  new_until_or_while :while, block, expr, pre
end
new_xstring(str) click to toggle source
# File lib/ruby_parser_extras.rb, line 682
def new_xstring str
  if str then
    case str[0]
    when :str
      str[0] = :xstr
    when :dstr
      str[0] = :dxstr
    else
      str = s(:dxstr, '', str)
    end
    str
  else
    s(:xstr, '')
  end
end
new_yield(args = nil) click to toggle source
# File lib/ruby_parser_extras.rb, line 698
def new_yield args = nil
  # TODO: raise args.inspect unless [:arglist].include? args.first # HACK
  raise SyntaxError, "Block argument should not be given." if
    args && args.node_type == :block_pass

  args ||= s(:arglist)

  # TODO: I can prolly clean this up
  args[0] = :arglist       if args.first == :array
  args = s(:arglist, args) unless args.first == :arglist

  return s(:yield, *args[1..-1])
end
next_token() click to toggle source
# File lib/ruby_parser_extras.rb, line 712
def next_token
  if self.lexer.advance then
    return self.lexer.token, self.lexer.yacc_value
  else
    return [false, '$end']
  end
end
node_assign(lhs, rhs) click to toggle source
# File lib/ruby_parser_extras.rb, line 720
def node_assign(lhs, rhs) # TODO: rename new_assign
  return nil unless lhs

  rhs = value_expr rhs

  case lhs[0]
  when :gasgn, :iasgn, :lasgn, :dasgn, :dasgn_curr,
    :masgn, :cdecl, :cvdecl, :cvasgn then
    lhs << rhs
  when :attrasgn, :call then
    args = lhs.pop unless Symbol === lhs.last
    lhs << arg_add(args, rhs)
  when :const then
    lhs[0] = :cdecl
    lhs << rhs
  else
    raise "unknown lhs #{lhs.inspect}"
  end

  lhs
end
process(str, file = "(string)") click to toggle source
# File lib/ruby_parser_extras.rb, line 742
def process(str, file = "(string)")
  raise "bad val: #{str.inspect}" unless String === str

  self.file = file
  self.lexer.src = str

  @yydebug = ENV.has_key? 'DEBUG'

  do_parse
end
remove_begin(node) click to toggle source
# File lib/ruby_parser_extras.rb, line 754
def remove_begin node
  oldnode = node
  if node and :begin == node[0] and node.size == 2 then
    node = node[-1]
    node.line = oldnode.line
  end
  node
end
reset() click to toggle source
# File lib/ruby_parser_extras.rb, line 763
def reset
  lexer.reset
  self.in_def = false
  self.in_single = 0
  self.env.reset
  self.comments.clear
end
ret_args(node) click to toggle source
# File lib/ruby_parser_extras.rb, line 771
def ret_args node
  if node then
    raise SyntaxError, "block argument should not be given" if
      node[0] == :block_pass

    node = node.last if node[0] == :array && node.size == 2
    # HACK matz wraps ONE of the FOUR splats in a newline to
    # distinguish. I use paren for now. ugh
    node = s(:svalue, node) if node[0] == :splat and not node.paren
    node[0] = :svalue if node[0] == :arglist && node[1][0] == :splat
  end

  node
end
s(*args) click to toggle source
# File lib/ruby_parser_extras.rb, line 786
def s(*args)
  result = Sexp.new(*args)
  result.line ||= lexer.lineno if lexer.src          # otherwise...
  result.file = self.file
  result
end
value_expr(oldnode) click to toggle source
# File lib/ruby_parser_extras.rb, line 793
def value_expr oldnode # HACK
  node = remove_begin oldnode
  node.line = oldnode.line if oldnode
  node[2] = value_expr(node[2]) if node and node[0] == :if
  node
end
void_stmts(node) click to toggle source
# File lib/ruby_parser_extras.rb, line 800
def void_stmts node
  return nil unless node
  return node unless node[0] == :block

  node[1..-1] = node[1..-1].map { |n| remove_begin(n) }
  node
end
warning(s) click to toggle source
# File lib/ruby_parser_extras.rb, line 808
def warning s
  # do nothing for now
end
yyerror(msg) click to toggle source
# File lib/ruby_parser_extras.rb, line 813
def yyerror msg
  # for now do nothing with the msg
  old_yyerror
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.