sydparse 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/Rakefile +1 -1
- data/bin/syd_pt_show +9 -1
- data/lib/sydparse.rb +1 -1
- data/node.h +5 -3
- data/pstate.h +76 -0
- data/runtime.c +56 -9
- data/runtime.h +1 -66
- data/sydparse.c +112 -91
- data/sydparse.y +118 -96
- metadata +3 -2
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
data/bin/syd_pt_show
CHANGED
@@ -10,6 +10,9 @@ if ARGV.first == "-l"
|
|
10
10
|
elsif ARGV.first == "-u"
|
11
11
|
unified = true
|
12
12
|
ARGV.shift
|
13
|
+
elsif ARGV.first == "-s"
|
14
|
+
simple = true
|
15
|
+
ARGV.shift
|
13
16
|
end
|
14
17
|
|
15
18
|
name = ARGV.shift
|
@@ -18,6 +21,11 @@ File.open(name, "r") do |fd|
|
|
18
21
|
pp SydneyParser.unified_sexp(fd)
|
19
22
|
else
|
20
23
|
syd = SydneyParser.load_file fd
|
21
|
-
|
24
|
+
out = syd.sexp(false, newlines)
|
25
|
+
if simple
|
26
|
+
p out
|
27
|
+
else
|
28
|
+
pp out
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/sydparse.rb
CHANGED
data/node.h
CHANGED
@@ -153,6 +153,8 @@ typedef struct RNode {
|
|
153
153
|
} u3;
|
154
154
|
} NODE;
|
155
155
|
|
156
|
+
#include "pstate.h"
|
157
|
+
|
156
158
|
#define RNODE(obj) (R_CAST(RNode)(obj))
|
157
159
|
|
158
160
|
#define nd_type(n) ((int)(((RNODE(n))->flags>>FL_USHIFT)&0xff))
|
@@ -233,7 +235,7 @@ typedef struct RNode {
|
|
233
235
|
#define nd_tag u1.id
|
234
236
|
#define nd_tval u2.value
|
235
237
|
|
236
|
-
#define NEW_NODE(t,a0,a1,a2) syd_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
|
238
|
+
#define NEW_NODE(t,a0,a1,a2) syd_node_newnode(parse_state, (t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
|
237
239
|
|
238
240
|
#define NEW_METHOD(n,x) NEW_NODE(NODE_METHOD,x,n,0)
|
239
241
|
#define NEW_FBODY(n,i,o) NEW_NODE(NODE_FBODY,n,i,o)
|
@@ -241,7 +243,7 @@ typedef struct RNode {
|
|
241
243
|
#define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_RFUNC(a,d))
|
242
244
|
#define NEW_CFUNC(f,c) NEW_NODE(NODE_CFUNC,f,c,0)
|
243
245
|
#define NEW_IFUNC(f,c) NEW_NODE(NODE_IFUNC,f,c,0)
|
244
|
-
#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
|
246
|
+
#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(vps, b1,b2))
|
245
247
|
#define NEW_SCOPE(b) NEW_NODE(NODE_SCOPE,syd_local_tbl(vps),0,(b))
|
246
248
|
#define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
|
247
249
|
#define NEW_IF(c,t,e) NEW_NODE(NODE_IF,c,t,e)
|
@@ -349,7 +351,7 @@ typedef struct RNode {
|
|
349
351
|
NODE *rb_compile_cstr _((const char*, const char*, int, int));
|
350
352
|
|
351
353
|
void rb_add_method _((VALUE, ID, NODE *, int));
|
352
|
-
NODE *syd_node_newnode _((enum node_type,VALUE,VALUE,VALUE));
|
354
|
+
NODE *syd_node_newnode _((rb_parse_state*, enum node_type,VALUE,VALUE,VALUE));
|
353
355
|
|
354
356
|
NODE* rb_method_node _((VALUE klass, ID id));
|
355
357
|
|
data/pstate.h
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#ifndef __SYD_PSTATE__
|
2
|
+
#define __SYD_PSTATE__ 1
|
3
|
+
|
4
|
+
enum lex_state {
|
5
|
+
EXPR_BEG, /* ignore newline, +/- is a sign. */
|
6
|
+
EXPR_END, /* newline significant, +/- is a operator. */
|
7
|
+
EXPR_ARG, /* newline significant, +/- is a operator. */
|
8
|
+
EXPR_CMDARG, /* newline significant, +/- is a operator. */
|
9
|
+
EXPR_ENDARG, /* newline significant, +/- is a operator. */
|
10
|
+
EXPR_MID, /* newline significant, +/- is a operator. */
|
11
|
+
EXPR_FNAME, /* ignore newline, no reserved words. */
|
12
|
+
EXPR_DOT, /* right after `.' or `::', no reserved words. */
|
13
|
+
EXPR_CLASS, /* immediate after `class', no here document. */
|
14
|
+
};
|
15
|
+
|
16
|
+
struct METHOD {
|
17
|
+
VALUE klass, rklass;
|
18
|
+
VALUE recv;
|
19
|
+
ID id, oid;
|
20
|
+
NODE *body;
|
21
|
+
};
|
22
|
+
|
23
|
+
#ifdef HAVE_LONG_LONG
|
24
|
+
typedef unsigned LONG_LONG stack_type;
|
25
|
+
#else
|
26
|
+
typedef unsigned long stack_type;
|
27
|
+
#endif
|
28
|
+
|
29
|
+
typedef struct rb_parse_state {
|
30
|
+
int end_seen;
|
31
|
+
VALUE debug_lines;
|
32
|
+
int heredoc_end;
|
33
|
+
int command_start;
|
34
|
+
NODE *lex_strterm;
|
35
|
+
int class_nest;
|
36
|
+
int in_single;
|
37
|
+
int in_def;
|
38
|
+
int compile_for_eval;
|
39
|
+
ID cur_mid;
|
40
|
+
char *token_buffer;
|
41
|
+
int tokidx;
|
42
|
+
int toksiz;
|
43
|
+
|
44
|
+
VALUE (*lex_gets)(); /* gets function */
|
45
|
+
VALUE lex_input; /* non-nil if File */
|
46
|
+
VALUE lex_lastline; /* gc protect */
|
47
|
+
char *lex_pbeg;
|
48
|
+
char *lex_p;
|
49
|
+
char *lex_pend;
|
50
|
+
int lex_gets_ptr;
|
51
|
+
|
52
|
+
enum lex_state lex_state;
|
53
|
+
int in_defined;
|
54
|
+
stack_type cond_stack;
|
55
|
+
stack_type cmdarg_stack;
|
56
|
+
|
57
|
+
void *lval; /* the parser's yylval */
|
58
|
+
|
59
|
+
VALUE comments;
|
60
|
+
int column;
|
61
|
+
NODE *top;
|
62
|
+
ID *locals;
|
63
|
+
|
64
|
+
VALUE self;
|
65
|
+
|
66
|
+
int ternary_colon;
|
67
|
+
|
68
|
+
void **memory_pools;
|
69
|
+
int pool_size, current_pool;
|
70
|
+
char *memory_cur;
|
71
|
+
char *memory_last_addr;
|
72
|
+
int memory_size;
|
73
|
+
|
74
|
+
} rb_parse_state;
|
75
|
+
|
76
|
+
#endif
|
data/runtime.c
CHANGED
@@ -17,6 +17,12 @@ rb_parse_state *alloc_parse_state() {
|
|
17
17
|
st->tokidx = 0;
|
18
18
|
st->toksiz = 0;
|
19
19
|
st->comments = 0;
|
20
|
+
st->memory_cur = NULL;
|
21
|
+
st->memory_last_addr = NULL;
|
22
|
+
st->current_pool = 0;
|
23
|
+
st->pool_size = 0;
|
24
|
+
st->memory_size = 204800;
|
25
|
+
st->memory_pools = NULL;
|
20
26
|
|
21
27
|
return st;
|
22
28
|
}
|
@@ -24,21 +30,21 @@ rb_parse_state *alloc_parse_state() {
|
|
24
30
|
void *rb_pt_mark(void *vps) {
|
25
31
|
rb_parse_state *parse_state = (rb_parse_state*)vps;
|
26
32
|
|
27
|
-
// rb_gc_mark_maybe((VALUE)(parse_state->lval->node));
|
28
33
|
rb_gc_mark(parse_state->lex_lastline);
|
29
34
|
rb_gc_mark(parse_state->lex_input);
|
30
35
|
rb_gc_mark(parse_state->self);
|
31
|
-
rb_gc_mark((VALUE)parse_state->top);
|
32
36
|
return NULL;
|
33
37
|
}
|
34
38
|
|
39
|
+
void pt_free();
|
40
|
+
|
35
41
|
VALUE rb_cSydParser;
|
36
42
|
|
37
43
|
VALUE rb_pt_create() {
|
38
44
|
VALUE obj;
|
39
45
|
rb_parse_state *st;
|
40
46
|
st = alloc_parse_state();
|
41
|
-
obj = Data_Wrap_Struct(rb_cSydParser, rb_pt_mark,
|
47
|
+
obj = Data_Wrap_Struct(rb_cSydParser, rb_pt_mark, pt_free, st);
|
42
48
|
st->self = obj;
|
43
49
|
return obj;
|
44
50
|
}
|
@@ -205,7 +211,43 @@ NODE *rb_pt_top(VALUE self) {
|
|
205
211
|
Data_Get_Struct(self, rb_parse_state, st);
|
206
212
|
return st->top;
|
207
213
|
}
|
208
|
-
|
214
|
+
|
215
|
+
void *pt_allocate(rb_parse_state *st, int size) {
|
216
|
+
void *ptr;
|
217
|
+
void *cur;
|
218
|
+
|
219
|
+
if(!st->memory_cur || ((st->memory_cur + size) >= st->memory_last_addr)) {
|
220
|
+
if(st->memory_cur) st->current_pool++;
|
221
|
+
|
222
|
+
if(st->current_pool == st->pool_size) {
|
223
|
+
st->pool_size += 10;
|
224
|
+
if(st->memory_pools) {
|
225
|
+
st->memory_pools = (void**)realloc(st->memory_pools, sizeof(void*) * st->pool_size);
|
226
|
+
} else {
|
227
|
+
st->memory_pools = (void**)malloc(sizeof(void*) * st->pool_size);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
st->memory_pools[st->current_pool] = malloc(st->memory_size);
|
231
|
+
st->memory_cur = st->memory_pools[st->current_pool];
|
232
|
+
memset(st->memory_cur, 0, st->memory_size);
|
233
|
+
st->memory_last_addr = st->memory_cur + st->memory_size - 1;
|
234
|
+
}
|
235
|
+
|
236
|
+
cur = (void*)st->memory_cur;
|
237
|
+
st->memory_cur = st->memory_cur + size;
|
238
|
+
|
239
|
+
return cur;
|
240
|
+
}
|
241
|
+
|
242
|
+
void pt_free(rb_parse_state *st) {
|
243
|
+
int i;
|
244
|
+
if(!st->memory_pools) return;
|
245
|
+
|
246
|
+
for(i = 0; i <= st->current_pool; i++) {
|
247
|
+
free(st->memory_pools[i]);
|
248
|
+
}
|
249
|
+
free(st->memory_pools);
|
250
|
+
}
|
209
251
|
|
210
252
|
/*
|
211
253
|
*
|
@@ -676,7 +718,7 @@ again_no_block:
|
|
676
718
|
rb_ary_push(current, ID2SYM(rb_intern("xstr_custom")));
|
677
719
|
rb_ary_push(current, ID2SYM(node->u2.id));
|
678
720
|
}
|
679
|
-
rb_ary_push(current,
|
721
|
+
rb_ary_push(current, rb_str_new4(node->nd_lit));
|
680
722
|
while (list) {
|
681
723
|
if (list->nd_head) {
|
682
724
|
switch (nd_type(list->nd_head)) {
|
@@ -803,11 +845,14 @@ again_no_block:
|
|
803
845
|
|
804
846
|
case NODE_XSTR: /* u1 (%x{ls}) */
|
805
847
|
case NODE_STR: /* u1 */
|
806
|
-
|
848
|
+
rb_ary_push(current, rb_str_dup(node->nd_lit));
|
849
|
+
break;
|
807
850
|
case NODE_MATCH:
|
851
|
+
rb_ary_push(current, rb_obj_dup(node->nd_lit));
|
852
|
+
break;
|
853
|
+
case NODE_LIT:
|
808
854
|
rb_ary_push(current, node->nd_lit);
|
809
855
|
break;
|
810
|
-
|
811
856
|
case NODE_NEWLINE:
|
812
857
|
ADD_LINE;
|
813
858
|
|
@@ -858,7 +903,8 @@ again_no_block:
|
|
858
903
|
case NODE_ATTRASGN: /* literal.meth = y u1 u2 u3 */
|
859
904
|
/* node id node */
|
860
905
|
if (node->nd_1st == RNODE(1)) {
|
861
|
-
|
906
|
+
rb_ary_push(current, rb_ary_new3(1, ID2SYM(rb_intern("self"))));
|
907
|
+
// add_to_parse_tree(current, Qnil, newlines, locals, line_numbers);
|
862
908
|
} else {
|
863
909
|
add_to_parse_tree(current, node->nd_1st, newlines, locals, line_numbers);
|
864
910
|
}
|
@@ -915,6 +961,8 @@ again_no_block:
|
|
915
961
|
}
|
916
962
|
}
|
917
963
|
|
964
|
+
void rb_add_to_parse_tree(VALUE, NODE*, int, void*);
|
965
|
+
|
918
966
|
VALUE rb_pt_sexp(int argc, VALUE *argv, VALUE self) {
|
919
967
|
rb_parse_state *st;
|
920
968
|
VALUE result;
|
@@ -949,7 +997,6 @@ VALUE rb_pt_comments(VALUE self) {
|
|
949
997
|
}
|
950
998
|
}
|
951
999
|
|
952
|
-
|
953
1000
|
void Init_sydney_parser() {
|
954
1001
|
VALUE cParser;
|
955
1002
|
setup_parser();
|
data/runtime.h
CHANGED
@@ -1,69 +1,5 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
VALUE klass, rklass;
|
4
|
-
VALUE recv;
|
5
|
-
ID id, oid;
|
6
|
-
NODE *body;
|
7
|
-
};
|
8
|
-
|
9
|
-
enum lex_state {
|
10
|
-
EXPR_BEG, /* ignore newline, +/- is a sign. */
|
11
|
-
EXPR_END, /* newline significant, +/- is a operator. */
|
12
|
-
EXPR_ARG, /* newline significant, +/- is a operator. */
|
13
|
-
EXPR_CMDARG, /* newline significant, +/- is a operator. */
|
14
|
-
EXPR_ENDARG, /* newline significant, +/- is a operator. */
|
15
|
-
EXPR_MID, /* newline significant, +/- is a operator. */
|
16
|
-
EXPR_FNAME, /* ignore newline, no reserved words. */
|
17
|
-
EXPR_DOT, /* right after `.' or `::', no reserved words. */
|
18
|
-
EXPR_CLASS, /* immediate after `class', no here document. */
|
19
|
-
};
|
20
|
-
|
21
|
-
#ifdef HAVE_LONG_LONG
|
22
|
-
typedef unsigned LONG_LONG stack_type;
|
23
|
-
#else
|
24
|
-
typedef unsigned long stack_type;
|
25
|
-
#endif
|
26
|
-
|
27
|
-
typedef struct rb_parse_state {
|
28
|
-
int end_seen;
|
29
|
-
VALUE debug_lines;
|
30
|
-
int heredoc_end;
|
31
|
-
int command_start;
|
32
|
-
NODE *lex_strterm;
|
33
|
-
int class_nest;
|
34
|
-
int in_single;
|
35
|
-
int in_def;
|
36
|
-
int compile_for_eval;
|
37
|
-
ID cur_mid;
|
38
|
-
char *token_buffer;
|
39
|
-
int tokidx;
|
40
|
-
int toksiz;
|
41
|
-
|
42
|
-
VALUE (*lex_gets)(); /* gets function */
|
43
|
-
VALUE lex_input; /* non-nil if File */
|
44
|
-
VALUE lex_lastline; /* gc protect */
|
45
|
-
char *lex_pbeg;
|
46
|
-
char *lex_p;
|
47
|
-
char *lex_pend;
|
48
|
-
int lex_gets_ptr;
|
49
|
-
|
50
|
-
enum lex_state lex_state;
|
51
|
-
int in_defined;
|
52
|
-
stack_type cond_stack;
|
53
|
-
stack_type cmdarg_stack;
|
54
|
-
|
55
|
-
void *lval; /* the parser's yylval */
|
56
|
-
|
57
|
-
VALUE comments;
|
58
|
-
int column;
|
59
|
-
NODE *top;
|
60
|
-
ID *locals;
|
61
|
-
|
62
|
-
VALUE self;
|
63
|
-
|
64
|
-
int ternary_colon;
|
65
|
-
|
66
|
-
} rb_parse_state;
|
2
|
+
#include "pstate.h"
|
67
3
|
|
68
4
|
rb_parse_state *alloc_parse_state();
|
69
5
|
|
@@ -192,4 +128,3 @@ VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
|
|
192
128
|
|
193
129
|
#define PUSH_CREF(c) ruby_cref = NEW_NODE(NODE_CREF,(c),0,ruby_cref)
|
194
130
|
#define POP_CREF() ruby_cref = ruby_cref->nd_next
|
195
|
-
|
data/sydparse.c
CHANGED
@@ -3602,7 +3602,7 @@ case 2:
|
|
3602
3602
|
void_expr(node->nd_head);
|
3603
3603
|
}
|
3604
3604
|
}
|
3605
|
-
vps->top = block_append(vps->top, yyvsp[0].node);
|
3605
|
+
vps->top = block_append(parse_state, vps->top, yyvsp[0].node);
|
3606
3606
|
//vps->top = NEW_SCOPE(block_append(vps->top, $2));
|
3607
3607
|
rb_funcall(vps->self, rb_intern("local_finish"), 0);
|
3608
3608
|
|
@@ -3619,7 +3619,7 @@ case 3:
|
|
3619
3619
|
}
|
3620
3620
|
else if (yyvsp[-1].node) {
|
3621
3621
|
rb_warn("else without rescue is useless");
|
3622
|
-
yyval.node = block_append(yyval.node, yyvsp[-1].node);
|
3622
|
+
yyval.node = block_append(parse_state, yyval.node, yyvsp[-1].node);
|
3623
3623
|
}
|
3624
3624
|
if (yyvsp[0].node) {
|
3625
3625
|
yyval.node = NEW_ENSURE(yyval.node, yyvsp[0].node);
|
@@ -3637,13 +3637,13 @@ case 4:
|
|
3637
3637
|
case 6:
|
3638
3638
|
#line 418 "sydparse.y"
|
3639
3639
|
{
|
3640
|
-
yyval.node = newline_node(yyvsp[0].node);
|
3640
|
+
yyval.node = newline_node(parse_state, yyvsp[0].node);
|
3641
3641
|
;
|
3642
3642
|
break;}
|
3643
3643
|
case 7:
|
3644
3644
|
#line 422 "sydparse.y"
|
3645
3645
|
{
|
3646
|
-
yyval.node = block_append(yyvsp[-2].node, newline_node(yyvsp[0].node));
|
3646
|
+
yyval.node = block_append(parse_state, yyvsp[-2].node, newline_node(parse_state, yyvsp[0].node));
|
3647
3647
|
;
|
3648
3648
|
break;}
|
3649
3649
|
case 8:
|
@@ -3826,7 +3826,7 @@ case 26:
|
|
3826
3826
|
args = NEW_LIST(yyvsp[0].node);
|
3827
3827
|
if (yyvsp[-3].node && nd_type(yyvsp[-3].node) != NODE_ARRAY)
|
3828
3828
|
yyvsp[-3].node = NEW_LIST(yyvsp[-3].node);
|
3829
|
-
yyvsp[-3].node = list_append(yyvsp[-3].node, NEW_NIL());
|
3829
|
+
yyvsp[-3].node = list_append(parse_state, yyvsp[-3].node, NEW_NIL());
|
3830
3830
|
list_concat(args, yyvsp[-3].node);
|
3831
3831
|
if (yyvsp[-1].id == tOROP) {
|
3832
3832
|
yyvsp[-1].id = 0;
|
@@ -3959,13 +3959,13 @@ case 46:
|
|
3959
3959
|
case 48:
|
3960
3960
|
#line 682 "sydparse.y"
|
3961
3961
|
{
|
3962
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
3962
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
3963
3963
|
;
|
3964
3964
|
break;}
|
3965
3965
|
case 49:
|
3966
3966
|
#line 686 "sydparse.y"
|
3967
3967
|
{
|
3968
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
3968
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
3969
3969
|
;
|
3970
3970
|
break;}
|
3971
3971
|
case 50:
|
@@ -3990,14 +3990,14 @@ case 52:
|
|
3990
3990
|
case 53:
|
3991
3991
|
#line 707 "sydparse.y"
|
3992
3992
|
{
|
3993
|
-
yyval.node = new_fcall(yyvsp[-1].id, yyvsp[0].node);
|
3993
|
+
yyval.node = new_fcall(parse_state, yyvsp[-1].id, yyvsp[0].node);
|
3994
3994
|
fixpos(yyval.node, yyvsp[0].node);
|
3995
3995
|
;
|
3996
3996
|
break;}
|
3997
3997
|
case 54:
|
3998
3998
|
#line 712 "sydparse.y"
|
3999
3999
|
{
|
4000
|
-
yyval.node = new_fcall(yyvsp[-2].id, yyvsp[-1].node);
|
4000
|
+
yyval.node = new_fcall(parse_state, yyvsp[-2].id, yyvsp[-1].node);
|
4001
4001
|
if (yyvsp[0].node) {
|
4002
4002
|
if (nd_type(yyval.node) == NODE_BLOCK_PASS) {
|
4003
4003
|
rb_compile_error("both block arg and actual block given");
|
@@ -4011,14 +4011,14 @@ case 54:
|
|
4011
4011
|
case 55:
|
4012
4012
|
#line 724 "sydparse.y"
|
4013
4013
|
{
|
4014
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
4014
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
4015
4015
|
fixpos(yyval.node, yyvsp[-3].node);
|
4016
4016
|
;
|
4017
4017
|
break;}
|
4018
4018
|
case 56:
|
4019
4019
|
#line 729 "sydparse.y"
|
4020
4020
|
{
|
4021
|
-
yyval.node = new_call(yyvsp[-4].node, yyvsp[-2].id, yyvsp[-1].node);
|
4021
|
+
yyval.node = new_call(parse_state, yyvsp[-4].node, yyvsp[-2].id, yyvsp[-1].node);
|
4022
4022
|
if (yyvsp[0].node) {
|
4023
4023
|
if (nd_type(yyval.node) == NODE_BLOCK_PASS) {
|
4024
4024
|
rb_compile_error("both block arg and actual block given");
|
@@ -4032,14 +4032,14 @@ case 56:
|
|
4032
4032
|
case 57:
|
4033
4033
|
#line 741 "sydparse.y"
|
4034
4034
|
{
|
4035
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
4035
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
4036
4036
|
fixpos(yyval.node, yyvsp[-3].node);
|
4037
4037
|
;
|
4038
4038
|
break;}
|
4039
4039
|
case 58:
|
4040
4040
|
#line 746 "sydparse.y"
|
4041
4041
|
{
|
4042
|
-
yyval.node = new_call(yyvsp[-4].node, yyvsp[-2].id, yyvsp[-1].node);
|
4042
|
+
yyval.node = new_call(parse_state, yyvsp[-4].node, yyvsp[-2].id, yyvsp[-1].node);
|
4043
4043
|
if (yyvsp[0].node) {
|
4044
4044
|
if (nd_type(yyval.node) == NODE_BLOCK_PASS) {
|
4045
4045
|
rb_compile_error("both block arg and actual block given");
|
@@ -4053,14 +4053,14 @@ case 58:
|
|
4053
4053
|
case 59:
|
4054
4054
|
#line 758 "sydparse.y"
|
4055
4055
|
{
|
4056
|
-
yyval.node = new_super(yyvsp[0].node);
|
4056
|
+
yyval.node = new_super(parse_state, yyvsp[0].node);
|
4057
4057
|
fixpos(yyval.node, yyvsp[0].node);
|
4058
4058
|
;
|
4059
4059
|
break;}
|
4060
4060
|
case 60:
|
4061
4061
|
#line 763 "sydparse.y"
|
4062
4062
|
{
|
4063
|
-
yyval.node = new_yield(yyvsp[0].node);
|
4063
|
+
yyval.node = new_yield(parse_state, yyvsp[0].node);
|
4064
4064
|
fixpos(yyval.node, yyvsp[0].node);
|
4065
4065
|
;
|
4066
4066
|
break;}
|
@@ -4085,7 +4085,7 @@ case 65:
|
|
4085
4085
|
case 66:
|
4086
4086
|
#line 788 "sydparse.y"
|
4087
4087
|
{
|
4088
|
-
yyval.node = NEW_MASGN(list_append(yyvsp[-1].node,yyvsp[0].node), 0);
|
4088
|
+
yyval.node = NEW_MASGN(list_append(parse_state, yyvsp[-1].node,yyvsp[0].node), 0);
|
4089
4089
|
;
|
4090
4090
|
break;}
|
4091
4091
|
case 67:
|
@@ -4127,7 +4127,7 @@ case 73:
|
|
4127
4127
|
case 74:
|
4128
4128
|
#line 821 "sydparse.y"
|
4129
4129
|
{
|
4130
|
-
yyval.node = list_append(yyvsp[-2].node, yyvsp[-1].node);
|
4130
|
+
yyval.node = list_append(parse_state, yyvsp[-2].node, yyvsp[-1].node);
|
4131
4131
|
;
|
4132
4132
|
break;}
|
4133
4133
|
case 75:
|
@@ -4287,7 +4287,7 @@ case 104:
|
|
4287
4287
|
case 105:
|
4288
4288
|
#line 949 "sydparse.y"
|
4289
4289
|
{
|
4290
|
-
yyval.node = block_append(yyvsp[-3].node, NEW_UNDEF(yyvsp[0].id));
|
4290
|
+
yyval.node = block_append(parse_state, yyvsp[-3].node, NEW_UNDEF(yyvsp[0].id));
|
4291
4291
|
;
|
4292
4292
|
break;}
|
4293
4293
|
case 106:
|
@@ -4442,7 +4442,7 @@ case 176:
|
|
4442
4442
|
args = NEW_LIST(yyvsp[0].node);
|
4443
4443
|
if (yyvsp[-3].node && nd_type(yyvsp[-3].node) != NODE_ARRAY)
|
4444
4444
|
yyvsp[-3].node = NEW_LIST(yyvsp[-3].node);
|
4445
|
-
yyvsp[-3].node = list_append(yyvsp[-3].node, NEW_NIL());
|
4445
|
+
yyvsp[-3].node = list_append(parse_state, yyvsp[-3].node, NEW_NIL());
|
4446
4446
|
list_concat(args, yyvsp[-3].node);
|
4447
4447
|
if (yyvsp[-1].id == tOROP) {
|
4448
4448
|
yyvsp[-1].id = 0;
|
@@ -4765,7 +4765,7 @@ case 223:
|
|
4765
4765
|
#line 1262 "sydparse.y"
|
4766
4766
|
{
|
4767
4767
|
value_expr(yyvsp[-1].node);
|
4768
|
-
yyval.node = arg_concat(yyvsp[-4].node, yyvsp[-1].node);
|
4768
|
+
yyval.node = arg_concat(parse_state, yyvsp[-4].node, yyvsp[-1].node);
|
4769
4769
|
;
|
4770
4770
|
break;}
|
4771
4771
|
case 224:
|
@@ -4804,7 +4804,7 @@ case 229:
|
|
4804
4804
|
#line 1291 "sydparse.y"
|
4805
4805
|
{
|
4806
4806
|
rb_warn("parenthesize argument for future version");
|
4807
|
-
yyval.node = list_append(yyvsp[-4].node, yyvsp[-2].node);
|
4807
|
+
yyval.node = list_append(parse_state, yyvsp[-4].node, yyvsp[-2].node);
|
4808
4808
|
;
|
4809
4809
|
break;}
|
4810
4810
|
case 232:
|
@@ -4823,7 +4823,7 @@ case 233:
|
|
4823
4823
|
case 234:
|
4824
4824
|
#line 1311 "sydparse.y"
|
4825
4825
|
{
|
4826
|
-
yyval.node = arg_concat(yyvsp[-4].node, yyvsp[-1].node);
|
4826
|
+
yyval.node = arg_concat(parse_state, yyvsp[-4].node, yyvsp[-1].node);
|
4827
4827
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4828
4828
|
;
|
4829
4829
|
break;}
|
@@ -4837,14 +4837,14 @@ case 235:
|
|
4837
4837
|
case 236:
|
4838
4838
|
#line 1321 "sydparse.y"
|
4839
4839
|
{
|
4840
|
-
yyval.node = arg_concat(NEW_LIST(NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4840
|
+
yyval.node = arg_concat(parse_state, NEW_LIST(NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4841
4841
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4842
4842
|
;
|
4843
4843
|
break;}
|
4844
4844
|
case 237:
|
4845
4845
|
#line 1326 "sydparse.y"
|
4846
4846
|
{
|
4847
|
-
yyval.node = list_append(yyvsp[-3].node, NEW_POSITIONAL(yyvsp[-1].node));
|
4847
|
+
yyval.node = list_append(parse_state, yyvsp[-3].node, NEW_POSITIONAL(yyvsp[-1].node));
|
4848
4848
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4849
4849
|
;
|
4850
4850
|
break;}
|
@@ -4852,7 +4852,7 @@ case 238:
|
|
4852
4852
|
#line 1331 "sydparse.y"
|
4853
4853
|
{
|
4854
4854
|
value_expr(yyvsp[-1].node);
|
4855
|
-
yyval.node = arg_concat(list_append(yyvsp[-6].node, NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4855
|
+
yyval.node = arg_concat(parse_state, list_append(parse_state, yyvsp[-6].node, NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4856
4856
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4857
4857
|
;
|
4858
4858
|
break;}
|
@@ -4877,14 +4877,14 @@ case 242:
|
|
4877
4877
|
case 243:
|
4878
4878
|
#line 1352 "sydparse.y"
|
4879
4879
|
{
|
4880
|
-
yyval.node = arg_concat(NEW_LIST(yyvsp[-4].node), yyvsp[-1].node);
|
4880
|
+
yyval.node = arg_concat(parse_state, NEW_LIST(yyvsp[-4].node), yyvsp[-1].node);
|
4881
4881
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4882
4882
|
;
|
4883
4883
|
break;}
|
4884
4884
|
case 244:
|
4885
4885
|
#line 1357 "sydparse.y"
|
4886
4886
|
{
|
4887
|
-
yyval.node = arg_concat(list_concat(NEW_LIST(yyvsp[-6].node),yyvsp[-4].node), yyvsp[-1].node);
|
4887
|
+
yyval.node = arg_concat(parse_state, list_concat(NEW_LIST(yyvsp[-6].node),yyvsp[-4].node), yyvsp[-1].node);
|
4888
4888
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4889
4889
|
;
|
4890
4890
|
break;}
|
@@ -4898,35 +4898,35 @@ case 245:
|
|
4898
4898
|
case 246:
|
4899
4899
|
#line 1367 "sydparse.y"
|
4900
4900
|
{
|
4901
|
-
yyval.node = arg_concat(NEW_LIST(NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4901
|
+
yyval.node = arg_concat(parse_state, NEW_LIST(NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4902
4902
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4903
4903
|
;
|
4904
4904
|
break;}
|
4905
4905
|
case 247:
|
4906
4906
|
#line 1372 "sydparse.y"
|
4907
4907
|
{
|
4908
|
-
yyval.node = list_append(NEW_LIST(yyvsp[-3].node), NEW_POSITIONAL(yyvsp[-1].node));
|
4908
|
+
yyval.node = list_append(parse_state, NEW_LIST(yyvsp[-3].node), NEW_POSITIONAL(yyvsp[-1].node));
|
4909
4909
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4910
4910
|
;
|
4911
4911
|
break;}
|
4912
4912
|
case 248:
|
4913
4913
|
#line 1377 "sydparse.y"
|
4914
4914
|
{
|
4915
|
-
yyval.node = list_append(list_concat(NEW_LIST(yyvsp[-5].node),yyvsp[-3].node), NEW_POSITIONAL(yyvsp[-1].node));
|
4915
|
+
yyval.node = list_append(parse_state, list_concat(NEW_LIST(yyvsp[-5].node),yyvsp[-3].node), NEW_POSITIONAL(yyvsp[-1].node));
|
4916
4916
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4917
4917
|
;
|
4918
4918
|
break;}
|
4919
4919
|
case 249:
|
4920
4920
|
#line 1382 "sydparse.y"
|
4921
4921
|
{
|
4922
|
-
yyval.node = arg_concat(list_append(NEW_LIST(yyvsp[-6].node), NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4922
|
+
yyval.node = arg_concat(parse_state, list_append(parse_state, NEW_LIST(yyvsp[-6].node), NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4923
4923
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4924
4924
|
;
|
4925
4925
|
break;}
|
4926
4926
|
case 250:
|
4927
4927
|
#line 1387 "sydparse.y"
|
4928
4928
|
{
|
4929
|
-
yyval.node = arg_concat(list_append(list_concat(NEW_LIST(yyvsp[-8].node), yyvsp[-6].node), NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4929
|
+
yyval.node = arg_concat(parse_state, list_append(parse_state, list_concat(NEW_LIST(yyvsp[-8].node), yyvsp[-6].node), NEW_POSITIONAL(yyvsp[-4].node)), yyvsp[-1].node);
|
4930
4930
|
yyval.node = arg_blk_pass(yyval.node, yyvsp[0].node);
|
4931
4931
|
;
|
4932
4932
|
break;}
|
@@ -4994,19 +4994,19 @@ case 263:
|
|
4994
4994
|
case 264:
|
4995
4995
|
#line 1441 "sydparse.y"
|
4996
4996
|
{
|
4997
|
-
yyval.node = list_append(yyvsp[-2].node, yyvsp[0].node);
|
4997
|
+
yyval.node = list_append(parse_state, yyvsp[-2].node, yyvsp[0].node);
|
4998
4998
|
;
|
4999
4999
|
break;}
|
5000
5000
|
case 265:
|
5001
5001
|
#line 1447 "sydparse.y"
|
5002
5002
|
{
|
5003
|
-
yyval.node = list_append(yyvsp[-2].node, yyvsp[0].node);
|
5003
|
+
yyval.node = list_append(parse_state, yyvsp[-2].node, yyvsp[0].node);
|
5004
5004
|
;
|
5005
5005
|
break;}
|
5006
5006
|
case 266:
|
5007
5007
|
#line 1451 "sydparse.y"
|
5008
5008
|
{
|
5009
|
-
yyval.node = arg_concat(yyvsp[-3].node, yyvsp[0].node);
|
5009
|
+
yyval.node = arg_concat(parse_state, yyvsp[-3].node, yyvsp[0].node);
|
5010
5010
|
;
|
5011
5011
|
break;}
|
5012
5012
|
case 267:
|
@@ -5103,7 +5103,7 @@ case 287:
|
|
5103
5103
|
case 288:
|
5104
5104
|
#line 1529 "sydparse.y"
|
5105
5105
|
{
|
5106
|
-
yyval.node = new_yield(yyvsp[-1].node);
|
5106
|
+
yyval.node = new_yield(parse_state, yyvsp[-1].node);
|
5107
5107
|
;
|
5108
5108
|
break;}
|
5109
5109
|
case 289:
|
@@ -5443,40 +5443,40 @@ case 347:
|
|
5443
5443
|
case 348:
|
5444
5444
|
#line 1813 "sydparse.y"
|
5445
5445
|
{
|
5446
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5446
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5447
5447
|
;
|
5448
5448
|
break;}
|
5449
5449
|
case 349:
|
5450
5450
|
#line 1817 "sydparse.y"
|
5451
5451
|
{
|
5452
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5452
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5453
5453
|
;
|
5454
5454
|
break;}
|
5455
5455
|
case 350:
|
5456
5456
|
#line 1823 "sydparse.y"
|
5457
5457
|
{
|
5458
|
-
yyval.node = new_fcall(yyvsp[-1].id, yyvsp[0].node);
|
5458
|
+
yyval.node = new_fcall(parse_state, yyvsp[-1].id, yyvsp[0].node);
|
5459
5459
|
fixpos(yyval.node, yyvsp[0].node);
|
5460
5460
|
;
|
5461
5461
|
break;}
|
5462
5462
|
case 351:
|
5463
5463
|
#line 1828 "sydparse.y"
|
5464
5464
|
{
|
5465
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5465
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5466
5466
|
fixpos(yyval.node, yyvsp[-3].node);
|
5467
5467
|
;
|
5468
5468
|
break;}
|
5469
5469
|
case 352:
|
5470
5470
|
#line 1833 "sydparse.y"
|
5471
5471
|
{
|
5472
|
-
yyval.node = new_call(yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5472
|
+
yyval.node = new_call(parse_state, yyvsp[-3].node, yyvsp[-1].id, yyvsp[0].node);
|
5473
5473
|
fixpos(yyval.node, yyvsp[-3].node);
|
5474
5474
|
;
|
5475
5475
|
break;}
|
5476
5476
|
case 353:
|
5477
5477
|
#line 1838 "sydparse.y"
|
5478
5478
|
{
|
5479
|
-
yyval.node = new_call(yyvsp[-2].node, yyvsp[0].id, 0);
|
5479
|
+
yyval.node = new_call(parse_state, yyvsp[-2].node, yyvsp[0].id, 0);
|
5480
5480
|
;
|
5481
5481
|
break;}
|
5482
5482
|
case 354:
|
@@ -5494,7 +5494,7 @@ case 355:
|
|
5494
5494
|
case 356:
|
5495
5495
|
#line 1850 "sydparse.y"
|
5496
5496
|
{
|
5497
|
-
yyval.node = new_super(yyvsp[0].node);
|
5497
|
+
yyval.node = new_super(parse_state, yyvsp[0].node);
|
5498
5498
|
;
|
5499
5499
|
break;}
|
5500
5500
|
case 357:
|
@@ -5550,7 +5550,7 @@ case 364:
|
|
5550
5550
|
case 366:
|
5551
5551
|
#line 1894 "sydparse.y"
|
5552
5552
|
{
|
5553
|
-
yyval.node = list_append(yyvsp[-3].node, NEW_WHEN(yyvsp[0].node, 0, 0));
|
5553
|
+
yyval.node = list_append(parse_state, yyvsp[-3].node, NEW_WHEN(yyvsp[0].node, 0, 0));
|
5554
5554
|
;
|
5555
5555
|
break;}
|
5556
5556
|
case 367:
|
@@ -5564,7 +5564,7 @@ case 370:
|
|
5564
5564
|
{
|
5565
5565
|
if (yyvsp[-3].node) {
|
5566
5566
|
yyvsp[-3].node = node_assign(yyvsp[-3].node, NEW_GVAR(rb_intern("$!")), parse_state);
|
5567
|
-
yyvsp[-1].node = block_append(yyvsp[-3].node, yyvsp[-1].node);
|
5567
|
+
yyvsp[-1].node = block_append(parse_state, yyvsp[-3].node, yyvsp[-1].node);
|
5568
5568
|
}
|
5569
5569
|
yyval.node = NEW_RESBODY(yyvsp[-4].node, yyvsp[-1].node, yyvsp[0].node);
|
5570
5570
|
fixpos(yyval.node, yyvsp[-4].node?yyvsp[-4].node:yyvsp[-1].node);
|
@@ -5606,7 +5606,7 @@ case 382:
|
|
5606
5606
|
node = NEW_STR(rb_str_new(0, 0));
|
5607
5607
|
}
|
5608
5608
|
else {
|
5609
|
-
node = evstr2dstr(node);
|
5609
|
+
node = evstr2dstr(parse_state, node);
|
5610
5610
|
}
|
5611
5611
|
yyval.node = node;
|
5612
5612
|
;
|
@@ -5614,7 +5614,7 @@ case 382:
|
|
5614
5614
|
case 384:
|
5615
5615
|
#line 1970 "sydparse.y"
|
5616
5616
|
{
|
5617
|
-
yyval.node = literal_concat(yyvsp[-1].node, yyvsp[0].node);
|
5617
|
+
yyval.node = literal_concat(parse_state, yyvsp[-1].node, yyvsp[0].node);
|
5618
5618
|
;
|
5619
5619
|
break;}
|
5620
5620
|
case 385:
|
@@ -5706,13 +5706,13 @@ case 390:
|
|
5706
5706
|
case 391:
|
5707
5707
|
#line 2058 "sydparse.y"
|
5708
5708
|
{
|
5709
|
-
yyval.node = list_append(yyvsp[-2].node, evstr2dstr(yyvsp[-1].node));
|
5709
|
+
yyval.node = list_append(parse_state, yyvsp[-2].node, evstr2dstr(parse_state, yyvsp[-1].node));
|
5710
5710
|
;
|
5711
5711
|
break;}
|
5712
5712
|
case 393:
|
5713
5713
|
#line 2065 "sydparse.y"
|
5714
5714
|
{
|
5715
|
-
yyval.node = literal_concat(yyvsp[-1].node, yyvsp[0].node);
|
5715
|
+
yyval.node = literal_concat(parse_state, yyvsp[-1].node, yyvsp[0].node);
|
5716
5716
|
;
|
5717
5717
|
break;}
|
5718
5718
|
case 394:
|
@@ -5736,7 +5736,7 @@ case 396:
|
|
5736
5736
|
case 397:
|
5737
5737
|
#line 2085 "sydparse.y"
|
5738
5738
|
{
|
5739
|
-
yyval.node = list_append(yyvsp[-2].node, yyvsp[-1].node);
|
5739
|
+
yyval.node = list_append(parse_state, yyvsp[-2].node, yyvsp[-1].node);
|
5740
5740
|
;
|
5741
5741
|
break;}
|
5742
5742
|
case 398:
|
@@ -5748,7 +5748,7 @@ case 398:
|
|
5748
5748
|
case 399:
|
5749
5749
|
#line 2095 "sydparse.y"
|
5750
5750
|
{
|
5751
|
-
yyval.node = literal_concat(yyvsp[-1].node, yyvsp[0].node);
|
5751
|
+
yyval.node = literal_concat(parse_state, yyvsp[-1].node, yyvsp[0].node);
|
5752
5752
|
;
|
5753
5753
|
break;}
|
5754
5754
|
case 400:
|
@@ -5760,7 +5760,7 @@ case 400:
|
|
5760
5760
|
case 401:
|
5761
5761
|
#line 2105 "sydparse.y"
|
5762
5762
|
{
|
5763
|
-
yyval.node = literal_concat(yyvsp[-1].node, yyvsp[0].node);
|
5763
|
+
yyval.node = literal_concat(parse_state, yyvsp[-1].node, yyvsp[0].node);
|
5764
5764
|
;
|
5765
5765
|
break;}
|
5766
5766
|
case 403:
|
@@ -5798,7 +5798,7 @@ case 406:
|
|
5798
5798
|
yyval.node = yyval.node->nd_next;
|
5799
5799
|
rb_gc_force_recycle((VALUE)yyvsp[-1].node);
|
5800
5800
|
}
|
5801
|
-
yyval.node = new_evstr(yyval.node);
|
5801
|
+
yyval.node = new_evstr(parse_state, yyval.node);
|
5802
5802
|
;
|
5803
5803
|
break;}
|
5804
5804
|
case 407:
|
@@ -5933,52 +5933,52 @@ case 442:
|
|
5933
5933
|
#line 2256 "sydparse.y"
|
5934
5934
|
{
|
5935
5935
|
// printf("rest + all = %d\n", $5);
|
5936
|
-
yyval.node = block_append(NEW_ARGS(yyvsp[-5].num, yyvsp[-3].node, yyvsp[-1].id), yyvsp[0].node);
|
5936
|
+
yyval.node = block_append(parse_state, NEW_ARGS(yyvsp[-5].num, yyvsp[-3].node, yyvsp[-1].id), yyvsp[0].node);
|
5937
5937
|
;
|
5938
5938
|
break;}
|
5939
5939
|
case 443:
|
5940
5940
|
#line 2261 "sydparse.y"
|
5941
5941
|
{
|
5942
|
-
yyval.node = block_append(NEW_ARGS(yyvsp[-3].num, yyvsp[-1].node, -1), yyvsp[0].node);
|
5942
|
+
yyval.node = block_append(parse_state, NEW_ARGS(yyvsp[-3].num, yyvsp[-1].node, -1), yyvsp[0].node);
|
5943
5943
|
;
|
5944
5944
|
break;}
|
5945
5945
|
case 444:
|
5946
5946
|
#line 2265 "sydparse.y"
|
5947
5947
|
{
|
5948
5948
|
// printf("arg + rest = %d\n", $3);
|
5949
|
-
yyval.node = block_append(NEW_ARGS(yyvsp[-3].num, 0, yyvsp[-1].id), yyvsp[0].node);
|
5949
|
+
yyval.node = block_append(parse_state, NEW_ARGS(yyvsp[-3].num, 0, yyvsp[-1].id), yyvsp[0].node);
|
5950
5950
|
;
|
5951
5951
|
break;}
|
5952
5952
|
case 445:
|
5953
5953
|
#line 2270 "sydparse.y"
|
5954
5954
|
{
|
5955
|
-
yyval.node = block_append(NEW_ARGS(yyvsp[-1].num, 0, -1), yyvsp[0].node);
|
5955
|
+
yyval.node = block_append(parse_state, NEW_ARGS(yyvsp[-1].num, 0, -1), yyvsp[0].node);
|
5956
5956
|
;
|
5957
5957
|
break;}
|
5958
5958
|
case 446:
|
5959
5959
|
#line 2274 "sydparse.y"
|
5960
5960
|
{
|
5961
5961
|
// printf("rest + opt = %d\n", $3);
|
5962
|
-
yyval.node = block_append(NEW_ARGS(0, yyvsp[-3].node, yyvsp[-1].id), yyvsp[0].node);
|
5962
|
+
yyval.node = block_append(parse_state, NEW_ARGS(0, yyvsp[-3].node, yyvsp[-1].id), yyvsp[0].node);
|
5963
5963
|
;
|
5964
5964
|
break;}
|
5965
5965
|
case 447:
|
5966
5966
|
#line 2279 "sydparse.y"
|
5967
5967
|
{
|
5968
|
-
yyval.node = block_append(NEW_ARGS(0, yyvsp[-1].node, -1), yyvsp[0].node);
|
5968
|
+
yyval.node = block_append(parse_state, NEW_ARGS(0, yyvsp[-1].node, -1), yyvsp[0].node);
|
5969
5969
|
;
|
5970
5970
|
break;}
|
5971
5971
|
case 448:
|
5972
5972
|
#line 2283 "sydparse.y"
|
5973
5973
|
{
|
5974
5974
|
// printf("rest only = %d\n", $1);
|
5975
|
-
yyval.node = block_append(NEW_ARGS(0, 0, yyvsp[-1].id), yyvsp[0].node);
|
5975
|
+
yyval.node = block_append(parse_state, NEW_ARGS(0, 0, yyvsp[-1].id), yyvsp[0].node);
|
5976
5976
|
;
|
5977
5977
|
break;}
|
5978
5978
|
case 449:
|
5979
5979
|
#line 2288 "sydparse.y"
|
5980
5980
|
{
|
5981
|
-
yyval.node = block_append(NEW_ARGS(0, 0, -1), yyvsp[0].node);
|
5981
|
+
yyval.node = block_append(parse_state, NEW_ARGS(0, 0, -1), yyvsp[0].node);
|
5982
5982
|
;
|
5983
5983
|
break;}
|
5984
5984
|
case 450:
|
@@ -6048,7 +6048,7 @@ case 459:
|
|
6048
6048
|
case 460:
|
6049
6049
|
#line 2347 "sydparse.y"
|
6050
6050
|
{
|
6051
|
-
yyval.node = block_append(yyvsp[-2].node, yyvsp[0].node);
|
6051
|
+
yyval.node = block_append(parse_state, yyvsp[-2].node, yyvsp[0].node);
|
6052
6052
|
;
|
6053
6053
|
break;}
|
6054
6054
|
case 463:
|
@@ -6156,13 +6156,13 @@ case 479:
|
|
6156
6156
|
case 480:
|
6157
6157
|
#line 2453 "sydparse.y"
|
6158
6158
|
{
|
6159
|
-
yyval.node = list_append(NEW_LIST(yyvsp[-2].node), yyvsp[0].node);
|
6159
|
+
yyval.node = list_append(parse_state, NEW_LIST(yyvsp[-2].node), yyvsp[0].node);
|
6160
6160
|
;
|
6161
6161
|
break;}
|
6162
6162
|
case 481:
|
6163
6163
|
#line 2458 "sydparse.y"
|
6164
6164
|
{
|
6165
|
-
yyval.node = list_append(NEW_LIST(NEW_LIT(ID2SYM(yyvsp[-1].id))), yyvsp[0].node);
|
6165
|
+
yyval.node = list_append(parse_state, NEW_LIST(NEW_LIT(ID2SYM(yyvsp[-1].id))), yyvsp[0].node);
|
6166
6166
|
;
|
6167
6167
|
break;}
|
6168
6168
|
case 501:
|
@@ -7112,7 +7112,7 @@ tokadd_string(func, term, paren, nest, parse_state)
|
|
7112
7112
|
}
|
7113
7113
|
|
7114
7114
|
#define NEW_STRTERM(func, term, paren) \
|
7115
|
-
syd_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
|
7115
|
+
syd_node_newnode(parse_state, NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
|
7116
7116
|
#define pslval ((YYSTYPE *)parse_state->lval)
|
7117
7117
|
static int
|
7118
7118
|
parse_string(quote, parse_state)
|
@@ -7220,7 +7220,7 @@ heredoc_identifier(rb_parse_state *parse_state)
|
|
7220
7220
|
len = parse_state->lex_p - parse_state->lex_pbeg;
|
7221
7221
|
parse_state->lex_p = parse_state->lex_pend;
|
7222
7222
|
pslval->id = 0;
|
7223
|
-
lex_strterm = syd_node_newnode(NODE_HEREDOC,
|
7223
|
+
lex_strterm = syd_node_newnode(parse_state, NODE_HEREDOC,
|
7224
7224
|
rb_str_new(tok(), toklen()), /* nd_lit */
|
7225
7225
|
len, /* nd_nth */
|
7226
7226
|
parse_state->lex_lastline); /* nd_orig */
|
@@ -8565,12 +8565,16 @@ yylex(YYSTYPE *yylval, void *vstate)
|
|
8565
8565
|
}
|
8566
8566
|
}
|
8567
8567
|
|
8568
|
+
void *pt_allocate(rb_parse_state *st, int size);
|
8569
|
+
|
8568
8570
|
NODE*
|
8569
|
-
syd_node_newnode(type, a0, a1, a2)
|
8571
|
+
syd_node_newnode(st, type, a0, a1, a2)
|
8572
|
+
rb_parse_state *st;
|
8570
8573
|
enum node_type type;
|
8571
8574
|
VALUE a0, a1, a2;
|
8572
8575
|
{
|
8573
|
-
NODE *n = (NODE*)
|
8576
|
+
NODE *n = (NODE*)pt_allocate(st, sizeof(NODE));
|
8577
|
+
// NODE *n = (NODE*)rb_newobj();
|
8574
8578
|
|
8575
8579
|
n->flags |= T_NODE;
|
8576
8580
|
nd_set_type(n, type);
|
@@ -8602,7 +8606,8 @@ nodeline(node)
|
|
8602
8606
|
#endif
|
8603
8607
|
|
8604
8608
|
static NODE*
|
8605
|
-
newline_node(node)
|
8609
|
+
newline_node(parse_state, node)
|
8610
|
+
rb_parse_state *parse_state;
|
8606
8611
|
NODE *node;
|
8607
8612
|
{
|
8608
8613
|
NODE *nl = 0;
|
@@ -8649,7 +8654,8 @@ parser_warn(node, mesg)
|
|
8649
8654
|
}
|
8650
8655
|
|
8651
8656
|
static NODE*
|
8652
|
-
block_append(head, tail)
|
8657
|
+
block_append(parse_state, head, tail)
|
8658
|
+
rb_parse_state *parse_state;
|
8653
8659
|
NODE *head, *tail;
|
8654
8660
|
{
|
8655
8661
|
NODE *end, *h = head;
|
@@ -8709,7 +8715,8 @@ block_append(head, tail)
|
|
8709
8715
|
|
8710
8716
|
/* append item to the list */
|
8711
8717
|
static NODE*
|
8712
|
-
list_append(list, item)
|
8718
|
+
list_append(parse_state, list, item)
|
8719
|
+
rb_parse_state *parse_state;
|
8713
8720
|
NODE *list, *item;
|
8714
8721
|
{
|
8715
8722
|
NODE *last;
|
@@ -8756,7 +8763,8 @@ list_concat(head, tail)
|
|
8756
8763
|
|
8757
8764
|
/* concat two string literals */
|
8758
8765
|
static NODE *
|
8759
|
-
literal_concat(head, tail)
|
8766
|
+
literal_concat(parse_state, head, tail)
|
8767
|
+
rb_parse_state *parse_state;
|
8760
8768
|
NODE *head, *tail;
|
8761
8769
|
{
|
8762
8770
|
enum node_type htype;
|
@@ -8767,7 +8775,7 @@ literal_concat(head, tail)
|
|
8767
8775
|
htype = nd_type(head);
|
8768
8776
|
if (htype == NODE_EVSTR) {
|
8769
8777
|
NODE *node = NEW_DSTR(rb_str_new(0, 0));
|
8770
|
-
head = list_append(node, head);
|
8778
|
+
head = list_append(parse_state, node, head);
|
8771
8779
|
}
|
8772
8780
|
switch (nd_type(tail)) {
|
8773
8781
|
case NODE_STR:
|
@@ -8776,7 +8784,7 @@ literal_concat(head, tail)
|
|
8776
8784
|
rb_gc_force_recycle((VALUE)tail);
|
8777
8785
|
}
|
8778
8786
|
else {
|
8779
|
-
list_append(head, tail);
|
8787
|
+
list_append(parse_state, head, tail);
|
8780
8788
|
}
|
8781
8789
|
break;
|
8782
8790
|
|
@@ -8799,24 +8807,26 @@ literal_concat(head, tail)
|
|
8799
8807
|
nd_set_type(head, NODE_DSTR);
|
8800
8808
|
head->nd_alen = 1;
|
8801
8809
|
}
|
8802
|
-
list_append(head, tail);
|
8810
|
+
list_append(parse_state, head, tail);
|
8803
8811
|
break;
|
8804
8812
|
}
|
8805
8813
|
return head;
|
8806
8814
|
}
|
8807
8815
|
|
8808
8816
|
static NODE *
|
8809
|
-
evstr2dstr(node)
|
8817
|
+
evstr2dstr(parse_state, node)
|
8818
|
+
rb_parse_state *parse_state;
|
8810
8819
|
NODE *node;
|
8811
8820
|
{
|
8812
8821
|
if (nd_type(node) == NODE_EVSTR) {
|
8813
|
-
node = list_append(NEW_DSTR(rb_str_new(0, 0)), node);
|
8822
|
+
node = list_append(parse_state, NEW_DSTR(rb_str_new(0, 0)), node);
|
8814
8823
|
}
|
8815
8824
|
return node;
|
8816
8825
|
}
|
8817
8826
|
|
8818
8827
|
static NODE *
|
8819
|
-
new_evstr(node)
|
8828
|
+
new_evstr(parse_state, node)
|
8829
|
+
rb_parse_state *parse_state;
|
8820
8830
|
NODE *node;
|
8821
8831
|
{
|
8822
8832
|
NODE *head = node;
|
@@ -9115,7 +9125,8 @@ rb_backref_error(node)
|
|
9115
9125
|
}
|
9116
9126
|
|
9117
9127
|
static NODE *
|
9118
|
-
arg_concat(node1, node2)
|
9128
|
+
arg_concat(parse_state, node1, node2)
|
9129
|
+
rb_parse_state *parse_state;
|
9119
9130
|
NODE *node1;
|
9120
9131
|
NODE *node2;
|
9121
9132
|
{
|
@@ -9124,13 +9135,14 @@ arg_concat(node1, node2)
|
|
9124
9135
|
}
|
9125
9136
|
|
9126
9137
|
static NODE *
|
9127
|
-
arg_add(node1, node2)
|
9138
|
+
arg_add(parse_state, node1, node2)
|
9139
|
+
rb_parse_state *parse_state;
|
9128
9140
|
NODE *node1;
|
9129
9141
|
NODE *node2;
|
9130
9142
|
{
|
9131
9143
|
if (!node1) return NEW_LIST(node2);
|
9132
9144
|
if (nd_type(node1) == NODE_ARRAY) {
|
9133
|
-
return list_append(node1, node2);
|
9145
|
+
return list_append(parse_state, node1, node2);
|
9134
9146
|
}
|
9135
9147
|
else {
|
9136
9148
|
return NEW_ARGSPUSH(node1, node2);
|
@@ -9160,7 +9172,7 @@ node_assign(lhs, rhs, parse_state)
|
|
9160
9172
|
|
9161
9173
|
case NODE_ATTRASGN:
|
9162
9174
|
case NODE_CALL:
|
9163
|
-
lhs->nd_args = arg_add(lhs->nd_args, rhs);
|
9175
|
+
lhs->nd_args = arg_add(parse_state, lhs->nd_args, rhs);
|
9164
9176
|
break;
|
9165
9177
|
|
9166
9178
|
default:
|
@@ -9596,7 +9608,8 @@ no_blockarg(node)
|
|
9596
9608
|
}
|
9597
9609
|
|
9598
9610
|
static NODE *
|
9599
|
-
ret_args(node)
|
9611
|
+
ret_args(parse_state, node)
|
9612
|
+
rb_parse_state *parse_state;
|
9600
9613
|
NODE *node;
|
9601
9614
|
{
|
9602
9615
|
if (node) {
|
@@ -9612,7 +9625,8 @@ ret_args(node)
|
|
9612
9625
|
}
|
9613
9626
|
|
9614
9627
|
static NODE *
|
9615
|
-
new_yield(node)
|
9628
|
+
new_yield(parse_state, node)
|
9629
|
+
rb_parse_state *parse_state;
|
9616
9630
|
NODE *node;
|
9617
9631
|
{
|
9618
9632
|
long state = Qtrue;
|
@@ -9666,7 +9680,8 @@ arg_blk_pass(node1, node2)
|
|
9666
9680
|
}
|
9667
9681
|
|
9668
9682
|
static NODE*
|
9669
|
-
arg_prepend(node1, node2)
|
9683
|
+
arg_prepend(parse_state, node1, node2)
|
9684
|
+
rb_parse_state *parse_state;
|
9670
9685
|
NODE *node1, *node2;
|
9671
9686
|
{
|
9672
9687
|
switch (nd_type(node2)) {
|
@@ -9674,10 +9689,10 @@ arg_prepend(node1, node2)
|
|
9674
9689
|
return list_concat(NEW_LIST(node1), node2);
|
9675
9690
|
|
9676
9691
|
case NODE_SPLAT:
|
9677
|
-
return arg_concat(node1, node2->nd_head);
|
9692
|
+
return arg_concat(parse_state, node1, node2->nd_head);
|
9678
9693
|
|
9679
9694
|
case NODE_BLOCK_PASS:
|
9680
|
-
node2->nd_body = arg_prepend(node1, node2->nd_body);
|
9695
|
+
node2->nd_body = arg_prepend(parse_state, node1, node2->nd_body);
|
9681
9696
|
return node2;
|
9682
9697
|
|
9683
9698
|
default:
|
@@ -9687,7 +9702,8 @@ arg_prepend(node1, node2)
|
|
9687
9702
|
}
|
9688
9703
|
|
9689
9704
|
static NODE*
|
9690
|
-
new_call(r,m,a)
|
9705
|
+
new_call(parse_state, r,m,a)
|
9706
|
+
rb_parse_state *parse_state;
|
9691
9707
|
NODE *r;
|
9692
9708
|
ID m;
|
9693
9709
|
NODE *a;
|
@@ -9700,7 +9716,8 @@ new_call(r,m,a)
|
|
9700
9716
|
}
|
9701
9717
|
|
9702
9718
|
static NODE*
|
9703
|
-
new_fcall(m,a)
|
9719
|
+
new_fcall(parse_state, m,a)
|
9720
|
+
rb_parse_state *parse_state;
|
9704
9721
|
ID m;
|
9705
9722
|
NODE *a;
|
9706
9723
|
{
|
@@ -9712,7 +9729,8 @@ new_fcall(m,a)
|
|
9712
9729
|
}
|
9713
9730
|
|
9714
9731
|
static NODE*
|
9715
|
-
new_super(a)
|
9732
|
+
new_super(parse_state,a)
|
9733
|
+
rb_parse_state *parse_state;
|
9716
9734
|
NODE *a;
|
9717
9735
|
{
|
9718
9736
|
if (a && nd_type(a) == NODE_BLOCK_PASS) {
|
@@ -9970,10 +9988,13 @@ syd_dyna_init(st, node, pre)
|
|
9970
9988
|
VALUE pre;
|
9971
9989
|
{
|
9972
9990
|
VALUE vars;
|
9991
|
+
rb_parse_state *parse_state;
|
9973
9992
|
int i;
|
9974
9993
|
// struct RVarmap *post = ruby_dyna_vars;
|
9975
9994
|
NODE *var, *out;
|
9976
9995
|
|
9996
|
+
parse_state = st;
|
9997
|
+
|
9977
9998
|
if (!node) return node;
|
9978
9999
|
|
9979
10000
|
vars = rb_funcall(st->self, rb_intern("dyna_init"), 1, pre);
|
@@ -9989,7 +10010,7 @@ syd_dyna_init(st, node, pre)
|
|
9989
10010
|
var = NEW_DASGN_CURR(post->id, var);
|
9990
10011
|
}
|
9991
10012
|
*/
|
9992
|
-
out = block_append(var, node);
|
10013
|
+
out = block_append(st, var, node);
|
9993
10014
|
return out;
|
9994
10015
|
}
|
9995
10016
|
|