refresh InterpretDebug5.diff
[nedit-bw.git] / key-grammar.patch
blobb2546b8c49a002ce8781503d028b70a95ab07baa
1 ---
3 source/parse.y | 128 ++++++++++++++++++---------------------------------------
4 1 file changed, 41 insertions(+), 87 deletions(-)
6 diff --quilt old/source/parse.y new/source/parse.y
7 --- old/source/parse.y
8 +++ new/source/parse.y
9 @@ -124,7 +124,7 @@ static int nextSymIsField = 0;
10 %token <num> NUMBER
11 %token DELETE ARG_LOOKUP
12 %token IF WHILE DO ELSE FOR BREAK CONTINUE RETURN DEFINE TYPEOF KEYVAL
13 -%type <num> arglistopt arglist catlist fnarglsopt fnarglist fnarg
14 +%type <num> keyargs key keyopt catlist fnarglsopt fnarglist fnarg
15 %type <inst> cond comastmts comastmtlst for while do else and or arrayexpr mark
16 %type <str> evalsym
17 %type <define> definesym
18 @@ -349,49 +349,27 @@ simpstmt: /* simple variable assignmen
19 ADD_OP(OP_ASSIGN); ADD_SYM($1);
21 /* delete array entry simple statement */
22 - | DELETE arraylv '[' arglistopt ']' {
23 - ADD_OP(OP_ARRAY_DELETE); ADD_IMMED($4);
24 + | DELETE arraylv keyopt {
25 + ADD_OP(OP_ARRAY_DELETE); ADD_IMMED($3);
27 - | DELETE arraylv dot field {
28 - ADD_OP(OP_ARRAY_DELETE); ADD_IMMED(1);
29 + /* array[index]/array.field assignment, op-assignment, incr/decr */
30 + | initarraylv key '=' blank expr {
31 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($2);
32 + }
33 + | initarraylv key operassign blank expr {
34 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($2);
35 + ADD_OP($3);
36 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($2);
37 + }
38 + | initarraylv key incrdecr {
39 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($2);
40 + ADD_OP($3);
41 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($2);
43 - /* array[index] assignment, op-assignment, incr/decrement */
44 - | initarraylv '[' arglistopt ']' '=' blank expr {
45 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
46 - }
47 - | initarraylv '[' arglistopt ']' operassign blank expr {
48 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
49 - ADD_OP($5);
50 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
51 - }
52 - | initarraylv '[' arglistopt ']' incrdecr {
53 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($3);
54 - ADD_OP($5);
55 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
56 - }
57 - | incrdecr blank initarraylv '[' arglistopt ']' {
58 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($5);
59 + | incrdecr blank initarraylv key {
60 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($4);
61 ADD_OP($1);
62 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($5);
63 - }
64 - /* array.field assignment, op-assignment, incr/decrement */
65 - | initarraylv dot field '=' blank expr {
66 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
67 - }
68 - | initarraylv dot field operassign blank expr {
69 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1);ADD_IMMED(1);
70 - ADD_OP($4);
71 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
72 - }
73 - | initarraylv dot field incrdecr {
74 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
75 - ADD_OP($4);
76 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
77 - }
78 - | incrdecr blank initarraylv dot field {
79 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
80 - ADD_OP($1);
81 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
82 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($4);
84 | initarraylv '[' '@' ']' '=' blank expr {
85 ADD_OP(OP_ARRAY_ASSIGN_NEXT);
86 @@ -460,13 +438,9 @@ lvlist: blank {
87 SwapCode($4, $5, GetPC());
90 -lvselector: blank '=' blank '[' arglist ']' {
91 - /* add code to push the rvalue expression value */
92 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($5);
93 - }
94 - | blank '=' blank dot field {
95 +lvselector: blank '=' blank key {
96 /* add code to push the rvalue expression value */
97 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
98 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($4);
101 /* lventry's value is the start of the assignment code */
102 @@ -476,17 +450,11 @@ lventry: SYMBOL {
103 $$ = GetPC();
104 ADD_OP(OP_ASSIGN); ADD_SYM($1);
106 - | initarraylv '[' arglist ']' {
107 + | initarraylv key {
108 /* above the rvalue is the array + nDim strings */
109 - ADD_OP(OP_PEEK_PUSH); ADD_IMMED($3 + 1);
110 + ADD_OP(OP_PEEK_PUSH); ADD_IMMED($2 + 1);
111 $$ = GetPC();
112 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
114 - | initarraylv dot field {
115 - /* above the rvalue is the array + one string */
116 - ADD_OP(OP_PEEK_PUSH); ADD_IMMED(2);
117 - $$ = GetPC();
118 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
119 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($2);
123 @@ -503,11 +471,14 @@ comastmtlst: simp
126 /* array key argument lists */
127 -arglistopt: blank { $$ = 0; }
128 - | arglist { $$ = $1; }
129 +key: '[' keyargs ']' { $$ = $2; }
130 + | dot field { $$ = 1; }
132 +keyopt: '[' blank ']' { $$ = 0; }
133 + | key { $$ = $1; }
135 -arglist: blank expr blank { $$ = 1; }
136 - | arglist ',' blank expr blank { $$ = $1 + 1; }
137 +keyargs: blank expr blank { $$ = 1; }
138 + | keyargs ',' blank expr blank { $$ = $1 + 1; }
141 /* string concatenation lists */
142 @@ -543,11 +514,8 @@ funccall: TYPEOF '(' {
143 fnarg: expr {
144 $$ = 0;
146 - | '[' arglist ']' '=' expr {
147 - $$ = $2; /* how many index elements to read? */
149 - | dot field '=' expr {
150 - $$ = 1; /* how many index elements to read? */
151 + | key '=' expr {
152 + $$ = $1; /* how many index elements to read? */
155 fnarglsopt: blank { $$ = 0; }
156 @@ -603,22 +571,16 @@ expr: catlist {
157 initarraylv: SYMBOL {
158 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM($1); ADD_IMMED(1);
160 - | initarraylv '[' arglistopt ']' {
161 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
163 - | initarraylv dot field {
164 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
165 + | initarraylv key {
166 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($2);
170 arraylv: SYMBOL {
171 ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM($1); ADD_IMMED(0);
173 - | arraylv '[' arglistopt ']' {
174 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
176 - | arraylv dot field {
177 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
178 + | arraylv keyopt {
179 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($2);
183 @@ -659,15 +621,10 @@ arrentry: blank {
184 /* make a suitable index >= 0 and add expr there */
185 ADD_OP(OP_ANONARRAY_NEXT_VAL);
187 - | blank '[' arglist ']' blank '=' blank expr blank {
188 - /* build the index from arglistopt and add expr there */
189 - ADD_OP(OP_ANONARRAY_INDEX_VAL);
190 - ADD_IMMED($3);
192 - | blank dot field blank '=' blank expr blank {
193 + | blank key blank '=' blank expr blank {
194 /* build the index from arglistopt and add expr there */
195 ADD_OP(OP_ANONARRAY_INDEX_VAL);
196 - ADD_IMMED(1);
197 + ADD_IMMED($2);
201 @@ -685,11 +642,8 @@ numexpr: '(' blank expr blank ')'
202 | ARG_LOOKUP '[' blank ']' { ADD_OP(OP_PUSH_ARG_COUNT); }
204 | ARG_LOOKUP { ADD_OP(OP_PUSH_ARG_ARRAY); }
205 - | numexpr '[' arglistopt ']' {
206 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
208 - | numexpr dot field {
209 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
210 + | numexpr keyopt {
211 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($2);
213 | numexpr '[' '@' ']' {
214 ADD_OP(OP_ARRAY_NEXT_NUM_IDX);