kanayago 0.1.1 → 0.3.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/.rubocop.yml +12 -0
 - data/.ruby-version +1 -0
 - data/README.md +20 -29
 - data/Rakefile +24 -120
 - data/ext/kanayago/extconf.rb +14 -0
 - data/ext/kanayago/kanayago.c +554 -235
 - data/ext/kanayago/kanayago.h +5 -0
 - data/ext/kanayago/literal_node.c +343 -0
 - data/ext/kanayago/literal_node.h +30 -0
 - data/ext/kanayago/pattern_node.c +78 -0
 - data/ext/kanayago/pattern_node.h +13 -0
 - data/ext/kanayago/scope_node.c +34 -0
 - data/ext/kanayago/scope_node.h +8 -0
 - data/ext/kanayago/statement_node.c +795 -0
 - data/ext/kanayago/statement_node.h +66 -0
 - data/ext/kanayago/string_node.c +192 -0
 - data/ext/kanayago/string_node.h +19 -0
 - data/ext/kanayago/variable_node.c +72 -0
 - data/ext/kanayago/variable_node.h +12 -0
 - data/lib/kanayago/literal_node.rb +87 -0
 - data/lib/kanayago/pattern_node.rb +19 -0
 - data/lib/kanayago/statement_node.rb +222 -0
 - data/lib/kanayago/string_node.rb +43 -0
 - data/lib/kanayago/variable_node.rb +23 -0
 - data/lib/kanayago/version.rb +1 -1
 - data/lib/kanayago.rb +22 -0
 - data/patch/3.4/copy_target.rb +78 -0
 - data/patch/3.4/kanayago.patch +162 -0
 - data/patch/head/copy_target.rb +84 -0
 - data/patch/head/kanayago.patch +162 -0
 - data/sample/minitest_generator.rb +266 -0
 - data/sample/test_generator.rb +272 -0
 - data/script/setup_parser.rb +136 -0
 - data/typeprof.conf.json +9 -0
 - metadata +30 -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 -347
 - data/ext/kanayago/id_table.h +0 -39
 - data/ext/kanayago/internal/array.h +0 -151
 - data/ext/kanayago/internal/basic_operators.h +0 -64
 - data/ext/kanayago/internal/bignum.h +0 -244
 - data/ext/kanayago/internal/bits.h +0 -568
 - 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 -36
 - data/ext/kanayago/internal/error.h +0 -218
 - data/ext/kanayago/internal/fixnum.h +0 -184
 - data/ext/kanayago/internal/gc.h +0 -322
 - data/ext/kanayago/internal/hash.h +0 -191
 - data/ext/kanayago/internal/imemo.h +0 -261
 - data/ext/kanayago/internal/io.h +0 -140
 - data/ext/kanayago/internal/numeric.h +0 -274
 - data/ext/kanayago/internal/parse.h +0 -117
 - data/ext/kanayago/internal/rational.h +0 -71
 - data/ext/kanayago/internal/re.h +0 -28
 - data/ext/kanayago/internal/ruby_parser.h +0 -125
 - data/ext/kanayago/internal/sanitizers.h +0 -297
 - data/ext/kanayago/internal/serial.h +0 -23
 - data/ext/kanayago/internal/static_assert.h +0 -16
 - data/ext/kanayago/internal/string.h +0 -186
 - data/ext/kanayago/internal/symbol.h +0 -45
 - data/ext/kanayago/internal/thread.h +0 -79
 - data/ext/kanayago/internal/variable.h +0 -72
 - data/ext/kanayago/internal/vm.h +0 -137
 - data/ext/kanayago/internal/warnings.h +0 -16
 - data/ext/kanayago/internal.h +0 -108
 - data/ext/kanayago/lex.c +0 -302
 - data/ext/kanayago/method.h +0 -255
 - data/ext/kanayago/node.c +0 -440
 - data/ext/kanayago/node.h +0 -111
 - data/ext/kanayago/node_name.inc +0 -224
 - data/ext/kanayago/parse.c +0 -26931
 - data/ext/kanayago/parse.h +0 -244
 - data/ext/kanayago/parse.tmp.y +0 -16145
 - data/ext/kanayago/parser_bits.h +0 -564
 - data/ext/kanayago/parser_node.h +0 -32
 - data/ext/kanayago/parser_st.c +0 -164
 - 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 -23
 - data/ext/kanayago/ruby_parser.c +0 -1165
 - data/ext/kanayago/rubyparser.h +0 -1391
 - data/ext/kanayago/shape.h +0 -234
 - data/ext/kanayago/st.c +0 -2339
 - data/ext/kanayago/symbol.h +0 -123
 - data/ext/kanayago/thread_pthread.h +0 -168
 - data/ext/kanayago/universal_parser.c +0 -230
 - data/ext/kanayago/vm_core.h +0 -2215
 - data/ext/kanayago/vm_opts.h +0 -67
 
    
        data/ext/kanayago/kanayago.h
    CHANGED
    
    
| 
         @@ -0,0 +1,343 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include "literal_node.h"
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include "internal/ruby_parser.h"
         
     | 
| 
      
 3 
     | 
    
         
            +
            #include "kanayago.h"
         
     | 
| 
      
 4 
     | 
    
         
            +
            #include "internal/encoding.h"
         
     | 
| 
      
 5 
     | 
    
         
            +
            #include "rubyparser.h"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            VALUE rb_cIntegerNode;
         
     | 
| 
      
 8 
     | 
    
         
            +
            VALUE rb_cFloatNode;
         
     | 
| 
      
 9 
     | 
    
         
            +
            VALUE rb_cRationalNode;
         
     | 
| 
      
 10 
     | 
    
         
            +
            VALUE rb_cImaginaryNode;
         
     | 
| 
      
 11 
     | 
    
         
            +
            VALUE rb_cStringNode;
         
     | 
| 
      
 12 
     | 
    
         
            +
            VALUE rb_cSymbolNode;
         
     | 
| 
      
 13 
     | 
    
         
            +
            VALUE rb_cZeroListNode;
         
     | 
| 
      
 14 
     | 
    
         
            +
            VALUE rb_cFileNode;
         
     | 
| 
      
 15 
     | 
    
         
            +
            VALUE rb_cLineNode;
         
     | 
| 
      
 16 
     | 
    
         
            +
            VALUE rb_cEncodingNode;
         
     | 
| 
      
 17 
     | 
    
         
            +
            VALUE rb_cNilNode;
         
     | 
| 
      
 18 
     | 
    
         
            +
            VALUE rb_cTrueNode;
         
     | 
| 
      
 19 
     | 
    
         
            +
            VALUE rb_cFalseNode;
         
     | 
| 
      
 20 
     | 
    
         
            +
            VALUE rb_cRangeNode;
         
     | 
| 
      
 21 
     | 
    
         
            +
            VALUE rb_cExclusiveRangeNode;
         
     | 
| 
      
 22 
     | 
    
         
            +
            VALUE rb_cFlipFlopNode;
         
     | 
| 
      
 23 
     | 
    
         
            +
            VALUE rb_cExclusiveFlipFlopNode;
         
     | 
| 
      
 24 
     | 
    
         
            +
            VALUE rb_cHashNode;
         
     | 
| 
      
 25 
     | 
    
         
            +
            VALUE rb_cNthRefNode;
         
     | 
| 
      
 26 
     | 
    
         
            +
            VALUE rb_cBackRefNode;
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 29 
     | 
    
         
            +
            integer_node_new(const NODE *node)
         
     | 
| 
      
 30 
     | 
    
         
            +
            {
         
     | 
| 
      
 31 
     | 
    
         
            +
                VALUE result = rb_class_new_instance(0, 0, rb_cIntegerNode);
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@val"), rb_node_integer_literal_val(node));
         
     | 
| 
      
 34 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@minus"), RNODE_INTEGER(node)->minus == TRUE ? Qtrue : Qfalse);
         
     | 
| 
      
 35 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@base"), INT2FIX(RNODE_INTEGER(node)->base));
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 38 
     | 
    
         
            +
            }
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 41 
     | 
    
         
            +
            float_node_new(const NODE *node)
         
     | 
| 
      
 42 
     | 
    
         
            +
            {
         
     | 
| 
      
 43 
     | 
    
         
            +
                VALUE result = rb_class_new_instance(0, 0, rb_cFloatNode);
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@val"), rb_node_float_literal_val(node));
         
     | 
| 
      
 46 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@minus"), RNODE_FLOAT(node)->minus == TRUE ? Qtrue : Qfalse);
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 49 
     | 
    
         
            +
            }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 52 
     | 
    
         
            +
            rational_node_new(const NODE *node)
         
     | 
| 
      
 53 
     | 
    
         
            +
            {
         
     | 
| 
      
 54 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cRationalNode);
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), rb_node_rational_literal_val(node));
         
     | 
| 
      
 57 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@minus"), RNODE_RATIONAL(node)->minus == TRUE ? Qtrue : Qfalse);
         
     | 
| 
      
 58 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@base"), INT2FIX(RNODE_RATIONAL(node)->base));
         
     | 
| 
      
 59 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@seen_point"), INT2FIX(RNODE_RATIONAL(node)->seen_point));
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 62 
     | 
    
         
            +
            }
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 65 
     | 
    
         
            +
            parser_string_coderange_type_to_str(enum rb_parser_string_coderange_type coderange)
         
     | 
| 
      
 66 
     | 
    
         
            +
            {
         
     | 
| 
      
 67 
     | 
    
         
            +
                switch (coderange) {
         
     | 
| 
      
 68 
     | 
    
         
            +
                  case RB_PARSER_ENC_CODERANGE_UNKNOWN:
         
     | 
| 
      
 69 
     | 
    
         
            +
                    return rb_str_new_cstr("RB_PARSER_ENC_CODERANGE_UNKNOWN");
         
     | 
| 
      
 70 
     | 
    
         
            +
                  case RB_PARSER_ENC_CODERANGE_7BIT:
         
     | 
| 
      
 71 
     | 
    
         
            +
            	return rb_str_new_cstr("RB_PARSER_ENC_CODERANGE_7BIT");
         
     | 
| 
      
 72 
     | 
    
         
            +
                  case RB_PARSER_ENC_CODERANGE_VALID:
         
     | 
| 
      
 73 
     | 
    
         
            +
            	return rb_str_new_cstr("RB_PARSER_ENC_CODERANGE_VALID");
         
     | 
| 
      
 74 
     | 
    
         
            +
                  case RB_PARSER_ENC_CODERANGE_BROKEN:
         
     | 
| 
      
 75 
     | 
    
         
            +
            	return rb_str_new_cstr("RB_PARSER_ENC_CODERANGE_BROKEN");
         
     | 
| 
      
 76 
     | 
    
         
            +
                }
         
     | 
| 
      
 77 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 78 
     | 
    
         
            +
            }
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 81 
     | 
    
         
            +
            numeric_type_to_str(enum rb_numeric_type type)
         
     | 
| 
      
 82 
     | 
    
         
            +
            {
         
     | 
| 
      
 83 
     | 
    
         
            +
                switch (type) {
         
     | 
| 
      
 84 
     | 
    
         
            +
                  case integer_literal:
         
     | 
| 
      
 85 
     | 
    
         
            +
                    return rb_str_new_cstr("integer_literal");
         
     | 
| 
      
 86 
     | 
    
         
            +
                  case float_literal:
         
     | 
| 
      
 87 
     | 
    
         
            +
            	return rb_str_new_cstr("float_literal");
         
     | 
| 
      
 88 
     | 
    
         
            +
                  case rational_literal:
         
     | 
| 
      
 89 
     | 
    
         
            +
            	return rb_str_new_cstr("rational_literal");
         
     | 
| 
      
 90 
     | 
    
         
            +
                }
         
     | 
| 
      
 91 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 92 
     | 
    
         
            +
            }
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 95 
     | 
    
         
            +
            imaginary_node_new(const NODE *node)
         
     | 
| 
      
 96 
     | 
    
         
            +
            {
         
     | 
| 
      
 97 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cImaginaryNode);
         
     | 
| 
      
 98 
     | 
    
         
            +
                enum rb_numeric_type type = RNODE_IMAGINARY(node)->type;
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), rb_node_imaginary_literal_val(node));
         
     | 
| 
      
 101 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@minus"), RNODE_IMAGINARY(node)->minus == TRUE ? Qtrue : Qfalse);
         
     | 
| 
      
 102 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@base"), INT2FIX(RNODE_IMAGINARY(node)->base));
         
     | 
| 
      
 103 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@seen_point"), INT2FIX(RNODE_IMAGINARY(node)->seen_point));
         
     | 
| 
      
 104 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@type"), numeric_type_to_str(type));
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 107 
     | 
    
         
            +
            }
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 110 
     | 
    
         
            +
            string_node_new(const NODE *node)
         
     | 
| 
      
 111 
     | 
    
         
            +
            {
         
     | 
| 
      
 112 
     | 
    
         
            +
                VALUE result = rb_class_new_instance(0, 0, rb_cStringNode);
         
     | 
| 
      
 113 
     | 
    
         
            +
                rb_parser_string_t *str = RNODE_STR(node)->string;
         
     | 
| 
      
 114 
     | 
    
         
            +
                rb_encoding *enc = str->enc;
         
     | 
| 
      
 115 
     | 
    
         
            +
                char *ptr = str->ptr;
         
     | 
| 
      
 116 
     | 
    
         
            +
                long len = str->len;
         
     | 
| 
      
 117 
     | 
    
         
            +
                enum rb_parser_string_coderange_type conderange = str->coderange;
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@ptr"), rb_enc_str_new(ptr, len, enc));
         
     | 
| 
      
 120 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@len"), LONG2FIX(len));
         
     | 
| 
      
 121 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@enc"), rb_enc_from_encoding(enc));
         
     | 
| 
      
 122 
     | 
    
         
            +
                rb_ivar_set(result, rb_intern("@coderange"), parser_string_coderange_type_to_str(conderange));
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 125 
     | 
    
         
            +
            }
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 128 
     | 
    
         
            +
            symbol_node_new(const NODE *node)
         
     | 
| 
      
 129 
     | 
    
         
            +
            {
         
     | 
| 
      
 130 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cSymbolNode);
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                rb_parser_string_t *str = RNODE_SYM(node)->string;
         
     | 
| 
      
 133 
     | 
    
         
            +
                rb_encoding *enc = str->enc;
         
     | 
| 
      
 134 
     | 
    
         
            +
                char *ptr = str->ptr;
         
     | 
| 
      
 135 
     | 
    
         
            +
                long len = str->len;
         
     | 
| 
      
 136 
     | 
    
         
            +
                enum rb_parser_string_coderange_type conderange = str->coderange;
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@ptr"), rb_enc_str_new(ptr, len, enc));
         
     | 
| 
      
 139 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@len"), LONG2FIX(len));
         
     | 
| 
      
 140 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@enc"), rb_enc_from_encoding(enc));
         
     | 
| 
      
 141 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@coderange"), parser_string_coderange_type_to_str(conderange));
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 144 
     | 
    
         
            +
            }
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 147 
     | 
    
         
            +
            zero_list_node_new(const NODE *node)
         
     | 
| 
      
 148 
     | 
    
         
            +
            {
         
     | 
| 
      
 149 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cZeroListNode);
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@len"), INT2FIX(0));
         
     | 
| 
      
 152 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), rb_ary_new());
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 155 
     | 
    
         
            +
            }
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 158 
     | 
    
         
            +
            file_node_new(const NODE *node)
         
     | 
| 
      
 159 
     | 
    
         
            +
            {
         
     | 
| 
      
 160 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cFileNode);
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                rb_parser_string_t *str = RNODE_FILE(node)->path;
         
     | 
| 
      
 163 
     | 
    
         
            +
                rb_encoding *enc = str->enc;
         
     | 
| 
      
 164 
     | 
    
         
            +
                char *ptr = str->ptr;
         
     | 
| 
      
 165 
     | 
    
         
            +
                long len = str->len;
         
     | 
| 
      
 166 
     | 
    
         
            +
                enum rb_parser_string_coderange_type conderange = str->coderange;
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@ptr"), rb_enc_str_new(ptr, len, enc));
         
     | 
| 
      
 169 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@len"), LONG2FIX(len));
         
     | 
| 
      
 170 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@enc"), rb_enc_from_encoding(enc));
         
     | 
| 
      
 171 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@coderange"), parser_string_coderange_type_to_str(conderange));
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 174 
     | 
    
         
            +
            }
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 177 
     | 
    
         
            +
            line_node_new(const NODE *node)
         
     | 
| 
      
 178 
     | 
    
         
            +
            {
         
     | 
| 
      
 179 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cLineNode);
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@lineno"), INT2FIX(node->nd_loc.beg_pos.lineno));
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 184 
     | 
    
         
            +
            }
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 187 
     | 
    
         
            +
            encoding_node_new(const NODE *node)
         
     | 
| 
      
 188 
     | 
    
         
            +
            {
         
     | 
| 
      
 189 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cEncodingNode);
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), rb_enc_from_encoding(RNODE_ENCODING(node)->enc));
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 194 
     | 
    
         
            +
            }
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 197 
     | 
    
         
            +
            nil_node_new(const NODE *node)
         
     | 
| 
      
 198 
     | 
    
         
            +
            {
         
     | 
| 
      
 199 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cNilNode);
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), Qnil);
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 204 
     | 
    
         
            +
            }
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 207 
     | 
    
         
            +
            true_node_new(const NODE *node)
         
     | 
| 
      
 208 
     | 
    
         
            +
            {
         
     | 
| 
      
 209 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cTrueNode);
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), Qtrue);
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 214 
     | 
    
         
            +
            }
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 217 
     | 
    
         
            +
            false_node_new(const NODE *node)
         
     | 
| 
      
 218 
     | 
    
         
            +
            {
         
     | 
| 
      
 219 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cFalseNode);
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@val"), Qfalse);
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 224 
     | 
    
         
            +
            }
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 227 
     | 
    
         
            +
            range_node_new(const NODE *node)
         
     | 
| 
      
 228 
     | 
    
         
            +
            {
         
     | 
| 
      
 229 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cRangeNode);
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@beg"), ast_to_node_instance(RNODE_DOT2(node)->nd_beg));
         
     | 
| 
      
 232 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@end"), ast_to_node_instance(RNODE_DOT2(node)->nd_end));
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 235 
     | 
    
         
            +
            }
         
     | 
| 
      
 236 
     | 
    
         
            +
             
     | 
| 
      
 237 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 238 
     | 
    
         
            +
            exclusive_range_node_new(const NODE *node)
         
     | 
| 
      
 239 
     | 
    
         
            +
            {
         
     | 
| 
      
 240 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cExclusiveRangeNode);
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@beg"), ast_to_node_instance(RNODE_DOT3(node)->nd_beg));
         
     | 
| 
      
 243 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@end"), ast_to_node_instance(RNODE_DOT3(node)->nd_end));
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 246 
     | 
    
         
            +
            }
         
     | 
| 
      
 247 
     | 
    
         
            +
             
     | 
| 
      
 248 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 249 
     | 
    
         
            +
            flip_flop_node_new(const NODE *node)
         
     | 
| 
      
 250 
     | 
    
         
            +
            {
         
     | 
| 
      
 251 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cFlipFlopNode);
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@beg"), ast_to_node_instance(RNODE_FLIP2(node)->nd_beg));
         
     | 
| 
      
 254 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@end"), ast_to_node_instance(RNODE_FLIP2(node)->nd_end));
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 257 
     | 
    
         
            +
            }
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 260 
     | 
    
         
            +
            exclusive_flip_flop_node_new(const NODE *node)
         
     | 
| 
      
 261 
     | 
    
         
            +
            {
         
     | 
| 
      
 262 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cExclusiveFlipFlopNode);
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@beg"), ast_to_node_instance(RNODE_FLIP3(node)->nd_beg));
         
     | 
| 
      
 265 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@end"), ast_to_node_instance(RNODE_FLIP3(node)->nd_end));
         
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
      
 267 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 268 
     | 
    
         
            +
            }
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 271 
     | 
    
         
            +
            hash_node_new(const NODE *node)
         
     | 
| 
      
 272 
     | 
    
         
            +
            {
         
     | 
| 
      
 273 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cHashNode);
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@head"), ast_to_node_instance(RNODE_HASH(node)->nd_head));
         
     | 
| 
      
 276 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@brace"), RNODE_HASH(node)->nd_brace ? Qtrue : Qfalse);
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 279 
     | 
    
         
            +
            }
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 282 
     | 
    
         
            +
            nth_ref_node_new(const NODE *node)
         
     | 
| 
      
 283 
     | 
    
         
            +
            {
         
     | 
| 
      
 284 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cNthRefNode);
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@nth"), LONG2NUM(RNODE_NTH_REF(node)->nd_nth));
         
     | 
| 
      
 287 
     | 
    
         
            +
             
     | 
| 
      
 288 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 289 
     | 
    
         
            +
            }
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 292 
     | 
    
         
            +
            back_ref_node_new(const NODE *node)
         
     | 
| 
      
 293 
     | 
    
         
            +
            {
         
     | 
| 
      
 294 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cBackRefNode);
         
     | 
| 
      
 295 
     | 
    
         
            +
             
     | 
| 
      
 296 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@nth"), LONG2NUM(RNODE_BACK_REF(node)->nd_nth));
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 299 
     | 
    
         
            +
            }
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
            void
         
     | 
| 
      
 302 
     | 
    
         
            +
            Init_LiteralNode(VALUE module)
         
     | 
| 
      
 303 
     | 
    
         
            +
            {
         
     | 
| 
      
 304 
     | 
    
         
            +
                rb_cIntegerNode = rb_define_class_under(module, "IntegerNode", rb_cObject);
         
     | 
| 
      
 305 
     | 
    
         
            +
             
     | 
| 
      
 306 
     | 
    
         
            +
                rb_cFloatNode = rb_define_class_under(module, "FloatNode", rb_cObject);
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
                rb_cRationalNode = rb_define_class_under(module, "RationalNode", rb_cObject);
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
                rb_cImaginaryNode = rb_define_class_under(module, "ImaginaryNode", rb_cObject);
         
     | 
| 
      
 311 
     | 
    
         
            +
             
     | 
| 
      
 312 
     | 
    
         
            +
                rb_cStringNode = rb_define_class_under(module, "StringNode", rb_cObject);
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
      
 314 
     | 
    
         
            +
                rb_cSymbolNode = rb_define_class_under(module, "SymbolNode", rb_cObject);
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
                rb_cZeroListNode = rb_define_class_under(module, "ZeroListNode", rb_cObject);
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
                rb_cFileNode = rb_define_class_under(module, "FileNode", rb_cObject);
         
     | 
| 
      
 319 
     | 
    
         
            +
             
     | 
| 
      
 320 
     | 
    
         
            +
                rb_cLineNode = rb_define_class_under(module, "LineNode", rb_cObject);
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
                rb_cEncodingNode = rb_define_class_under(module, "EncodingNode", rb_cObject);
         
     | 
| 
      
 323 
     | 
    
         
            +
             
     | 
| 
      
 324 
     | 
    
         
            +
                rb_cNilNode = rb_define_class_under(module, "NilNode", rb_cObject);
         
     | 
| 
      
 325 
     | 
    
         
            +
             
     | 
| 
      
 326 
     | 
    
         
            +
                rb_cTrueNode = rb_define_class_under(module, "TrueNode", rb_cObject);
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
                rb_cFalseNode = rb_define_class_under(module, "FalseNode", rb_cObject);
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
                rb_cRangeNode = rb_define_class_under(module, "RangeNode", rb_cObject);
         
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
      
 332 
     | 
    
         
            +
                rb_cExclusiveRangeNode = rb_define_class_under(module, "ExclusiveRangeNode", rb_cObject);
         
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
      
 334 
     | 
    
         
            +
                rb_cFlipFlopNode = rb_define_class_under(module, "FlipFlopNode", rb_cObject);
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
                rb_cExclusiveFlipFlopNode = rb_define_class_under(module, "ExclusiveFlipFlopNode", rb_cObject);
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
                rb_cHashNode = rb_define_class_under(module, "HashNode", rb_cObject);
         
     | 
| 
      
 339 
     | 
    
         
            +
             
     | 
| 
      
 340 
     | 
    
         
            +
                rb_cNthRefNode = rb_define_class_under(module, "NthRefNode", rb_cObject);
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
      
 342 
     | 
    
         
            +
                rb_cBackRefNode = rb_define_class_under(module, "BackRefNode", rb_cObject);
         
     | 
| 
      
 343 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #ifndef KANAYAGO_LITERAL_NODE_H
         
     | 
| 
      
 2 
     | 
    
         
            +
            #define KANAYAGO_LITERAL_NODE_H
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #include "internal/ruby_parser.h"
         
     | 
| 
      
 5 
     | 
    
         
            +
            #include "kanayago.h"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            VALUE integer_node_new(const NODE *);
         
     | 
| 
      
 8 
     | 
    
         
            +
            VALUE float_node_new(const NODE *);
         
     | 
| 
      
 9 
     | 
    
         
            +
            VALUE rational_node_new(const NODE *);
         
     | 
| 
      
 10 
     | 
    
         
            +
            VALUE imaginary_node_new(const NODE *);
         
     | 
| 
      
 11 
     | 
    
         
            +
            VALUE symbol_node_new(const NODE *);
         
     | 
| 
      
 12 
     | 
    
         
            +
            VALUE string_node_new(const NODE *);
         
     | 
| 
      
 13 
     | 
    
         
            +
            VALUE zero_list_node_new(const NODE *);
         
     | 
| 
      
 14 
     | 
    
         
            +
            VALUE file_node_new(const NODE *node);
         
     | 
| 
      
 15 
     | 
    
         
            +
            VALUE line_node_new(const NODE *);
         
     | 
| 
      
 16 
     | 
    
         
            +
            VALUE encoding_node_new(const NODE *);
         
     | 
| 
      
 17 
     | 
    
         
            +
            VALUE nil_node_new(const NODE *);
         
     | 
| 
      
 18 
     | 
    
         
            +
            VALUE true_node_new(const NODE *);
         
     | 
| 
      
 19 
     | 
    
         
            +
            VALUE false_node_new(const NODE *);
         
     | 
| 
      
 20 
     | 
    
         
            +
            VALUE range_node_new(const NODE *);
         
     | 
| 
      
 21 
     | 
    
         
            +
            VALUE exclusive_range_node_new(const NODE *);
         
     | 
| 
      
 22 
     | 
    
         
            +
            VALUE flip_flop_node_new(const NODE *);
         
     | 
| 
      
 23 
     | 
    
         
            +
            VALUE exclusive_flip_flop_node_new(const NODE *);
         
     | 
| 
      
 24 
     | 
    
         
            +
            VALUE hash_node_new(const NODE *);
         
     | 
| 
      
 25 
     | 
    
         
            +
            VALUE nth_ref_node_new(const NODE *);
         
     | 
| 
      
 26 
     | 
    
         
            +
            VALUE back_ref_node_new(const NODE *);
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            void Init_LiteralNode(VALUE);
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            #endif
         
     | 
| 
         @@ -0,0 +1,78 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include "pattern_node.h"
         
     | 
| 
      
 2 
     | 
    
         
            +
            #include "internal/ruby_parser.h"
         
     | 
| 
      
 3 
     | 
    
         
            +
            #include "kanayago.h"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            VALUE rb_cInNode;
         
     | 
| 
      
 6 
     | 
    
         
            +
            VALUE rb_cArrayPatternNode;
         
     | 
| 
      
 7 
     | 
    
         
            +
            VALUE rb_cHashPatternNode;
         
     | 
| 
      
 8 
     | 
    
         
            +
            VALUE rb_cFindPatternNode;
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 11 
     | 
    
         
            +
            in_node_new(const NODE *node)
         
     | 
| 
      
 12 
     | 
    
         
            +
            {
         
     | 
| 
      
 13 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cInNode);
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@head"), ast_to_node_instance(RNODE_IN(node)->nd_head));
         
     | 
| 
      
 16 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@body"), ast_to_node_instance(RNODE_IN(node)->nd_body));
         
     | 
| 
      
 17 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@next"), ast_to_node_instance(RNODE_IN(node)->nd_next));
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 20 
     | 
    
         
            +
            }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 23 
     | 
    
         
            +
            array_pattern_node_new(const NODE *node)
         
     | 
| 
      
 24 
     | 
    
         
            +
            {
         
     | 
| 
      
 25 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cArrayPatternNode);
         
     | 
| 
      
 26 
     | 
    
         
            +
                NODE *rest_arg = RNODE_ARYPTN(node)->rest_arg;
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pconst"), ast_to_node_instance(RNODE_ARYPTN(node)->nd_pconst));
         
     | 
| 
      
 29 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pre_args"), ast_to_node_instance(RNODE_ARYPTN(node)->pre_args));
         
     | 
| 
      
 30 
     | 
    
         
            +
                // rest_arg can be NODE_SPECIAL_NO_NAME_REST (-1), which should be preserved as a special marker
         
     | 
| 
      
 31 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@rest_arg"),
         
     | 
| 
      
 32 
     | 
    
         
            +
                            (rest_arg == (NODE *)-1) ? INT2FIX(-1) : ast_to_node_instance(rest_arg));
         
     | 
| 
      
 33 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@post_args"), ast_to_node_instance(RNODE_ARYPTN(node)->post_args));
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 36 
     | 
    
         
            +
            }
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 39 
     | 
    
         
            +
            hash_pattern_node_new(const NODE *node)
         
     | 
| 
      
 40 
     | 
    
         
            +
            {
         
     | 
| 
      
 41 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cHashPatternNode);
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pconst"), ast_to_node_instance(RNODE_HSHPTN(node)->nd_pconst));
         
     | 
| 
      
 44 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pkwargs"), ast_to_node_instance(RNODE_HSHPTN(node)->nd_pkwargs));
         
     | 
| 
      
 45 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pkwrestarg"), ast_to_node_instance(RNODE_HSHPTN(node)->nd_pkwrestarg));
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 48 
     | 
    
         
            +
            }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 51 
     | 
    
         
            +
            find_pattern_node_new(const NODE *node)
         
     | 
| 
      
 52 
     | 
    
         
            +
            {
         
     | 
| 
      
 53 
     | 
    
         
            +
                VALUE obj = rb_class_new_instance(0, 0, rb_cFindPatternNode);
         
     | 
| 
      
 54 
     | 
    
         
            +
                NODE *pre_rest_arg = RNODE_FNDPTN(node)->pre_rest_arg;
         
     | 
| 
      
 55 
     | 
    
         
            +
                NODE *post_rest_arg = RNODE_FNDPTN(node)->post_rest_arg;
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pconst"), ast_to_node_instance(RNODE_FNDPTN(node)->nd_pconst));
         
     | 
| 
      
 58 
     | 
    
         
            +
                // rest args can be NODE_SPECIAL_NO_NAME_REST (-1)
         
     | 
| 
      
 59 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@pre_rest_arg"),
         
     | 
| 
      
 60 
     | 
    
         
            +
                            (pre_rest_arg == (NODE *)-1) ? INT2FIX(-1) : ast_to_node_instance(pre_rest_arg));
         
     | 
| 
      
 61 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@args"), ast_to_node_instance(RNODE_FNDPTN(node)->args));
         
     | 
| 
      
 62 
     | 
    
         
            +
                rb_ivar_set(obj, rb_intern("@post_rest_arg"),
         
     | 
| 
      
 63 
     | 
    
         
            +
                            (post_rest_arg == (NODE *)-1) ? INT2FIX(-1) : ast_to_node_instance(post_rest_arg));
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                return obj;
         
     | 
| 
      
 66 
     | 
    
         
            +
            }
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            void
         
     | 
| 
      
 69 
     | 
    
         
            +
            Init_PatternNode(VALUE module)
         
     | 
| 
      
 70 
     | 
    
         
            +
            {
         
     | 
| 
      
 71 
     | 
    
         
            +
                rb_cInNode = rb_define_class_under(module, "InNode", rb_cObject);
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                rb_cArrayPatternNode = rb_define_class_under(module, "ArrayPatternNode", rb_cObject);
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                rb_cHashPatternNode = rb_define_class_under(module, "HashPatternNode", rb_cObject);
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                rb_cFindPatternNode = rb_define_class_under(module, "FindPatternNode", rb_cObject);
         
     | 
| 
      
 78 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #ifndef KANAYAGO_PATTERN_NODE_H
         
     | 
| 
      
 2 
     | 
    
         
            +
            #define KANAYAGO_PATTERN_NODE_H
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #include "kanayago.h"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            VALUE in_node_new(const NODE *);
         
     | 
| 
      
 7 
     | 
    
         
            +
            VALUE array_pattern_node_new(const NODE *);
         
     | 
| 
      
 8 
     | 
    
         
            +
            VALUE hash_pattern_node_new(const NODE *);
         
     | 
| 
      
 9 
     | 
    
         
            +
            VALUE find_pattern_node_new(const NODE *);
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            void Init_PatternNode(VALUE);
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            #endif
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include "kanayago.h"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            VALUE rb_cScopeNode;
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 6 
     | 
    
         
            +
            scope_node_new(const NODE *node)
         
     | 
| 
      
 7 
     | 
    
         
            +
            {
         
     | 
| 
      
 8 
     | 
    
         
            +
                VALUE result = rb_class_new_instance(0, 0, rb_cScopeNode);
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                rb_ivar_set(result, symbol("args"), ast_to_node_instance((const NODE *)(RNODE_SCOPE(node)->nd_args)));
         
     | 
| 
      
 11 
     | 
    
         
            +
                rb_ivar_set(result, symbol("body"), ast_to_node_instance(RNODE_SCOPE(node)->nd_body));
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 14 
     | 
    
         
            +
            }
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 17 
     | 
    
         
            +
            scope_node_args_get(VALUE self)
         
     | 
| 
      
 18 
     | 
    
         
            +
            {
         
     | 
| 
      
 19 
     | 
    
         
            +
                return rb_ivar_get(self, symbol("args"));
         
     | 
| 
      
 20 
     | 
    
         
            +
            }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 23 
     | 
    
         
            +
            scope_node_body_get(VALUE self)
         
     | 
| 
      
 24 
     | 
    
         
            +
            {
         
     | 
| 
      
 25 
     | 
    
         
            +
                return rb_ivar_get(self, symbol("body"));
         
     | 
| 
      
 26 
     | 
    
         
            +
            }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            void
         
     | 
| 
      
 29 
     | 
    
         
            +
            Init_ScopeNode(VALUE module)
         
     | 
| 
      
 30 
     | 
    
         
            +
            {
         
     | 
| 
      
 31 
     | 
    
         
            +
                rb_cScopeNode = rb_define_class_under(module, "ScopeNode", rb_cObject);
         
     | 
| 
      
 32 
     | 
    
         
            +
                rb_define_method(rb_cScopeNode, "args", scope_node_args_get, 0);
         
     | 
| 
      
 33 
     | 
    
         
            +
                rb_define_method(rb_cScopeNode, "body", scope_node_body_get, 0);
         
     | 
| 
      
 34 
     | 
    
         
            +
            }
         
     |