kanayago 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +261 -0
 - data/README.md +1 -1
 - data/Rakefile +5 -48
 - data/ext/kanayago/extconf.rb +8 -0
 - data/ext/kanayago/kanayago.c +30 -185
 - data/ext/kanayago/scope_node.c +2 -16
 - data/ext/kanayago/variable_node.c +2 -1
 - data/lib/kanayago/call_node.rb +19 -0
 - data/lib/kanayago/constant_node.rb +15 -0
 - data/lib/kanayago/literal_node.rb +4 -0
 - data/lib/kanayago/scope_node.rb +14 -0
 - data/lib/kanayago/statement_node.rb +16 -0
 - data/lib/kanayago/variable_node.rb +4 -0
 - data/lib/kanayago/version.rb +1 -1
 - data/lib/kanayago.rb +3 -16
 - data/script/setup_parser.rb +136 -0
 - metadata +6 -64
 - data/ext/kanayago/ccan/check_type/check_type.h +0 -63
 - data/ext/kanayago/ccan/container_of/container_of.h +0 -142
 - data/ext/kanayago/ccan/list/list.h +0 -791
 - data/ext/kanayago/ccan/str/str.h +0 -17
 - data/ext/kanayago/constant.h +0 -53
 - data/ext/kanayago/id.h +0 -354
 - data/ext/kanayago/id_table.h +0 -54
 - data/ext/kanayago/include/ruby/st.h +0 -199
 - data/ext/kanayago/internal/array.h +0 -154
 - data/ext/kanayago/internal/basic_operators.h +0 -65
 - data/ext/kanayago/internal/bignum.h +0 -245
 - data/ext/kanayago/internal/bits.h +0 -650
 - data/ext/kanayago/internal/compile.h +0 -34
 - data/ext/kanayago/internal/compilers.h +0 -107
 - data/ext/kanayago/internal/complex.h +0 -29
 - data/ext/kanayago/internal/encoding.h +0 -39
 - data/ext/kanayago/internal/error.h +0 -251
 - data/ext/kanayago/internal/fixnum.h +0 -185
 - data/ext/kanayago/internal/gc.h +0 -358
 - data/ext/kanayago/internal/hash.h +0 -194
 - data/ext/kanayago/internal/imemo.h +0 -322
 - data/ext/kanayago/internal/io.h +0 -163
 - data/ext/kanayago/internal/namespace.h +0 -81
 - data/ext/kanayago/internal/numeric.h +0 -275
 - data/ext/kanayago/internal/parse.h +0 -131
 - data/ext/kanayago/internal/rational.h +0 -71
 - data/ext/kanayago/internal/re.h +0 -33
 - data/ext/kanayago/internal/ruby_parser.h +0 -125
 - data/ext/kanayago/internal/sanitizers.h +0 -346
 - data/ext/kanayago/internal/serial.h +0 -23
 - data/ext/kanayago/internal/set_table.h +0 -70
 - data/ext/kanayago/internal/static_assert.h +0 -16
 - data/ext/kanayago/internal/string.h +0 -203
 - data/ext/kanayago/internal/symbol.h +0 -46
 - data/ext/kanayago/internal/thread.h +0 -112
 - data/ext/kanayago/internal/variable.h +0 -74
 - data/ext/kanayago/internal/vm.h +0 -136
 - data/ext/kanayago/internal/warnings.h +0 -16
 - data/ext/kanayago/internal.h +0 -105
 - data/ext/kanayago/lex.c +0 -302
 - data/ext/kanayago/method.h +0 -271
 - data/ext/kanayago/node.c +0 -446
 - data/ext/kanayago/node.h +0 -122
 - data/ext/kanayago/node_name.inc +0 -224
 - data/ext/kanayago/parse.c +0 -27377
 - data/ext/kanayago/parse.h +0 -244
 - data/ext/kanayago/parser_bits.h +0 -564
 - data/ext/kanayago/parser_node.h +0 -32
 - data/ext/kanayago/parser_st.c +0 -165
 - data/ext/kanayago/parser_st.h +0 -162
 - data/ext/kanayago/parser_value.h +0 -106
 - data/ext/kanayago/probes.h +0 -4
 - data/ext/kanayago/ruby_assert.h +0 -14
 - data/ext/kanayago/ruby_atomic.h +0 -66
 - data/ext/kanayago/ruby_parser.c +0 -1137
 - data/ext/kanayago/rubyparser.h +0 -1394
 - data/ext/kanayago/shape.h +0 -444
 - data/ext/kanayago/st.c +0 -3223
 - data/ext/kanayago/symbol.h +0 -116
 - data/ext/kanayago/thread_pthread.h +0 -175
 - data/ext/kanayago/universal_parser.c +0 -211
 - data/ext/kanayago/vm_core.h +0 -2349
 - data/ext/kanayago/vm_opts.h +0 -67
 
    
        data/ext/kanayago/ruby_parser.c
    DELETED
    
    | 
         @@ -1,1137 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            /* This is a wrapper for parse.y */
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            #include "internal/parse.h"
         
     | 
| 
       4 
     | 
    
         
            -
            #include "internal/re.h"
         
     | 
| 
       5 
     | 
    
         
            -
            #include "internal/ruby_parser.h"
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            #include "node.h"
         
     | 
| 
       8 
     | 
    
         
            -
            #include "rubyparser.h"
         
     | 
| 
       9 
     | 
    
         
            -
            #include "internal/error.h"
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            #ifdef UNIVERSAL_PARSER
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            #include "internal.h"
         
     | 
| 
       14 
     | 
    
         
            -
            #include "internal/array.h"
         
     | 
| 
       15 
     | 
    
         
            -
            #include "internal/bignum.h"
         
     | 
| 
       16 
     | 
    
         
            -
            #include "internal/compile.h"
         
     | 
| 
       17 
     | 
    
         
            -
            #include "internal/complex.h"
         
     | 
| 
       18 
     | 
    
         
            -
            #include "internal/encoding.h"
         
     | 
| 
       19 
     | 
    
         
            -
            #include "internal/gc.h"
         
     | 
| 
       20 
     | 
    
         
            -
            #include "internal/hash.h"
         
     | 
| 
       21 
     | 
    
         
            -
            #include "internal/io.h"
         
     | 
| 
       22 
     | 
    
         
            -
            #include "internal/rational.h"
         
     | 
| 
       23 
     | 
    
         
            -
            #include "internal/re.h"
         
     | 
| 
       24 
     | 
    
         
            -
            #include "internal/string.h"
         
     | 
| 
       25 
     | 
    
         
            -
            #include "internal/symbol.h"
         
     | 
| 
       26 
     | 
    
         
            -
            #include "internal/thread.h"
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            #include "ruby/ractor.h"
         
     | 
| 
       29 
     | 
    
         
            -
            #include "ruby/ruby.h"
         
     | 
| 
       30 
     | 
    
         
            -
            #include "ruby/util.h"
         
     | 
| 
       31 
     | 
    
         
            -
            #include "internal.h"
         
     | 
| 
       32 
     | 
    
         
            -
            #include "vm_core.h"
         
     | 
| 
       33 
     | 
    
         
            -
            #include "symbol.h"
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
            #define parser_encoding const void
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
            RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 6, 0)
         
     | 
| 
       38 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       39 
     | 
    
         
            -
            syntax_error_append(VALUE exc, VALUE file, int line, int column,
         
     | 
| 
       40 
     | 
    
         
            -
                                parser_encoding *enc, const char *fmt, va_list args)
         
     | 
| 
       41 
     | 
    
         
            -
            {
         
     | 
| 
       42 
     | 
    
         
            -
                return rb_syntax_error_append(exc, file, line, column, enc, fmt, args);
         
     | 
| 
       43 
     | 
    
         
            -
            }
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            static int
         
     | 
| 
       46 
     | 
    
         
            -
            local_defined(ID id, const void *p)
         
     | 
| 
       47 
     | 
    
         
            -
            {
         
     | 
| 
       48 
     | 
    
         
            -
                return rb_local_defined(id, (const rb_iseq_t *)p);
         
     | 
| 
       49 
     | 
    
         
            -
            }
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
            static int
         
     | 
| 
       52 
     | 
    
         
            -
            dvar_defined(ID id, const void *p)
         
     | 
| 
       53 
     | 
    
         
            -
            {
         
     | 
| 
       54 
     | 
    
         
            -
                return rb_dvar_defined(id, (const rb_iseq_t *)p);
         
     | 
| 
       55 
     | 
    
         
            -
            }
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
            static int
         
     | 
| 
       58 
     | 
    
         
            -
            is_usascii_enc(parser_encoding *enc)
         
     | 
| 
       59 
     | 
    
         
            -
            {
         
     | 
| 
       60 
     | 
    
         
            -
                return rb_is_usascii_enc(enc);
         
     | 
| 
       61 
     | 
    
         
            -
            }
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
            static int
         
     | 
| 
       64 
     | 
    
         
            -
            is_local_id2(ID id)
         
     | 
| 
       65 
     | 
    
         
            -
            {
         
     | 
| 
       66 
     | 
    
         
            -
                return is_local_id(id);
         
     | 
| 
       67 
     | 
    
         
            -
            }
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
            static int
         
     | 
| 
       70 
     | 
    
         
            -
            is_attrset_id2(ID id)
         
     | 
| 
       71 
     | 
    
         
            -
            {
         
     | 
| 
       72 
     | 
    
         
            -
                return is_attrset_id(id);
         
     | 
| 
       73 
     | 
    
         
            -
            }
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
            static int
         
     | 
| 
       76 
     | 
    
         
            -
            is_notop_id2(ID id)
         
     | 
| 
       77 
     | 
    
         
            -
            {
         
     | 
| 
       78 
     | 
    
         
            -
                return is_notop_id(id);
         
     | 
| 
       79 
     | 
    
         
            -
            }
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       82 
     | 
    
         
            -
            enc_str_new(const char *ptr, long len, parser_encoding *enc)
         
     | 
| 
       83 
     | 
    
         
            -
            {
         
     | 
| 
       84 
     | 
    
         
            -
                return rb_enc_str_new(ptr, len, enc);
         
     | 
| 
       85 
     | 
    
         
            -
            }
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
            static int
         
     | 
| 
       88 
     | 
    
         
            -
            enc_isalnum(OnigCodePoint c, parser_encoding *enc)
         
     | 
| 
       89 
     | 
    
         
            -
            {
         
     | 
| 
       90 
     | 
    
         
            -
                return rb_enc_isalnum(c, enc);
         
     | 
| 
       91 
     | 
    
         
            -
            }
         
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
            static int
         
     | 
| 
       94 
     | 
    
         
            -
            enc_precise_mbclen(const char *p, const char *e, parser_encoding *enc)
         
     | 
| 
       95 
     | 
    
         
            -
            {
         
     | 
| 
       96 
     | 
    
         
            -
                return rb_enc_precise_mbclen(p, e, enc);
         
     | 
| 
       97 
     | 
    
         
            -
            }
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
            static int
         
     | 
| 
       100 
     | 
    
         
            -
            mbclen_charfound_p(int len)
         
     | 
| 
       101 
     | 
    
         
            -
            {
         
     | 
| 
       102 
     | 
    
         
            -
                return MBCLEN_CHARFOUND_P(len);
         
     | 
| 
       103 
     | 
    
         
            -
            }
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
            static int
         
     | 
| 
       106 
     | 
    
         
            -
            mbclen_charfound_len(int len)
         
     | 
| 
       107 
     | 
    
         
            -
            {
         
     | 
| 
       108 
     | 
    
         
            -
                return MBCLEN_CHARFOUND_LEN(len);
         
     | 
| 
       109 
     | 
    
         
            -
            }
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
            static const char *
         
     | 
| 
       112 
     | 
    
         
            -
            enc_name(parser_encoding *enc)
         
     | 
| 
       113 
     | 
    
         
            -
            {
         
     | 
| 
       114 
     | 
    
         
            -
                return rb_enc_name(enc);
         
     | 
| 
       115 
     | 
    
         
            -
            }
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
            static char *
         
     | 
| 
       118 
     | 
    
         
            -
            enc_prev_char(const char *s, const char *p, const char *e, parser_encoding *enc)
         
     | 
| 
       119 
     | 
    
         
            -
            {
         
     | 
| 
       120 
     | 
    
         
            -
                return rb_enc_prev_char(s, p, e, enc);
         
     | 
| 
       121 
     | 
    
         
            -
            }
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
            static parser_encoding *
         
     | 
| 
       124 
     | 
    
         
            -
            enc_get(VALUE obj)
         
     | 
| 
       125 
     | 
    
         
            -
            {
         
     | 
| 
       126 
     | 
    
         
            -
                return rb_enc_get(obj);
         
     | 
| 
       127 
     | 
    
         
            -
            }
         
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
            static int
         
     | 
| 
       130 
     | 
    
         
            -
            enc_asciicompat(parser_encoding *enc)
         
     | 
| 
       131 
     | 
    
         
            -
            {
         
     | 
| 
       132 
     | 
    
         
            -
                return rb_enc_asciicompat(enc);
         
     | 
| 
       133 
     | 
    
         
            -
            }
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
            static parser_encoding *
         
     | 
| 
       136 
     | 
    
         
            -
            utf8_encoding(void)
         
     | 
| 
       137 
     | 
    
         
            -
            {
         
     | 
| 
       138 
     | 
    
         
            -
                return rb_utf8_encoding();
         
     | 
| 
       139 
     | 
    
         
            -
            }
         
     | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
            static parser_encoding *
         
     | 
| 
       142 
     | 
    
         
            -
            ascii8bit_encoding(void)
         
     | 
| 
       143 
     | 
    
         
            -
            {
         
     | 
| 
       144 
     | 
    
         
            -
                return rb_ascii8bit_encoding();
         
     | 
| 
       145 
     | 
    
         
            -
            }
         
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
            static int
         
     | 
| 
       148 
     | 
    
         
            -
            enc_codelen(int c, parser_encoding *enc)
         
     | 
| 
       149 
     | 
    
         
            -
            {
         
     | 
| 
       150 
     | 
    
         
            -
                return rb_enc_codelen(c, enc);
         
     | 
| 
       151 
     | 
    
         
            -
            }
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
            static int
         
     | 
| 
       154 
     | 
    
         
            -
            enc_mbcput(unsigned int c, void *buf, parser_encoding *enc)
         
     | 
| 
       155 
     | 
    
         
            -
            {
         
     | 
| 
       156 
     | 
    
         
            -
                return rb_enc_mbcput(c, buf, enc);
         
     | 
| 
       157 
     | 
    
         
            -
            }
         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
            static parser_encoding *
         
     | 
| 
       160 
     | 
    
         
            -
            enc_from_index(int idx)
         
     | 
| 
       161 
     | 
    
         
            -
            {
         
     | 
| 
       162 
     | 
    
         
            -
                return rb_enc_from_index(idx);
         
     | 
| 
       163 
     | 
    
         
            -
            }
         
     | 
| 
       164 
     | 
    
         
            -
             
     | 
| 
       165 
     | 
    
         
            -
            static int
         
     | 
| 
       166 
     | 
    
         
            -
            enc_isspace(OnigCodePoint c, parser_encoding *enc)
         
     | 
| 
       167 
     | 
    
         
            -
            {
         
     | 
| 
       168 
     | 
    
         
            -
                return rb_enc_isspace(c, enc);
         
     | 
| 
       169 
     | 
    
         
            -
            }
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
            static ID
         
     | 
| 
       172 
     | 
    
         
            -
            intern3(const char *name, long len, parser_encoding *enc)
         
     | 
| 
       173 
     | 
    
         
            -
            {
         
     | 
| 
       174 
     | 
    
         
            -
                return rb_intern3(name, len, enc);
         
     | 
| 
       175 
     | 
    
         
            -
            }
         
     | 
| 
       176 
     | 
    
         
            -
             
     | 
| 
       177 
     | 
    
         
            -
            static int
         
     | 
| 
       178 
     | 
    
         
            -
            enc_symname_type(const char *name, long len, parser_encoding *enc, unsigned int allowed_attrset)
         
     | 
| 
       179 
     | 
    
         
            -
            {
         
     | 
| 
       180 
     | 
    
         
            -
                return rb_enc_symname_type(name, len, enc, allowed_attrset);
         
     | 
| 
       181 
     | 
    
         
            -
            }
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
            typedef struct {
         
     | 
| 
       184 
     | 
    
         
            -
                struct parser_params *parser;
         
     | 
| 
       185 
     | 
    
         
            -
                rb_encoding *enc;
         
     | 
| 
       186 
     | 
    
         
            -
                NODE *succ_block;
         
     | 
| 
       187 
     | 
    
         
            -
                const rb_code_location_t *loc;
         
     | 
| 
       188 
     | 
    
         
            -
                rb_parser_assignable_func assignable;
         
     | 
| 
       189 
     | 
    
         
            -
            } reg_named_capture_assign_t;
         
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
       191 
     | 
    
         
            -
            static int
         
     | 
| 
       192 
     | 
    
         
            -
            reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
         
     | 
| 
       193 
     | 
    
         
            -
                      int back_num, int *back_refs, OnigRegex regex, void *arg0)
         
     | 
| 
       194 
     | 
    
         
            -
            {
         
     | 
| 
       195 
     | 
    
         
            -
                reg_named_capture_assign_t *arg = (reg_named_capture_assign_t*)arg0;
         
     | 
| 
       196 
     | 
    
         
            -
                struct parser_params* p = arg->parser;
         
     | 
| 
       197 
     | 
    
         
            -
                rb_encoding *enc = arg->enc;
         
     | 
| 
       198 
     | 
    
         
            -
                const rb_code_location_t *loc = arg->loc;
         
     | 
| 
       199 
     | 
    
         
            -
                long len = name_end - name;
         
     | 
| 
       200 
     | 
    
         
            -
                const char *s = (const char *)name;
         
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
                return rb_reg_named_capture_assign_iter_impl(p, s, len, enc, &arg->succ_block, loc, arg->assignable);
         
     | 
| 
       203 
     | 
    
         
            -
            }
         
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
     | 
    
         
            -
            static NODE *
         
     | 
| 
       206 
     | 
    
         
            -
            reg_named_capture_assign(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc,
         
     | 
| 
       207 
     | 
    
         
            -
                                     rb_parser_assignable_func assignable)
         
     | 
| 
       208 
     | 
    
         
            -
            {
         
     | 
| 
       209 
     | 
    
         
            -
                reg_named_capture_assign_t arg;
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
                arg.parser = p;
         
     | 
| 
       212 
     | 
    
         
            -
                arg.enc = rb_enc_get(regexp);
         
     | 
| 
       213 
     | 
    
         
            -
                arg.succ_block = 0;
         
     | 
| 
       214 
     | 
    
         
            -
                arg.loc = loc;
         
     | 
| 
       215 
     | 
    
         
            -
                arg.assignable = assignable;
         
     | 
| 
       216 
     | 
    
         
            -
                onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg);
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
                if (!arg.succ_block) return 0;
         
     | 
| 
       219 
     | 
    
         
            -
                return RNODE_BLOCK(arg.succ_block)->nd_next;
         
     | 
| 
       220 
     | 
    
         
            -
            }
         
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
            static int
         
     | 
| 
       223 
     | 
    
         
            -
            rtest(VALUE obj)
         
     | 
| 
       224 
     | 
    
         
            -
            {
         
     | 
| 
       225 
     | 
    
         
            -
                return (int)RB_TEST(obj);
         
     | 
| 
       226 
     | 
    
         
            -
            }
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
     | 
    
         
            -
            static int
         
     | 
| 
       229 
     | 
    
         
            -
            nil_p(VALUE obj)
         
     | 
| 
       230 
     | 
    
         
            -
            {
         
     | 
| 
       231 
     | 
    
         
            -
                return (int)NIL_P(obj);
         
     | 
| 
       232 
     | 
    
         
            -
            }
         
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       235 
     | 
    
         
            -
            syntax_error_new(void)
         
     | 
| 
       236 
     | 
    
         
            -
            {
         
     | 
| 
       237 
     | 
    
         
            -
                return rb_class_new_instance(0, 0, rb_eSyntaxError);
         
     | 
| 
       238 
     | 
    
         
            -
            }
         
     | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
       240 
     | 
    
         
            -
            static void *
         
     | 
| 
       241 
     | 
    
         
            -
            memmove2(void *dest, const void *src, size_t t, size_t n)
         
     | 
| 
       242 
     | 
    
         
            -
            {
         
     | 
| 
       243 
     | 
    
         
            -
                return memmove(dest, src, rbimpl_size_mul_or_raise(t, n));
         
     | 
| 
       244 
     | 
    
         
            -
            }
         
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
       246 
     | 
    
         
            -
            static void *
         
     | 
| 
       247 
     | 
    
         
            -
            nonempty_memcpy(void *dest, const void *src, size_t t, size_t n)
         
     | 
| 
       248 
     | 
    
         
            -
            {
         
     | 
| 
       249 
     | 
    
         
            -
                return ruby_nonempty_memcpy(dest, src, rbimpl_size_mul_or_raise(t, n));
         
     | 
| 
       250 
     | 
    
         
            -
            }
         
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       253 
     | 
    
         
            -
            ruby_verbose2(void)
         
     | 
| 
       254 
     | 
    
         
            -
            {
         
     | 
| 
       255 
     | 
    
         
            -
                return ruby_verbose;
         
     | 
| 
       256 
     | 
    
         
            -
            }
         
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
            static int *
         
     | 
| 
       259 
     | 
    
         
            -
            rb_errno_ptr2(void)
         
     | 
| 
       260 
     | 
    
         
            -
            {
         
     | 
| 
       261 
     | 
    
         
            -
                return rb_errno_ptr();
         
     | 
| 
       262 
     | 
    
         
            -
            }
         
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
            static void *
         
     | 
| 
       265 
     | 
    
         
            -
            zalloc(size_t elemsiz)
         
     | 
| 
       266 
     | 
    
         
            -
            {
         
     | 
| 
       267 
     | 
    
         
            -
                return ruby_xcalloc(1, elemsiz);
         
     | 
| 
       268 
     | 
    
         
            -
            }
         
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
            static void
         
     | 
| 
       271 
     | 
    
         
            -
            gc_guard(VALUE obj)
         
     | 
| 
       272 
     | 
    
         
            -
            {
         
     | 
| 
       273 
     | 
    
         
            -
                RB_GC_GUARD(obj);
         
     | 
| 
       274 
     | 
    
         
            -
            }
         
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       277 
     | 
    
         
            -
            arg_error(void)
         
     | 
| 
       278 
     | 
    
         
            -
            {
         
     | 
| 
       279 
     | 
    
         
            -
                return rb_eArgError;
         
     | 
| 
       280 
     | 
    
         
            -
            }
         
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       283 
     | 
    
         
            -
            static_id2sym(ID id)
         
     | 
| 
       284 
     | 
    
         
            -
            {
         
     | 
| 
       285 
     | 
    
         
            -
                return (((VALUE)(id)<<RUBY_SPECIAL_SHIFT)|SYMBOL_FLAG);
         
     | 
| 
       286 
     | 
    
         
            -
            }
         
     | 
| 
       287 
     | 
    
         
            -
             
     | 
| 
       288 
     | 
    
         
            -
            static long
         
     | 
| 
       289 
     | 
    
         
            -
            str_coderange_scan_restartable(const char *s, const char *e, parser_encoding *enc, int *cr)
         
     | 
| 
       290 
     | 
    
         
            -
            {
         
     | 
| 
       291 
     | 
    
         
            -
                return rb_str_coderange_scan_restartable(s, e, enc, cr);
         
     | 
| 
       292 
     | 
    
         
            -
            }
         
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
       294 
     | 
    
         
            -
            static int
         
     | 
| 
       295 
     | 
    
         
            -
            enc_mbminlen(parser_encoding *enc)
         
     | 
| 
       296 
     | 
    
         
            -
            {
         
     | 
| 
       297 
     | 
    
         
            -
                return rb_enc_mbminlen(enc);
         
     | 
| 
       298 
     | 
    
         
            -
            }
         
     | 
| 
       299 
     | 
    
         
            -
             
     | 
| 
       300 
     | 
    
         
            -
            static bool
         
     | 
| 
       301 
     | 
    
         
            -
            enc_isascii(OnigCodePoint c, parser_encoding *enc)
         
     | 
| 
       302 
     | 
    
         
            -
            {
         
     | 
| 
       303 
     | 
    
         
            -
                return rb_enc_isascii(c, enc);
         
     | 
| 
       304 
     | 
    
         
            -
            }
         
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
     | 
    
         
            -
            static OnigCodePoint
         
     | 
| 
       307 
     | 
    
         
            -
            enc_mbc_to_codepoint(const char *p, const char *e, parser_encoding *enc)
         
     | 
| 
       308 
     | 
    
         
            -
            {
         
     | 
| 
       309 
     | 
    
         
            -
                const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p);
         
     | 
| 
       310 
     | 
    
         
            -
                const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e);
         
     | 
| 
       311 
     | 
    
         
            -
             
     | 
| 
       312 
     | 
    
         
            -
                return ONIGENC_MBC_TO_CODE((rb_encoding *)enc, up, ue);
         
     | 
| 
       313 
     | 
    
         
            -
            }
         
     | 
| 
       314 
     | 
    
         
            -
             
     | 
| 
       315 
     | 
    
         
            -
            extern VALUE rb_eArgError;
         
     | 
| 
       316 
     | 
    
         
            -
             
     | 
| 
       317 
     | 
    
         
            -
            // Add for Kanayago
         
     | 
| 
       318 
     | 
    
         
            -
            static void *
         
     | 
| 
       319 
     | 
    
         
            -
            xmalloc_mul_add(size_t x, size_t y, size_t z)
         
     | 
| 
       320 
     | 
    
         
            -
            {
         
     | 
| 
       321 
     | 
    
         
            -
                return rb_xmalloc_mul_add(x, y, z);
         
     | 
| 
       322 
     | 
    
         
            -
            }
         
     | 
| 
       323 
     | 
    
         
            -
             
     | 
| 
       324 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       325 
     | 
    
         
            -
            suppress_tracing(VALUE (*func)(VALUE), VALUE arg)
         
     | 
| 
       326 
     | 
    
         
            -
            {
         
     | 
| 
       327 
     | 
    
         
            -
                return func(arg);
         
     | 
| 
       328 
     | 
    
         
            -
            }
         
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
            static ID
         
     | 
| 
       331 
     | 
    
         
            -
            make_temporary_id(size_t n)
         
     | 
| 
       332 
     | 
    
         
            -
            {
         
     | 
| 
       333 
     | 
    
         
            -
                return rb_make_temporary_id(n);
         
     | 
| 
       334 
     | 
    
         
            -
            }
         
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
            static int
         
     | 
| 
       337 
     | 
    
         
            -
            stderr_tty_p(void)
         
     | 
| 
       338 
     | 
    
         
            -
            {
         
     | 
| 
       339 
     | 
    
         
            -
                return rb_stderr_tty_p();
         
     | 
| 
       340 
     | 
    
         
            -
            }
         
     | 
| 
       341 
     | 
    
         
            -
             
     | 
| 
       342 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       343 
     | 
    
         
            -
            reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
         
     | 
| 
       344 
     | 
    
         
            -
            {
         
     | 
| 
       345 
     | 
    
         
            -
                 return rb_reg_compile(str, options, sourcefile, sourceline);
         
     | 
| 
       346 
     | 
    
         
            -
            }
         
     | 
| 
       347 
     | 
    
         
            -
             
     | 
| 
       348 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       349 
     | 
    
         
            -
            reg_check_preprocess(VALUE val)
         
     | 
| 
       350 
     | 
    
         
            -
            {
         
     | 
| 
       351 
     | 
    
         
            -
                return rb_reg_check_preprocess(val);
         
     | 
| 
       352 
     | 
    
         
            -
            }
         
     | 
| 
       353 
     | 
    
         
            -
            // End of Add for Kanayago
         
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
       355 
     | 
    
         
            -
            static const rb_parser_config_t rb_global_parser_config = {
         
     | 
| 
       356 
     | 
    
         
            -
                .malloc = ruby_xmalloc,
         
     | 
| 
       357 
     | 
    
         
            -
                .calloc = ruby_xcalloc,
         
     | 
| 
       358 
     | 
    
         
            -
                .realloc = ruby_xrealloc,
         
     | 
| 
       359 
     | 
    
         
            -
                .free = ruby_xfree,
         
     | 
| 
       360 
     | 
    
         
            -
                .alloc_n = ruby_xmalloc2,
         
     | 
| 
       361 
     | 
    
         
            -
                .alloc = ruby_xmalloc,
         
     | 
| 
       362 
     | 
    
         
            -
                .realloc_n = ruby_xrealloc2,
         
     | 
| 
       363 
     | 
    
         
            -
                .zalloc = zalloc,
         
     | 
| 
       364 
     | 
    
         
            -
                .rb_memmove = memmove2,
         
     | 
| 
       365 
     | 
    
         
            -
                .nonempty_memcpy = nonempty_memcpy,
         
     | 
| 
       366 
     | 
    
         
            -
                .xmalloc_mul_add = xmalloc_mul_add, // use xmalloc_mul_add for Kanayago
         
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
       368 
     | 
    
         
            -
                .compile_callback = suppress_tracing, // use suppress_tracing for Kanayago
         
     | 
| 
       369 
     | 
    
         
            -
                .reg_named_capture_assign = reg_named_capture_assign,
         
     | 
| 
       370 
     | 
    
         
            -
             
     | 
| 
       371 
     | 
    
         
            -
                .attr_get = rb_attr_get,
         
     | 
| 
       372 
     | 
    
         
            -
             
     | 
| 
       373 
     | 
    
         
            -
                .ary_new_from_args = rb_ary_new_from_args,
         
     | 
| 
       374 
     | 
    
         
            -
                .ary_unshift = rb_ary_unshift,
         
     | 
| 
       375 
     | 
    
         
            -
             
     | 
| 
       376 
     | 
    
         
            -
                .make_temporary_id = make_temporary_id, // use make_temporary_id for Kanayago
         
     | 
| 
       377 
     | 
    
         
            -
                .is_local_id = is_local_id2,
         
     | 
| 
       378 
     | 
    
         
            -
                .is_attrset_id = is_attrset_id2,
         
     | 
| 
       379 
     | 
    
         
            -
                .is_global_name_punct = is_global_name_punct,
         
     | 
| 
       380 
     | 
    
         
            -
                .id_type = id_type,
         
     | 
| 
       381 
     | 
    
         
            -
                .id_attrset = rb_id_attrset,
         
     | 
| 
       382 
     | 
    
         
            -
                .intern = rb_intern,
         
     | 
| 
       383 
     | 
    
         
            -
                .intern2 = rb_intern2,
         
     | 
| 
       384 
     | 
    
         
            -
                .intern3 = intern3,
         
     | 
| 
       385 
     | 
    
         
            -
                .intern_str = rb_intern_str,
         
     | 
| 
       386 
     | 
    
         
            -
                .is_notop_id = is_notop_id2,
         
     | 
| 
       387 
     | 
    
         
            -
                .enc_symname_type = enc_symname_type,
         
     | 
| 
       388 
     | 
    
         
            -
                .id2name = rb_id2name,
         
     | 
| 
       389 
     | 
    
         
            -
                .id2str = rb_id2str,
         
     | 
| 
       390 
     | 
    
         
            -
                .id2sym = rb_id2sym,
         
     | 
| 
       391 
     | 
    
         
            -
             
     | 
| 
       392 
     | 
    
         
            -
                .str_catf = rb_str_catf,
         
     | 
| 
       393 
     | 
    
         
            -
                .str_cat_cstr = rb_str_cat_cstr,
         
     | 
| 
       394 
     | 
    
         
            -
                .str_resize = rb_str_resize,
         
     | 
| 
       395 
     | 
    
         
            -
                .str_new = rb_str_new,
         
     | 
| 
       396 
     | 
    
         
            -
                .str_new_cstr = rb_str_new_cstr,
         
     | 
| 
       397 
     | 
    
         
            -
                .str_to_interned_str = rb_str_to_interned_str,
         
     | 
| 
       398 
     | 
    
         
            -
                .enc_str_new = enc_str_new,
         
     | 
| 
       399 
     | 
    
         
            -
                .str_vcatf = rb_str_vcatf,
         
     | 
| 
       400 
     | 
    
         
            -
                .rb_sprintf = rb_sprintf,
         
     | 
| 
       401 
     | 
    
         
            -
                .rstring_ptr = RSTRING_PTR,
         
     | 
| 
       402 
     | 
    
         
            -
                .rstring_len = RSTRING_LEN,
         
     | 
| 
       403 
     | 
    
         
            -
             
     | 
| 
       404 
     | 
    
         
            -
                .int2num = rb_int2num_inline,
         
     | 
| 
       405 
     | 
    
         
            -
             
     | 
| 
       406 
     | 
    
         
            -
                .stderr_tty_p = stderr_tty_p, //use stderr_tty_p for Kanayago
         
     | 
| 
       407 
     | 
    
         
            -
                .write_error_str = rb_write_error_str,
         
     | 
| 
       408 
     | 
    
         
            -
                .io_write = rb_io_write,
         
     | 
| 
       409 
     | 
    
         
            -
                .io_flush = rb_io_flush,
         
     | 
| 
       410 
     | 
    
         
            -
                .io_puts = rb_io_puts,
         
     | 
| 
       411 
     | 
    
         
            -
             
     | 
| 
       412 
     | 
    
         
            -
                .debug_output_stdout = rb_ractor_stdout,
         
     | 
| 
       413 
     | 
    
         
            -
                .debug_output_stderr = rb_ractor_stderr,
         
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
                .is_usascii_enc = is_usascii_enc,
         
     | 
| 
       416 
     | 
    
         
            -
                .enc_isalnum = enc_isalnum,
         
     | 
| 
       417 
     | 
    
         
            -
                .enc_precise_mbclen = enc_precise_mbclen,
         
     | 
| 
       418 
     | 
    
         
            -
                .mbclen_charfound_p = mbclen_charfound_p,
         
     | 
| 
       419 
     | 
    
         
            -
                .mbclen_charfound_len = mbclen_charfound_len,
         
     | 
| 
       420 
     | 
    
         
            -
                .enc_name = enc_name,
         
     | 
| 
       421 
     | 
    
         
            -
                .enc_prev_char = enc_prev_char,
         
     | 
| 
       422 
     | 
    
         
            -
                .enc_get = enc_get,
         
     | 
| 
       423 
     | 
    
         
            -
                .enc_asciicompat = enc_asciicompat,
         
     | 
| 
       424 
     | 
    
         
            -
                .utf8_encoding = utf8_encoding,
         
     | 
| 
       425 
     | 
    
         
            -
                .ascii8bit_encoding = ascii8bit_encoding,
         
     | 
| 
       426 
     | 
    
         
            -
                .enc_codelen = enc_codelen,
         
     | 
| 
       427 
     | 
    
         
            -
                .enc_mbcput = enc_mbcput,
         
     | 
| 
       428 
     | 
    
         
            -
                .enc_find_index = rb_enc_find_index,
         
     | 
| 
       429 
     | 
    
         
            -
                .enc_from_index = enc_from_index,
         
     | 
| 
       430 
     | 
    
         
            -
                .enc_isspace = enc_isspace,
         
     | 
| 
       431 
     | 
    
         
            -
                .enc_coderange_7bit = ENC_CODERANGE_7BIT,
         
     | 
| 
       432 
     | 
    
         
            -
                .enc_coderange_unknown = ENC_CODERANGE_UNKNOWN,
         
     | 
| 
       433 
     | 
    
         
            -
                .enc_mbminlen = enc_mbminlen,
         
     | 
| 
       434 
     | 
    
         
            -
                .enc_isascii = enc_isascii,
         
     | 
| 
       435 
     | 
    
         
            -
                .enc_mbc_to_codepoint = enc_mbc_to_codepoint,
         
     | 
| 
       436 
     | 
    
         
            -
             
     | 
| 
       437 
     | 
    
         
            -
                .local_defined = local_defined,
         
     | 
| 
       438 
     | 
    
         
            -
                .dvar_defined = dvar_defined,
         
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
                .syntax_error_append = syntax_error_append,
         
     | 
| 
       441 
     | 
    
         
            -
                .raise = rb_raise,
         
     | 
| 
       442 
     | 
    
         
            -
                .syntax_error_new = syntax_error_new,
         
     | 
| 
       443 
     | 
    
         
            -
             
     | 
| 
       444 
     | 
    
         
            -
                .errinfo = rb_errinfo,
         
     | 
| 
       445 
     | 
    
         
            -
                .set_errinfo = rb_set_errinfo,
         
     | 
| 
       446 
     | 
    
         
            -
                .make_exception = rb_make_exception,
         
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
       448 
     | 
    
         
            -
                .sized_xfree = ruby_sized_xfree,
         
     | 
| 
       449 
     | 
    
         
            -
                .sized_realloc_n = ruby_sized_realloc_n,
         
     | 
| 
       450 
     | 
    
         
            -
                .gc_guard = gc_guard,
         
     | 
| 
       451 
     | 
    
         
            -
                .gc_mark = rb_gc_mark,
         
     | 
| 
       452 
     | 
    
         
            -
             
     | 
| 
       453 
     | 
    
         
            -
                .reg_compile = reg_compile, // use reg_compile for Kanayago
         
     | 
| 
       454 
     | 
    
         
            -
                .reg_check_preprocess = reg_check_preprocess, // use reg_check_preprocess for Kanayago
         
     | 
| 
       455 
     | 
    
         
            -
                .memcicmp = rb_memcicmp,
         
     | 
| 
       456 
     | 
    
         
            -
             
     | 
| 
       457 
     | 
    
         
            -
                .compile_warn = rb_compile_warn,
         
     | 
| 
       458 
     | 
    
         
            -
                .compile_warning = rb_compile_warning,
         
     | 
| 
       459 
     | 
    
         
            -
                .bug = rb_bug,
         
     | 
| 
       460 
     | 
    
         
            -
                .fatal = rb_fatal,
         
     | 
| 
       461 
     | 
    
         
            -
                .verbose = ruby_verbose2,
         
     | 
| 
       462 
     | 
    
         
            -
                .errno_ptr = rb_errno_ptr2,
         
     | 
| 
       463 
     | 
    
         
            -
             
     | 
| 
       464 
     | 
    
         
            -
                .make_backtrace = rb_make_backtrace,
         
     | 
| 
       465 
     | 
    
         
            -
             
     | 
| 
       466 
     | 
    
         
            -
                .scan_hex = ruby_scan_hex,
         
     | 
| 
       467 
     | 
    
         
            -
                .scan_oct = ruby_scan_oct,
         
     | 
| 
       468 
     | 
    
         
            -
                .scan_digits = ruby_scan_digits,
         
     | 
| 
       469 
     | 
    
         
            -
                .strtod = ruby_strtod,
         
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
       471 
     | 
    
         
            -
                .rtest = rtest,
         
     | 
| 
       472 
     | 
    
         
            -
                .nil_p = nil_p,
         
     | 
| 
       473 
     | 
    
         
            -
                .qnil = Qnil,
         
     | 
| 
       474 
     | 
    
         
            -
                .qfalse = Qfalse,
         
     | 
| 
       475 
     | 
    
         
            -
                .eArgError = arg_error,
         
     | 
| 
       476 
     | 
    
         
            -
                .long2int = rb_long2int,
         
     | 
| 
       477 
     | 
    
         
            -
             
     | 
| 
       478 
     | 
    
         
            -
                /* For Ripper */
         
     | 
| 
       479 
     | 
    
         
            -
                .static_id2sym = static_id2sym,
         
     | 
| 
       480 
     | 
    
         
            -
                .str_coderange_scan_restartable = str_coderange_scan_restartable,
         
     | 
| 
       481 
     | 
    
         
            -
            };
         
     | 
| 
       482 
     | 
    
         
            -
            #endif
         
     | 
| 
       483 
     | 
    
         
            -
             
     | 
| 
       484 
     | 
    
         
            -
            static void
         
     | 
| 
       485 
     | 
    
         
            -
            parser_mark(void *ptr)
         
     | 
| 
       486 
     | 
    
         
            -
            {
         
     | 
| 
       487 
     | 
    
         
            -
                struct ruby_parser *parser = (struct ruby_parser*)ptr;
         
     | 
| 
       488 
     | 
    
         
            -
                rb_ruby_parser_mark(parser->parser_params);
         
     | 
| 
       489 
     | 
    
         
            -
             
     | 
| 
       490 
     | 
    
         
            -
                switch (parser->type) {
         
     | 
| 
       491 
     | 
    
         
            -
                  case lex_type_str:
         
     | 
| 
       492 
     | 
    
         
            -
                    rb_gc_mark(parser->data.lex_str.str);
         
     | 
| 
       493 
     | 
    
         
            -
                    break;
         
     | 
| 
       494 
     | 
    
         
            -
                  case lex_type_io:
         
     | 
| 
       495 
     | 
    
         
            -
                    rb_gc_mark(parser->data.lex_io.file);
         
     | 
| 
       496 
     | 
    
         
            -
                    break;
         
     | 
| 
       497 
     | 
    
         
            -
                  case lex_type_array:
         
     | 
| 
       498 
     | 
    
         
            -
                    rb_gc_mark(parser->data.lex_array.ary);
         
     | 
| 
       499 
     | 
    
         
            -
                    break;
         
     | 
| 
       500 
     | 
    
         
            -
                  case lex_type_generic:
         
     | 
| 
       501 
     | 
    
         
            -
                    /* noop. Caller of rb_parser_compile_generic should mark the objects. */
         
     | 
| 
       502 
     | 
    
         
            -
                    break;
         
     | 
| 
       503 
     | 
    
         
            -
                }
         
     | 
| 
       504 
     | 
    
         
            -
            }
         
     | 
| 
       505 
     | 
    
         
            -
             
     | 
| 
       506 
     | 
    
         
            -
            static void
         
     | 
| 
       507 
     | 
    
         
            -
            parser_free(void *ptr)
         
     | 
| 
       508 
     | 
    
         
            -
            {
         
     | 
| 
       509 
     | 
    
         
            -
                struct ruby_parser *parser = (struct ruby_parser*)ptr;
         
     | 
| 
       510 
     | 
    
         
            -
                rb_ruby_parser_free(parser->parser_params);
         
     | 
| 
       511 
     | 
    
         
            -
                xfree(parser);
         
     | 
| 
       512 
     | 
    
         
            -
            }
         
     | 
| 
       513 
     | 
    
         
            -
             
     | 
| 
       514 
     | 
    
         
            -
            static size_t
         
     | 
| 
       515 
     | 
    
         
            -
            parser_memsize(const void *ptr)
         
     | 
| 
       516 
     | 
    
         
            -
            {
         
     | 
| 
       517 
     | 
    
         
            -
                struct ruby_parser *parser = (struct ruby_parser*)ptr;
         
     | 
| 
       518 
     | 
    
         
            -
                return rb_ruby_parser_memsize(parser->parser_params);
         
     | 
| 
       519 
     | 
    
         
            -
            }
         
     | 
| 
       520 
     | 
    
         
            -
             
     | 
| 
       521 
     | 
    
         
            -
            // Not static const for Kanayago
         
     | 
| 
       522 
     | 
    
         
            -
            const rb_data_type_t ruby_parser_data_type = {
         
     | 
| 
       523 
     | 
    
         
            -
                "parser",
         
     | 
| 
       524 
     | 
    
         
            -
                {
         
     | 
| 
       525 
     | 
    
         
            -
                    parser_mark,
         
     | 
| 
       526 
     | 
    
         
            -
                    parser_free,
         
     | 
| 
       527 
     | 
    
         
            -
                    parser_memsize,
         
     | 
| 
       528 
     | 
    
         
            -
                },
         
     | 
| 
       529 
     | 
    
         
            -
                0, 0, RUBY_TYPED_FREE_IMMEDIATELY
         
     | 
| 
       530 
     | 
    
         
            -
            };
         
     | 
| 
       531 
     | 
    
         
            -
             
     | 
| 
       532 
     | 
    
         
            -
            #ifdef UNIVERSAL_PARSER
         
     | 
| 
       533 
     | 
    
         
            -
            const rb_parser_config_t *
         
     | 
| 
       534 
     | 
    
         
            -
            rb_ruby_parser_config(void)
         
     | 
| 
       535 
     | 
    
         
            -
            {
         
     | 
| 
       536 
     | 
    
         
            -
                return &rb_global_parser_config;
         
     | 
| 
       537 
     | 
    
         
            -
            }
         
     | 
| 
       538 
     | 
    
         
            -
             
     | 
| 
       539 
     | 
    
         
            -
            rb_parser_t *
         
     | 
| 
       540 
     | 
    
         
            -
            rb_parser_params_new(void)
         
     | 
| 
       541 
     | 
    
         
            -
            {
         
     | 
| 
       542 
     | 
    
         
            -
                return rb_ruby_parser_new(&rb_global_parser_config);
         
     | 
| 
       543 
     | 
    
         
            -
            }
         
     | 
| 
       544 
     | 
    
         
            -
            #else
         
     | 
| 
       545 
     | 
    
         
            -
            rb_parser_t *
         
     | 
| 
       546 
     | 
    
         
            -
            rb_parser_params_new(void)
         
     | 
| 
       547 
     | 
    
         
            -
            {
         
     | 
| 
       548 
     | 
    
         
            -
                return rb_ruby_parser_new();
         
     | 
| 
       549 
     | 
    
         
            -
            }
         
     | 
| 
       550 
     | 
    
         
            -
            #endif /* UNIVERSAL_PARSER */
         
     | 
| 
       551 
     | 
    
         
            -
             
     | 
| 
       552 
     | 
    
         
            -
            VALUE
         
     | 
| 
       553 
     | 
    
         
            -
            rb_parser_new(void)
         
     | 
| 
       554 
     | 
    
         
            -
            {
         
     | 
| 
       555 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       556 
     | 
    
         
            -
                rb_parser_t *parser_params;
         
     | 
| 
       557 
     | 
    
         
            -
             
     | 
| 
       558 
     | 
    
         
            -
                /*
         
     | 
| 
       559 
     | 
    
         
            -
                 * Create parser_params ahead of vparser because
         
     | 
| 
       560 
     | 
    
         
            -
                 * rb_ruby_parser_new can run GC so if create vparser
         
     | 
| 
       561 
     | 
    
         
            -
                 * first, parser_mark tries to mark not initialized parser_params.
         
     | 
| 
       562 
     | 
    
         
            -
                 */
         
     | 
| 
       563 
     | 
    
         
            -
                parser_params = rb_parser_params_new();
         
     | 
| 
       564 
     | 
    
         
            -
                VALUE vparser = TypedData_Make_Struct(0, struct ruby_parser,
         
     | 
| 
       565 
     | 
    
         
            -
                                                     &ruby_parser_data_type, parser);
         
     | 
| 
       566 
     | 
    
         
            -
                parser->parser_params = parser_params;
         
     | 
| 
       567 
     | 
    
         
            -
             
     | 
| 
       568 
     | 
    
         
            -
                return vparser;
         
     | 
| 
       569 
     | 
    
         
            -
            }
         
     | 
| 
       570 
     | 
    
         
            -
             
     | 
| 
       571 
     | 
    
         
            -
            void
         
     | 
| 
       572 
     | 
    
         
            -
            rb_parser_set_options(VALUE vparser, int print, int loop, int chomp, int split)
         
     | 
| 
       573 
     | 
    
         
            -
            {
         
     | 
| 
       574 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       575 
     | 
    
         
            -
             
     | 
| 
       576 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       577 
     | 
    
         
            -
                rb_ruby_parser_set_options(parser->parser_params, print, loop, chomp, split);
         
     | 
| 
       578 
     | 
    
         
            -
            }
         
     | 
| 
       579 
     | 
    
         
            -
             
     | 
| 
       580 
     | 
    
         
            -
            VALUE
         
     | 
| 
       581 
     | 
    
         
            -
            rb_parser_set_context(VALUE vparser, const struct rb_iseq_struct *base, int main)
         
     | 
| 
       582 
     | 
    
         
            -
            {
         
     | 
| 
       583 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       584 
     | 
    
         
            -
             
     | 
| 
       585 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       586 
     | 
    
         
            -
                rb_ruby_parser_set_context(parser->parser_params, base, main);
         
     | 
| 
       587 
     | 
    
         
            -
                return vparser;
         
     | 
| 
       588 
     | 
    
         
            -
            }
         
     | 
| 
       589 
     | 
    
         
            -
             
     | 
| 
       590 
     | 
    
         
            -
            void
         
     | 
| 
       591 
     | 
    
         
            -
            rb_parser_set_script_lines(VALUE vparser)
         
     | 
| 
       592 
     | 
    
         
            -
            {
         
     | 
| 
       593 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       594 
     | 
    
         
            -
             
     | 
| 
       595 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       596 
     | 
    
         
            -
                rb_ruby_parser_set_script_lines(parser->parser_params);
         
     | 
| 
       597 
     | 
    
         
            -
            }
         
     | 
| 
       598 
     | 
    
         
            -
             
     | 
| 
       599 
     | 
    
         
            -
            void
         
     | 
| 
       600 
     | 
    
         
            -
            rb_parser_error_tolerant(VALUE vparser)
         
     | 
| 
       601 
     | 
    
         
            -
            {
         
     | 
| 
       602 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       603 
     | 
    
         
            -
             
     | 
| 
       604 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       605 
     | 
    
         
            -
                rb_ruby_parser_error_tolerant(parser->parser_params);
         
     | 
| 
       606 
     | 
    
         
            -
            }
         
     | 
| 
       607 
     | 
    
         
            -
             
     | 
| 
       608 
     | 
    
         
            -
            void
         
     | 
| 
       609 
     | 
    
         
            -
            rb_parser_keep_tokens(VALUE vparser)
         
     | 
| 
       610 
     | 
    
         
            -
            {
         
     | 
| 
       611 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       612 
     | 
    
         
            -
             
     | 
| 
       613 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       614 
     | 
    
         
            -
                rb_ruby_parser_keep_tokens(parser->parser_params);
         
     | 
| 
       615 
     | 
    
         
            -
            }
         
     | 
| 
       616 
     | 
    
         
            -
             
     | 
| 
       617 
     | 
    
         
            -
            rb_parser_string_t *
         
     | 
| 
       618 
     | 
    
         
            -
            rb_parser_lex_get_str(struct parser_params *p, struct lex_pointer_string *ptr_str)
         
     | 
| 
       619 
     | 
    
         
            -
            {
         
     | 
| 
       620 
     | 
    
         
            -
                char *beg, *end, *start;
         
     | 
| 
       621 
     | 
    
         
            -
                long len;
         
     | 
| 
       622 
     | 
    
         
            -
                VALUE s = ptr_str->str;
         
     | 
| 
       623 
     | 
    
         
            -
             
     | 
| 
       624 
     | 
    
         
            -
                beg = RSTRING_PTR(s);
         
     | 
| 
       625 
     | 
    
         
            -
                len = RSTRING_LEN(s);
         
     | 
| 
       626 
     | 
    
         
            -
                start = beg;
         
     | 
| 
       627 
     | 
    
         
            -
                if (ptr_str->ptr) {
         
     | 
| 
       628 
     | 
    
         
            -
                    if (len == ptr_str->ptr) return 0;
         
     | 
| 
       629 
     | 
    
         
            -
                    beg += ptr_str->ptr;
         
     | 
| 
       630 
     | 
    
         
            -
                    len -= ptr_str->ptr;
         
     | 
| 
       631 
     | 
    
         
            -
                }
         
     | 
| 
       632 
     | 
    
         
            -
                end = memchr(beg, '\n', len);
         
     | 
| 
       633 
     | 
    
         
            -
                if (end) len = ++end - beg;
         
     | 
| 
       634 
     | 
    
         
            -
                ptr_str->ptr += len;
         
     | 
| 
       635 
     | 
    
         
            -
                return rb_str_to_parser_string(p, rb_str_subseq(s, beg - start, len));
         
     | 
| 
       636 
     | 
    
         
            -
            }
         
     | 
| 
       637 
     | 
    
         
            -
             
     | 
| 
       638 
     | 
    
         
            -
            static rb_parser_string_t *
         
     | 
| 
       639 
     | 
    
         
            -
            lex_get_str(struct parser_params *p, rb_parser_input_data input, int line_count)
         
     | 
| 
       640 
     | 
    
         
            -
            {
         
     | 
| 
       641 
     | 
    
         
            -
                return rb_parser_lex_get_str(p, (struct lex_pointer_string *)input);
         
     | 
| 
       642 
     | 
    
         
            -
            }
         
     | 
| 
       643 
     | 
    
         
            -
             
     | 
| 
       644 
     | 
    
         
            -
            static void parser_aset_script_lines_for(VALUE path, rb_parser_ary_t *lines);
         
     | 
| 
       645 
     | 
    
         
            -
             
     | 
| 
       646 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       647 
     | 
    
         
            -
            parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, VALUE fname, rb_parser_input_data input, int line)
         
     | 
| 
       648 
     | 
    
         
            -
            {
         
     | 
| 
       649 
     | 
    
         
            -
                rb_ast_t *ast = rb_parser_compile(p, gets, fname, input, line);
         
     | 
| 
       650 
     | 
    
         
            -
                parser_aset_script_lines_for(fname, ast->body.script_lines);
         
     | 
| 
       651 
     | 
    
         
            -
                return ast;
         
     | 
| 
       652 
     | 
    
         
            -
            }
         
     | 
| 
       653 
     | 
    
         
            -
             
     | 
| 
       654 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       655 
     | 
    
         
            -
            parser_compile_string0(struct ruby_parser *parser, VALUE fname, VALUE s, int line)
         
     | 
| 
       656 
     | 
    
         
            -
            {
         
     | 
| 
       657 
     | 
    
         
            -
                VALUE str = rb_str_new_frozen(s);
         
     | 
| 
       658 
     | 
    
         
            -
             
     | 
| 
       659 
     | 
    
         
            -
                parser->type = lex_type_str;
         
     | 
| 
       660 
     | 
    
         
            -
                parser->data.lex_str.str = str;
         
     | 
| 
       661 
     | 
    
         
            -
                parser->data.lex_str.ptr = 0;
         
     | 
| 
       662 
     | 
    
         
            -
             
     | 
| 
       663 
     | 
    
         
            -
                return parser_compile(parser->parser_params, lex_get_str, fname, (rb_parser_input_data)&parser->data, line);
         
     | 
| 
       664 
     | 
    
         
            -
            }
         
     | 
| 
       665 
     | 
    
         
            -
             
     | 
| 
       666 
     | 
    
         
            -
            static rb_encoding *
         
     | 
| 
       667 
     | 
    
         
            -
            must_be_ascii_compatible(VALUE s)
         
     | 
| 
       668 
     | 
    
         
            -
            {
         
     | 
| 
       669 
     | 
    
         
            -
                rb_encoding *enc = rb_enc_get(s);
         
     | 
| 
       670 
     | 
    
         
            -
                if (!rb_enc_asciicompat(enc)) {
         
     | 
| 
       671 
     | 
    
         
            -
                    rb_raise(rb_eArgError, "invalid source encoding");
         
     | 
| 
       672 
     | 
    
         
            -
                }
         
     | 
| 
       673 
     | 
    
         
            -
                return enc;
         
     | 
| 
       674 
     | 
    
         
            -
            }
         
     | 
| 
       675 
     | 
    
         
            -
             
     | 
| 
       676 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       677 
     | 
    
         
            -
            parser_compile_string_path(struct ruby_parser *parser, VALUE f, VALUE s, int line)
         
     | 
| 
       678 
     | 
    
         
            -
            {
         
     | 
| 
       679 
     | 
    
         
            -
                must_be_ascii_compatible(s);
         
     | 
| 
       680 
     | 
    
         
            -
                return parser_compile_string0(parser, f, s, line);
         
     | 
| 
       681 
     | 
    
         
            -
            }
         
     | 
| 
       682 
     | 
    
         
            -
             
     | 
| 
       683 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       684 
     | 
    
         
            -
            parser_compile_string(struct ruby_parser *parser, const char *f, VALUE s, int line)
         
     | 
| 
       685 
     | 
    
         
            -
            {
         
     | 
| 
       686 
     | 
    
         
            -
                return parser_compile_string_path(parser, rb_filesystem_str_new_cstr(f), s, line);
         
     | 
| 
       687 
     | 
    
         
            -
            }
         
     | 
| 
       688 
     | 
    
         
            -
             
     | 
| 
       689 
     | 
    
         
            -
            VALUE rb_io_gets_internal(VALUE io);
         
     | 
| 
       690 
     | 
    
         
            -
             
     | 
| 
       691 
     | 
    
         
            -
            static rb_parser_string_t *
         
     | 
| 
       692 
     | 
    
         
            -
            lex_io_gets(struct parser_params *p, rb_parser_input_data input, int line_count)
         
     | 
| 
       693 
     | 
    
         
            -
            {
         
     | 
| 
       694 
     | 
    
         
            -
                VALUE io = (VALUE)input;
         
     | 
| 
       695 
     | 
    
         
            -
                VALUE line = rb_io_gets_internal(io);
         
     | 
| 
       696 
     | 
    
         
            -
                if (NIL_P(line)) return 0;
         
     | 
| 
       697 
     | 
    
         
            -
                return rb_str_to_parser_string(p, line);
         
     | 
| 
       698 
     | 
    
         
            -
            }
         
     | 
| 
       699 
     | 
    
         
            -
             
     | 
| 
       700 
     | 
    
         
            -
            static rb_parser_string_t *
         
     | 
| 
       701 
     | 
    
         
            -
            lex_gets_array(struct parser_params *p, rb_parser_input_data data, int index)
         
     | 
| 
       702 
     | 
    
         
            -
            {
         
     | 
| 
       703 
     | 
    
         
            -
                VALUE array = (VALUE)data;
         
     | 
| 
       704 
     | 
    
         
            -
                VALUE str = rb_ary_entry(array, index);
         
     | 
| 
       705 
     | 
    
         
            -
                if (!NIL_P(str)) {
         
     | 
| 
       706 
     | 
    
         
            -
                    StringValue(str);
         
     | 
| 
       707 
     | 
    
         
            -
                    if (!rb_enc_asciicompat(rb_enc_get(str))) {
         
     | 
| 
       708 
     | 
    
         
            -
                        rb_raise(rb_eArgError, "invalid source encoding");
         
     | 
| 
       709 
     | 
    
         
            -
                    }
         
     | 
| 
       710 
     | 
    
         
            -
                    return rb_str_to_parser_string(p, str);
         
     | 
| 
       711 
     | 
    
         
            -
                }
         
     | 
| 
       712 
     | 
    
         
            -
                else {
         
     | 
| 
       713 
     | 
    
         
            -
                    return 0;
         
     | 
| 
       714 
     | 
    
         
            -
                }
         
     | 
| 
       715 
     | 
    
         
            -
            }
         
     | 
| 
       716 
     | 
    
         
            -
             
     | 
| 
       717 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       718 
     | 
    
         
            -
            parser_compile_file_path(struct ruby_parser *parser, VALUE fname, VALUE file, int start)
         
     | 
| 
       719 
     | 
    
         
            -
            {
         
     | 
| 
       720 
     | 
    
         
            -
                parser->type = lex_type_io;
         
     | 
| 
       721 
     | 
    
         
            -
                parser->data.lex_io.file = file;
         
     | 
| 
       722 
     | 
    
         
            -
             
     | 
| 
       723 
     | 
    
         
            -
                return parser_compile(parser->parser_params, lex_io_gets, fname, (rb_parser_input_data)file, start);
         
     | 
| 
       724 
     | 
    
         
            -
            }
         
     | 
| 
       725 
     | 
    
         
            -
             
     | 
| 
       726 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       727 
     | 
    
         
            -
            parser_compile_array(struct ruby_parser *parser, VALUE fname, VALUE array, int start)
         
     | 
| 
       728 
     | 
    
         
            -
            {
         
     | 
| 
       729 
     | 
    
         
            -
                parser->type = lex_type_array;
         
     | 
| 
       730 
     | 
    
         
            -
                parser->data.lex_array.ary = array;
         
     | 
| 
       731 
     | 
    
         
            -
             
     | 
| 
       732 
     | 
    
         
            -
                return parser_compile(parser->parser_params, lex_gets_array, fname, (rb_parser_input_data)array, start);
         
     | 
| 
       733 
     | 
    
         
            -
            }
         
     | 
| 
       734 
     | 
    
         
            -
             
     | 
| 
       735 
     | 
    
         
            -
            static rb_ast_t*
         
     | 
| 
       736 
     | 
    
         
            -
            parser_compile_generic(struct ruby_parser *parser, rb_parser_lex_gets_func *lex_gets, VALUE fname, VALUE input, int start)
         
     | 
| 
       737 
     | 
    
         
            -
            {
         
     | 
| 
       738 
     | 
    
         
            -
                parser->type = lex_type_generic;
         
     | 
| 
       739 
     | 
    
         
            -
             
     | 
| 
       740 
     | 
    
         
            -
                return parser_compile(parser->parser_params, lex_gets, fname, (rb_parser_input_data)input, start);
         
     | 
| 
       741 
     | 
    
         
            -
            }
         
     | 
| 
       742 
     | 
    
         
            -
             
     | 
| 
       743 
     | 
    
         
            -
            static void
         
     | 
| 
       744 
     | 
    
         
            -
            ast_free(void *ptr)
         
     | 
| 
       745 
     | 
    
         
            -
            {
         
     | 
| 
       746 
     | 
    
         
            -
                rb_ast_t *ast = (rb_ast_t *)ptr;
         
     | 
| 
       747 
     | 
    
         
            -
                rb_ast_free(ast);
         
     | 
| 
       748 
     | 
    
         
            -
            }
         
     | 
| 
       749 
     | 
    
         
            -
             
     | 
| 
       750 
     | 
    
         
            -
            static const rb_data_type_t ast_data_type = {
         
     | 
| 
       751 
     | 
    
         
            -
                "AST",
         
     | 
| 
       752 
     | 
    
         
            -
                {
         
     | 
| 
       753 
     | 
    
         
            -
                    NULL,
         
     | 
| 
       754 
     | 
    
         
            -
                    ast_free,
         
     | 
| 
       755 
     | 
    
         
            -
                    NULL, // No dsize() because this object does not appear in ObjectSpace.
         
     | 
| 
       756 
     | 
    
         
            -
                },
         
     | 
| 
       757 
     | 
    
         
            -
                0, 0, RUBY_TYPED_FREE_IMMEDIATELY
         
     | 
| 
       758 
     | 
    
         
            -
            };
         
     | 
| 
       759 
     | 
    
         
            -
             
     | 
| 
       760 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       761 
     | 
    
         
            -
            ast_alloc(void)
         
     | 
| 
       762 
     | 
    
         
            -
            {
         
     | 
| 
       763 
     | 
    
         
            -
                return TypedData_Wrap_Struct(0, &ast_data_type, NULL);
         
     | 
| 
       764 
     | 
    
         
            -
            }
         
     | 
| 
       765 
     | 
    
         
            -
             
     | 
| 
       766 
     | 
    
         
            -
            VALUE
         
     | 
| 
       767 
     | 
    
         
            -
            rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE file, int start)
         
     | 
| 
       768 
     | 
    
         
            -
            {
         
     | 
| 
       769 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       770 
     | 
    
         
            -
                VALUE ast_value = ast_alloc();
         
     | 
| 
       771 
     | 
    
         
            -
             
     | 
| 
       772 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       773 
     | 
    
         
            -
                DATA_PTR(ast_value) = parser_compile_file_path(parser, fname, file, start);
         
     | 
| 
       774 
     | 
    
         
            -
                RB_GC_GUARD(vparser);
         
     | 
| 
       775 
     | 
    
         
            -
             
     | 
| 
       776 
     | 
    
         
            -
                return ast_value;
         
     | 
| 
       777 
     | 
    
         
            -
            }
         
     | 
| 
       778 
     | 
    
         
            -
             
     | 
| 
       779 
     | 
    
         
            -
            VALUE
         
     | 
| 
       780 
     | 
    
         
            -
            rb_parser_compile_array(VALUE vparser, VALUE fname, VALUE array, int start)
         
     | 
| 
       781 
     | 
    
         
            -
            {
         
     | 
| 
       782 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       783 
     | 
    
         
            -
                VALUE ast_value = ast_alloc();
         
     | 
| 
       784 
     | 
    
         
            -
             
     | 
| 
       785 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       786 
     | 
    
         
            -
                DATA_PTR(ast_value) = parser_compile_array(parser, fname, array, start);
         
     | 
| 
       787 
     | 
    
         
            -
                RB_GC_GUARD(vparser);
         
     | 
| 
       788 
     | 
    
         
            -
             
     | 
| 
       789 
     | 
    
         
            -
                return ast_value;
         
     | 
| 
       790 
     | 
    
         
            -
            }
         
     | 
| 
       791 
     | 
    
         
            -
             
     | 
| 
       792 
     | 
    
         
            -
            VALUE
         
     | 
| 
       793 
     | 
    
         
            -
            rb_parser_compile_generic(VALUE vparser, rb_parser_lex_gets_func *lex_gets, VALUE fname, VALUE input, int start)
         
     | 
| 
       794 
     | 
    
         
            -
            {
         
     | 
| 
       795 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       796 
     | 
    
         
            -
                VALUE ast_value = ast_alloc();
         
     | 
| 
       797 
     | 
    
         
            -
             
     | 
| 
       798 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       799 
     | 
    
         
            -
                DATA_PTR(ast_value) = parser_compile_generic(parser, lex_gets, fname, input, start);
         
     | 
| 
       800 
     | 
    
         
            -
                RB_GC_GUARD(vparser);
         
     | 
| 
       801 
     | 
    
         
            -
             
     | 
| 
       802 
     | 
    
         
            -
                return ast_value;
         
     | 
| 
       803 
     | 
    
         
            -
            }
         
     | 
| 
       804 
     | 
    
         
            -
             
     | 
| 
       805 
     | 
    
         
            -
            VALUE
         
     | 
| 
       806 
     | 
    
         
            -
            rb_parser_compile_string(VALUE vparser, const char *f, VALUE s, int line)
         
     | 
| 
       807 
     | 
    
         
            -
            {
         
     | 
| 
       808 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       809 
     | 
    
         
            -
                VALUE ast_value = ast_alloc();
         
     | 
| 
       810 
     | 
    
         
            -
             
     | 
| 
       811 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       812 
     | 
    
         
            -
                DATA_PTR(ast_value) = parser_compile_string(parser, f, s, line);
         
     | 
| 
       813 
     | 
    
         
            -
                RB_GC_GUARD(vparser);
         
     | 
| 
       814 
     | 
    
         
            -
             
     | 
| 
       815 
     | 
    
         
            -
                return ast_value;
         
     | 
| 
       816 
     | 
    
         
            -
            }
         
     | 
| 
       817 
     | 
    
         
            -
             
     | 
| 
       818 
     | 
    
         
            -
            VALUE
         
     | 
| 
       819 
     | 
    
         
            -
            rb_parser_compile_string_path(VALUE vparser, VALUE f, VALUE s, int line)
         
     | 
| 
       820 
     | 
    
         
            -
            {
         
     | 
| 
       821 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       822 
     | 
    
         
            -
                VALUE ast_value = ast_alloc();
         
     | 
| 
       823 
     | 
    
         
            -
             
     | 
| 
       824 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       825 
     | 
    
         
            -
                DATA_PTR(ast_value) = parser_compile_string_path(parser, f, s, line);
         
     | 
| 
       826 
     | 
    
         
            -
                RB_GC_GUARD(vparser);
         
     | 
| 
       827 
     | 
    
         
            -
             
     | 
| 
       828 
     | 
    
         
            -
                return ast_value;
         
     | 
| 
       829 
     | 
    
         
            -
            }
         
     | 
| 
       830 
     | 
    
         
            -
             
     | 
| 
       831 
     | 
    
         
            -
            VALUE
         
     | 
| 
       832 
     | 
    
         
            -
            rb_parser_encoding(VALUE vparser)
         
     | 
| 
       833 
     | 
    
         
            -
            {
         
     | 
| 
       834 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       835 
     | 
    
         
            -
             
     | 
| 
       836 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       837 
     | 
    
         
            -
                return rb_enc_from_encoding(rb_ruby_parser_encoding(parser->parser_params));
         
     | 
| 
       838 
     | 
    
         
            -
            }
         
     | 
| 
       839 
     | 
    
         
            -
             
     | 
| 
       840 
     | 
    
         
            -
            VALUE
         
     | 
| 
       841 
     | 
    
         
            -
            rb_parser_end_seen_p(VALUE vparser)
         
     | 
| 
       842 
     | 
    
         
            -
            {
         
     | 
| 
       843 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       844 
     | 
    
         
            -
             
     | 
| 
       845 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       846 
     | 
    
         
            -
                return RBOOL(rb_ruby_parser_end_seen_p(parser->parser_params));
         
     | 
| 
       847 
     | 
    
         
            -
            }
         
     | 
| 
       848 
     | 
    
         
            -
             
     | 
| 
       849 
     | 
    
         
            -
            VALUE
         
     | 
| 
       850 
     | 
    
         
            -
            rb_parser_set_yydebug(VALUE vparser, VALUE flag)
         
     | 
| 
       851 
     | 
    
         
            -
            {
         
     | 
| 
       852 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       853 
     | 
    
         
            -
             
     | 
| 
       854 
     | 
    
         
            -
                TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       855 
     | 
    
         
            -
                rb_ruby_parser_set_yydebug(parser->parser_params, RTEST(flag));
         
     | 
| 
       856 
     | 
    
         
            -
                return flag;
         
     | 
| 
       857 
     | 
    
         
            -
            }
         
     | 
| 
       858 
     | 
    
         
            -
             
     | 
| 
       859 
     | 
    
         
            -
            void
         
     | 
| 
       860 
     | 
    
         
            -
            rb_set_script_lines_for(VALUE vparser, VALUE path)
         
     | 
| 
       861 
     | 
    
         
            -
            {
         
     | 
| 
       862 
     | 
    
         
            -
                struct ruby_parser *parser;
         
     | 
| 
       863 
     | 
    
         
            -
                VALUE hash;
         
     | 
| 
       864 
     | 
    
         
            -
                ID script_lines;
         
     | 
| 
       865 
     | 
    
         
            -
                CONST_ID(script_lines, "SCRIPT_LINES__");
         
     | 
| 
       866 
     | 
    
         
            -
                if (!rb_const_defined_at(rb_cObject, script_lines)) return;
         
     | 
| 
       867 
     | 
    
         
            -
                hash = rb_const_get_at(rb_cObject, script_lines);
         
     | 
| 
       868 
     | 
    
         
            -
                if (RB_TYPE_P(hash, T_HASH)) {
         
     | 
| 
       869 
     | 
    
         
            -
                    rb_hash_aset(hash, path, Qtrue);
         
     | 
| 
       870 
     | 
    
         
            -
                    TypedData_Get_Struct(vparser, struct ruby_parser, &ruby_parser_data_type, parser);
         
     | 
| 
       871 
     | 
    
         
            -
                    rb_ruby_parser_set_script_lines(parser->parser_params);
         
     | 
| 
       872 
     | 
    
         
            -
                }
         
     | 
| 
       873 
     | 
    
         
            -
            }
         
     | 
| 
       874 
     | 
    
         
            -
             
     | 
| 
       875 
     | 
    
         
            -
            VALUE
         
     | 
| 
       876 
     | 
    
         
            -
            rb_parser_build_script_lines_from(rb_parser_ary_t *lines)
         
     | 
| 
       877 
     | 
    
         
            -
            {
         
     | 
| 
       878 
     | 
    
         
            -
                int i;
         
     | 
| 
       879 
     | 
    
         
            -
                if (!lines) return Qnil;
         
     | 
| 
       880 
     | 
    
         
            -
                if (lines->data_type != PARSER_ARY_DATA_SCRIPT_LINE) {
         
     | 
| 
       881 
     | 
    
         
            -
                    rb_bug("unexpected rb_parser_ary_data_type (%d) for script lines", lines->data_type);
         
     | 
| 
       882 
     | 
    
         
            -
                }
         
     | 
| 
       883 
     | 
    
         
            -
                VALUE script_lines = rb_ary_new_capa(lines->len);
         
     | 
| 
       884 
     | 
    
         
            -
                for (i = 0; i < lines->len; i++) {
         
     | 
| 
       885 
     | 
    
         
            -
                    rb_parser_string_t *str = (rb_parser_string_t *)lines->data[i];
         
     | 
| 
       886 
     | 
    
         
            -
                    rb_ary_push(script_lines, rb_enc_str_new(str->ptr, str->len, str->enc));
         
     | 
| 
       887 
     | 
    
         
            -
                }
         
     | 
| 
       888 
     | 
    
         
            -
                return script_lines;
         
     | 
| 
       889 
     | 
    
         
            -
            }
         
     | 
| 
       890 
     | 
    
         
            -
             
     | 
| 
       891 
     | 
    
         
            -
            VALUE
         
     | 
| 
       892 
     | 
    
         
            -
            rb_str_new_parser_string(rb_parser_string_t *str)
         
     | 
| 
       893 
     | 
    
         
            -
            {
         
     | 
| 
       894 
     | 
    
         
            -
                VALUE string = rb_enc_literal_str(str->ptr, str->len, str->enc);
         
     | 
| 
       895 
     | 
    
         
            -
                rb_enc_str_coderange(string);
         
     | 
| 
       896 
     | 
    
         
            -
                return string;
         
     | 
| 
       897 
     | 
    
         
            -
            }
         
     | 
| 
       898 
     | 
    
         
            -
             
     | 
| 
       899 
     | 
    
         
            -
            VALUE
         
     | 
| 
       900 
     | 
    
         
            -
            rb_str_new_mutable_parser_string(rb_parser_string_t *str)
         
     | 
| 
       901 
     | 
    
         
            -
            {
         
     | 
| 
       902 
     | 
    
         
            -
                return rb_enc_str_new(str->ptr, str->len, str->enc);
         
     | 
| 
       903 
     | 
    
         
            -
            }
         
     | 
| 
       904 
     | 
    
         
            -
             
     | 
| 
       905 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       906 
     | 
    
         
            -
            negative_numeric(VALUE val)
         
     | 
| 
       907 
     | 
    
         
            -
            {
         
     | 
| 
       908 
     | 
    
         
            -
                if (FIXNUM_P(val)) {
         
     | 
| 
       909 
     | 
    
         
            -
                    return LONG2FIX(-FIX2LONG(val));
         
     | 
| 
       910 
     | 
    
         
            -
                }
         
     | 
| 
       911 
     | 
    
         
            -
                if (SPECIAL_CONST_P(val)) {
         
     | 
| 
       912 
     | 
    
         
            -
            #if USE_FLONUM
         
     | 
| 
       913 
     | 
    
         
            -
                    if (FLONUM_P(val)) {
         
     | 
| 
       914 
     | 
    
         
            -
                        return DBL2NUM(-RFLOAT_VALUE(val));
         
     | 
| 
       915 
     | 
    
         
            -
                    }
         
     | 
| 
       916 
     | 
    
         
            -
            #endif
         
     | 
| 
       917 
     | 
    
         
            -
                    goto unknown;
         
     | 
| 
       918 
     | 
    
         
            -
                }
         
     | 
| 
       919 
     | 
    
         
            -
                switch (BUILTIN_TYPE(val)) {
         
     | 
| 
       920 
     | 
    
         
            -
                  case T_BIGNUM:
         
     | 
| 
       921 
     | 
    
         
            -
                    BIGNUM_NEGATE(val);
         
     | 
| 
       922 
     | 
    
         
            -
                    val = rb_big_norm(val);
         
     | 
| 
       923 
     | 
    
         
            -
                    break;
         
     | 
| 
       924 
     | 
    
         
            -
                  case T_RATIONAL:
         
     | 
| 
       925 
     | 
    
         
            -
                    RATIONAL_SET_NUM(val, negative_numeric(RRATIONAL(val)->num));
         
     | 
| 
       926 
     | 
    
         
            -
                    break;
         
     | 
| 
       927 
     | 
    
         
            -
                  case T_COMPLEX:
         
     | 
| 
       928 
     | 
    
         
            -
                    RCOMPLEX_SET_REAL(val, negative_numeric(RCOMPLEX(val)->real));
         
     | 
| 
       929 
     | 
    
         
            -
                    RCOMPLEX_SET_IMAG(val, negative_numeric(RCOMPLEX(val)->imag));
         
     | 
| 
       930 
     | 
    
         
            -
                    break;
         
     | 
| 
       931 
     | 
    
         
            -
                  case T_FLOAT:
         
     | 
| 
       932 
     | 
    
         
            -
                    val = DBL2NUM(-RFLOAT_VALUE(val));
         
     | 
| 
       933 
     | 
    
         
            -
                    break;
         
     | 
| 
       934 
     | 
    
         
            -
                  unknown:
         
     | 
| 
       935 
     | 
    
         
            -
                  default:
         
     | 
| 
       936 
     | 
    
         
            -
                    rb_bug("unknown literal type (%s) passed to negative_numeric",
         
     | 
| 
       937 
     | 
    
         
            -
                           rb_builtin_class_name(val));
         
     | 
| 
       938 
     | 
    
         
            -
                    break;
         
     | 
| 
       939 
     | 
    
         
            -
                }
         
     | 
| 
       940 
     | 
    
         
            -
                return val;
         
     | 
| 
       941 
     | 
    
         
            -
            }
         
     | 
| 
       942 
     | 
    
         
            -
             
     | 
| 
       943 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       944 
     | 
    
         
            -
            integer_value(const char *val, int base)
         
     | 
| 
       945 
     | 
    
         
            -
            {
         
     | 
| 
       946 
     | 
    
         
            -
                return rb_cstr_to_inum(val, base, FALSE);
         
     | 
| 
       947 
     | 
    
         
            -
            }
         
     | 
| 
       948 
     | 
    
         
            -
             
     | 
| 
       949 
     | 
    
         
            -
            static VALUE
         
     | 
| 
       950 
     | 
    
         
            -
            rational_value(const char *node_val, int base, int seen_point)
         
     | 
| 
       951 
     | 
    
         
            -
            {
         
     | 
| 
       952 
     | 
    
         
            -
                VALUE lit;
         
     | 
| 
       953 
     | 
    
         
            -
                char* val = strdup(node_val);
         
     | 
| 
       954 
     | 
    
         
            -
                if (seen_point > 0) {
         
     | 
| 
       955 
     | 
    
         
            -
                    int len = (int)(strlen(val));
         
     | 
| 
       956 
     | 
    
         
            -
                    char *point = &val[seen_point];
         
     | 
| 
       957 
     | 
    
         
            -
                    size_t fraclen = len-seen_point-1;
         
     | 
| 
       958 
     | 
    
         
            -
                    memmove(point, point+1, fraclen+1);
         
     | 
| 
       959 
     | 
    
         
            -
             
     | 
| 
       960 
     | 
    
         
            -
                    lit = rb_rational_new(integer_value(val, base), rb_int_positive_pow(10, fraclen));
         
     | 
| 
       961 
     | 
    
         
            -
                }
         
     | 
| 
       962 
     | 
    
         
            -
                else {
         
     | 
| 
       963 
     | 
    
         
            -
                    lit = rb_rational_raw1(integer_value(val, base));
         
     | 
| 
       964 
     | 
    
         
            -
                }
         
     | 
| 
       965 
     | 
    
         
            -
             
     | 
| 
       966 
     | 
    
         
            -
                free(val);
         
     | 
| 
       967 
     | 
    
         
            -
             
     | 
| 
       968 
     | 
    
         
            -
                return lit;
         
     | 
| 
       969 
     | 
    
         
            -
            }
         
     | 
| 
       970 
     | 
    
         
            -
             
     | 
| 
       971 
     | 
    
         
            -
            VALUE
         
     | 
| 
       972 
     | 
    
         
            -
            rb_node_integer_literal_val(const NODE *n)
         
     | 
| 
       973 
     | 
    
         
            -
            {
         
     | 
| 
       974 
     | 
    
         
            -
                const rb_node_integer_t *node = RNODE_INTEGER(n);
         
     | 
| 
       975 
     | 
    
         
            -
                VALUE val = integer_value(node->val, node->base);
         
     | 
| 
       976 
     | 
    
         
            -
                if (node->minus) {
         
     | 
| 
       977 
     | 
    
         
            -
                    val = negative_numeric(val);
         
     | 
| 
       978 
     | 
    
         
            -
                }
         
     | 
| 
       979 
     | 
    
         
            -
                return val;
         
     | 
| 
       980 
     | 
    
         
            -
            }
         
     | 
| 
       981 
     | 
    
         
            -
             
     | 
| 
       982 
     | 
    
         
            -
            VALUE
         
     | 
| 
       983 
     | 
    
         
            -
            rb_node_float_literal_val(const NODE *n)
         
     | 
| 
       984 
     | 
    
         
            -
            {
         
     | 
| 
       985 
     | 
    
         
            -
                const rb_node_float_t *node = RNODE_FLOAT(n);
         
     | 
| 
       986 
     | 
    
         
            -
                double d = strtod(node->val, 0);
         
     | 
| 
       987 
     | 
    
         
            -
                if (node->minus) {
         
     | 
| 
       988 
     | 
    
         
            -
                    d = -d;
         
     | 
| 
       989 
     | 
    
         
            -
                }
         
     | 
| 
       990 
     | 
    
         
            -
                VALUE val = DBL2NUM(d);
         
     | 
| 
       991 
     | 
    
         
            -
                return val;
         
     | 
| 
       992 
     | 
    
         
            -
            }
         
     | 
| 
       993 
     | 
    
         
            -
             
     | 
| 
       994 
     | 
    
         
            -
            VALUE
         
     | 
| 
       995 
     | 
    
         
            -
            rb_node_rational_literal_val(const NODE *n)
         
     | 
| 
       996 
     | 
    
         
            -
            {
         
     | 
| 
       997 
     | 
    
         
            -
                VALUE lit;
         
     | 
| 
       998 
     | 
    
         
            -
                const rb_node_rational_t *node = RNODE_RATIONAL(n);
         
     | 
| 
       999 
     | 
    
         
            -
             
     | 
| 
       1000 
     | 
    
         
            -
                lit = rational_value(node->val, node->base, node->seen_point);
         
     | 
| 
       1001 
     | 
    
         
            -
             
     | 
| 
       1002 
     | 
    
         
            -
                if (node->minus) {
         
     | 
| 
       1003 
     | 
    
         
            -
                    lit = negative_numeric(lit);
         
     | 
| 
       1004 
     | 
    
         
            -
                }
         
     | 
| 
       1005 
     | 
    
         
            -
             
     | 
| 
       1006 
     | 
    
         
            -
                return lit;
         
     | 
| 
       1007 
     | 
    
         
            -
            }
         
     | 
| 
       1008 
     | 
    
         
            -
             
     | 
| 
       1009 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1010 
     | 
    
         
            -
            rb_node_imaginary_literal_val(const NODE *n)
         
     | 
| 
       1011 
     | 
    
         
            -
            {
         
     | 
| 
       1012 
     | 
    
         
            -
                VALUE lit;
         
     | 
| 
       1013 
     | 
    
         
            -
                const rb_node_imaginary_t *node = RNODE_IMAGINARY(n);
         
     | 
| 
       1014 
     | 
    
         
            -
             
     | 
| 
       1015 
     | 
    
         
            -
                enum rb_numeric_type type = node->type;
         
     | 
| 
       1016 
     | 
    
         
            -
             
     | 
| 
       1017 
     | 
    
         
            -
                switch (type) {
         
     | 
| 
       1018 
     | 
    
         
            -
                  case integer_literal:
         
     | 
| 
       1019 
     | 
    
         
            -
                    lit = integer_value(node->val, node->base);
         
     | 
| 
       1020 
     | 
    
         
            -
                    break;
         
     | 
| 
       1021 
     | 
    
         
            -
                  case float_literal:{
         
     | 
| 
       1022 
     | 
    
         
            -
                    double d = strtod(node->val, 0);
         
     | 
| 
       1023 
     | 
    
         
            -
                    lit = DBL2NUM(d);
         
     | 
| 
       1024 
     | 
    
         
            -
                    break;
         
     | 
| 
       1025 
     | 
    
         
            -
                  }
         
     | 
| 
       1026 
     | 
    
         
            -
                  case rational_literal:
         
     | 
| 
       1027 
     | 
    
         
            -
                    lit = rational_value(node->val, node->base, node->seen_point);
         
     | 
| 
       1028 
     | 
    
         
            -
                    break;
         
     | 
| 
       1029 
     | 
    
         
            -
                  default:
         
     | 
| 
       1030 
     | 
    
         
            -
                    rb_bug("unreachable");
         
     | 
| 
       1031 
     | 
    
         
            -
                }
         
     | 
| 
       1032 
     | 
    
         
            -
             
     | 
| 
       1033 
     | 
    
         
            -
                lit = rb_complex_raw(INT2FIX(0), lit);
         
     | 
| 
       1034 
     | 
    
         
            -
             
     | 
| 
       1035 
     | 
    
         
            -
                if (node->minus) {
         
     | 
| 
       1036 
     | 
    
         
            -
                    lit = negative_numeric(lit);
         
     | 
| 
       1037 
     | 
    
         
            -
                }
         
     | 
| 
       1038 
     | 
    
         
            -
                return lit;
         
     | 
| 
       1039 
     | 
    
         
            -
            }
         
     | 
| 
       1040 
     | 
    
         
            -
             
     | 
| 
       1041 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1042 
     | 
    
         
            -
            rb_node_str_string_val(const NODE *node)
         
     | 
| 
       1043 
     | 
    
         
            -
            {
         
     | 
| 
       1044 
     | 
    
         
            -
                rb_parser_string_t *str = RNODE_STR(node)->string;
         
     | 
| 
       1045 
     | 
    
         
            -
                return rb_str_new_parser_string(str);
         
     | 
| 
       1046 
     | 
    
         
            -
            }
         
     | 
| 
       1047 
     | 
    
         
            -
             
     | 
| 
       1048 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1049 
     | 
    
         
            -
            rb_node_sym_string_val(const NODE *node)
         
     | 
| 
       1050 
     | 
    
         
            -
            {
         
     | 
| 
       1051 
     | 
    
         
            -
                rb_parser_string_t *str = RNODE_SYM(node)->string;
         
     | 
| 
       1052 
     | 
    
         
            -
                return ID2SYM(rb_intern3(str->ptr, str->len, str->enc));
         
     | 
| 
       1053 
     | 
    
         
            -
            }
         
     | 
| 
       1054 
     | 
    
         
            -
             
     | 
| 
       1055 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1056 
     | 
    
         
            -
            rb_node_dstr_string_val(const NODE *node)
         
     | 
| 
       1057 
     | 
    
         
            -
            {
         
     | 
| 
       1058 
     | 
    
         
            -
                rb_parser_string_t *str = RNODE_DSTR(node)->string;
         
     | 
| 
       1059 
     | 
    
         
            -
                return str ? rb_str_new_parser_string(str) : Qnil;
         
     | 
| 
       1060 
     | 
    
         
            -
            }
         
     | 
| 
       1061 
     | 
    
         
            -
             
     | 
| 
       1062 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1063 
     | 
    
         
            -
            rb_node_dregx_string_val(const NODE *node)
         
     | 
| 
       1064 
     | 
    
         
            -
            {
         
     | 
| 
       1065 
     | 
    
         
            -
                rb_parser_string_t *str = RNODE_DREGX(node)->string;
         
     | 
| 
       1066 
     | 
    
         
            -
                return rb_str_new_parser_string(str);
         
     | 
| 
       1067 
     | 
    
         
            -
            }
         
     | 
| 
       1068 
     | 
    
         
            -
             
     | 
| 
       1069 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1070 
     | 
    
         
            -
            rb_node_regx_string_val(const NODE *node)
         
     | 
| 
       1071 
     | 
    
         
            -
            {
         
     | 
| 
       1072 
     | 
    
         
            -
                rb_node_regx_t *node_reg = RNODE_REGX(node);
         
     | 
| 
       1073 
     | 
    
         
            -
                rb_parser_string_t *string = node_reg->string;
         
     | 
| 
       1074 
     | 
    
         
            -
                VALUE str = rb_enc_str_new(string->ptr, string->len, string->enc);
         
     | 
| 
       1075 
     | 
    
         
            -
             
     | 
| 
       1076 
     | 
    
         
            -
                return rb_reg_compile(str, node_reg->options, NULL, 0);
         
     | 
| 
       1077 
     | 
    
         
            -
            }
         
     | 
| 
       1078 
     | 
    
         
            -
             
     | 
| 
       1079 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1080 
     | 
    
         
            -
            rb_node_line_lineno_val(const NODE *node)
         
     | 
| 
       1081 
     | 
    
         
            -
            {
         
     | 
| 
       1082 
     | 
    
         
            -
                return INT2FIX(node->nd_loc.beg_pos.lineno);
         
     | 
| 
       1083 
     | 
    
         
            -
            }
         
     | 
| 
       1084 
     | 
    
         
            -
             
     | 
| 
       1085 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1086 
     | 
    
         
            -
            rb_node_file_path_val(const NODE *node)
         
     | 
| 
       1087 
     | 
    
         
            -
            {
         
     | 
| 
       1088 
     | 
    
         
            -
                return rb_str_new_parser_string(RNODE_FILE(node)->path);
         
     | 
| 
       1089 
     | 
    
         
            -
            }
         
     | 
| 
       1090 
     | 
    
         
            -
             
     | 
| 
       1091 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1092 
     | 
    
         
            -
            rb_node_encoding_val(const NODE *node)
         
     | 
| 
       1093 
     | 
    
         
            -
            {
         
     | 
| 
       1094 
     | 
    
         
            -
                return rb_enc_from_encoding(RNODE_ENCODING(node)->enc);
         
     | 
| 
       1095 
     | 
    
         
            -
            }
         
     | 
| 
       1096 
     | 
    
         
            -
             
     | 
| 
       1097 
     | 
    
         
            -
            static void
         
     | 
| 
       1098 
     | 
    
         
            -
            parser_aset_script_lines_for(VALUE path, rb_parser_ary_t *lines)
         
     | 
| 
       1099 
     | 
    
         
            -
            {
         
     | 
| 
       1100 
     | 
    
         
            -
                VALUE hash, script_lines;
         
     | 
| 
       1101 
     | 
    
         
            -
                ID script_lines_id;
         
     | 
| 
       1102 
     | 
    
         
            -
                if (NIL_P(path) || !lines) return;
         
     | 
| 
       1103 
     | 
    
         
            -
                CONST_ID(script_lines_id, "SCRIPT_LINES__");
         
     | 
| 
       1104 
     | 
    
         
            -
                if (!rb_const_defined_at(rb_cObject, script_lines_id)) return;
         
     | 
| 
       1105 
     | 
    
         
            -
                hash = rb_const_get_at(rb_cObject, script_lines_id);
         
     | 
| 
       1106 
     | 
    
         
            -
                if (!RB_TYPE_P(hash, T_HASH)) return;
         
     | 
| 
       1107 
     | 
    
         
            -
                if (rb_hash_lookup(hash, path) == Qnil) return;
         
     | 
| 
       1108 
     | 
    
         
            -
                script_lines = rb_parser_build_script_lines_from(lines);
         
     | 
| 
       1109 
     | 
    
         
            -
                rb_hash_aset(hash, path, script_lines);
         
     | 
| 
       1110 
     | 
    
         
            -
            }
         
     | 
| 
       1111 
     | 
    
         
            -
             
     | 
| 
       1112 
     | 
    
         
            -
            VALUE
         
     | 
| 
       1113 
     | 
    
         
            -
            rb_ruby_ast_new(const NODE *const root)
         
     | 
| 
       1114 
     | 
    
         
            -
            {
         
     | 
| 
       1115 
     | 
    
         
            -
                rb_ast_t *ast;
         
     | 
| 
       1116 
     | 
    
         
            -
                VALUE ast_value = TypedData_Make_Struct(0, rb_ast_t, &ast_data_type, ast);
         
     | 
| 
       1117 
     | 
    
         
            -
            #ifdef UNIVERSAL_PARSER
         
     | 
| 
       1118 
     | 
    
         
            -
                ast->config = &rb_global_parser_config;
         
     | 
| 
       1119 
     | 
    
         
            -
            #endif
         
     | 
| 
       1120 
     | 
    
         
            -
                ast->body = (rb_ast_body_t){
         
     | 
| 
       1121 
     | 
    
         
            -
                    .root = root,
         
     | 
| 
       1122 
     | 
    
         
            -
                    .frozen_string_literal = -1,
         
     | 
| 
       1123 
     | 
    
         
            -
                    .coverage_enabled = -1,
         
     | 
| 
       1124 
     | 
    
         
            -
                    .script_lines = NULL,
         
     | 
| 
       1125 
     | 
    
         
            -
                    .line_count = 0,
         
     | 
| 
       1126 
     | 
    
         
            -
                };
         
     | 
| 
       1127 
     | 
    
         
            -
                return ast_value;
         
     | 
| 
       1128 
     | 
    
         
            -
            }
         
     | 
| 
       1129 
     | 
    
         
            -
             
     | 
| 
       1130 
     | 
    
         
            -
            rb_ast_t *
         
     | 
| 
       1131 
     | 
    
         
            -
            rb_ruby_ast_data_get(VALUE ast_value)
         
     | 
| 
       1132 
     | 
    
         
            -
            {
         
     | 
| 
       1133 
     | 
    
         
            -
                rb_ast_t *ast;
         
     | 
| 
       1134 
     | 
    
         
            -
                if (NIL_P(ast_value)) return NULL;
         
     | 
| 
       1135 
     | 
    
         
            -
                TypedData_Get_Struct(ast_value, rb_ast_t, &ast_data_type, ast);
         
     | 
| 
       1136 
     | 
    
         
            -
                return ast;
         
     | 
| 
       1137 
     | 
    
         
            -
            }
         
     |