1 diff -u nedit_mod/source/parse.y nedit_mod_/source/parse.y
2 --- nedit_mod/source/parse.y 2005-08-16 14:33:52.000000000 -0400
3 +++ nedit_mod_/source/parse.y 2005-08-15 10:41:07.000000000 -0400
8 + enum operations oper;
10 %token <sym> NUMBER STRING SYMBOL FIELD
11 %token DELETE ARG_LOOKUP
12 -%token IF WHILE ELSE FOR BREAK CONTINUE RETURN
13 -%type <nArgs> arglist catlist
14 -%type <inst> cond comastmts for while else and or arrayexpr
15 +%token IF WHILE DO ELSE FOR BREAK CONTINUE RETURN
16 +%type <nArgs> arglistopt arglist catlist
17 +%type <inst> cond comastmts comastmtlst for while do else and or arrayexpr mark
19 +%type <oper> operassign incrdecr
20 +%token <oper> '=' ADDEQ SUBEQ MULEQ DIVEQ MODEQ ANDEQ OREQ
21 +%token <oper> INCR DECR
29 +mark: /* nothing */ { $$ = GetPC(); } /* record instruction address */
32 | simpstmt stmtend blank
33 - | IF '(' cond ')' blank block %prec IF_NO_ELSE {
34 - SET_BR_OFF($3, GetPC());
35 + | IF blank '(' cond ')' blank block %prec IF_NO_ELSE {
36 + SET_BR_OFF($4, GetPC());
38 - | IF '(' cond ')' blank block else blank block %prec ELSE {
39 - SET_BR_OFF($3, ($7+1)); SET_BR_OFF($7, GetPC());
40 + | IF blank '(' cond ')' blank block else block %prec ELSE {
41 + SET_BR_OFF($4, ($8+1)); SET_BR_OFF($8, GetPC());
43 | while '(' cond ')' blank block {
44 ADD_OP(OP_BRANCH); ADD_BR_OFF($1);
45 SET_BR_OFF($3, GetPC()); FillLoopAddrs(GetPC(), $1);
47 + | do block WHILE blank '(' mark cond ')' stmtend blank {
48 + ADD_OP(OP_BRANCH); ADD_BR_OFF($1);
49 + SET_BR_OFF($7, GetPC()); FillLoopAddrs(GetPC(), $6);
51 | for '(' comastmts ';' cond ';' comastmts ')' blank block {
52 FillLoopAddrs(GetPC()+2+($7-($5+1)), GetPC());
53 SwapCode($5+1, $7, GetPC());
54 ADD_OP(OP_BRANCH); ADD_BR_OFF($3); SET_BR_OFF($5, GetPC());
56 - | for '(' SYMBOL IN arrayexpr ')' {
57 + | for '(' blank SYMBOL IN blank arrayexpr blank ')' {
58 Symbol *iterSym = InstallIteratorSymbol();
59 ADD_OP(OP_BEGIN_ARRAY_ITER); ADD_SYM(iterSym);
60 - ADD_OP(OP_ARRAY_ITER); ADD_SYM($3); ADD_SYM(iterSym); ADD_BR_OFF(0);
61 + ADD_OP(OP_ARRAY_ITER); ADD_SYM($4); ADD_SYM(iterSym); ADD_BR_OFF(0);
64 - ADD_OP(OP_BRANCH); ADD_BR_OFF($5+2);
65 - SET_BR_OFF($5+5, GetPC());
66 - FillLoopAddrs(GetPC(), $5+2);
67 + ADD_OP(OP_BRANCH); ADD_BR_OFF($7+2);
68 + SET_BR_OFF($7+5, GetPC());
69 + FillLoopAddrs(GetPC(), $7+2);
71 | BREAK stmtend blank {
72 ADD_OP(OP_BRANCH); ADD_BR_OFF(0);
73 @@ -162,229 +172,130 @@
74 ADD_OP(OP_RETURN_NO_VAL);
77 -simpstmt: SYMBOL '=' expr {
79 +operassign: ADDEQ { $$ = OP_ADD; }
80 + | SUBEQ { $$ = OP_SUB; }
81 + | MULEQ { $$ = OP_MUL; }
82 + | DIVEQ { $$ = OP_DIV; }
83 + | MODEQ { $$ = OP_MOD; }
84 + | ANDEQ { $$ = OP_BIT_AND; }
85 + | OREQ { $$ = OP_BIT_OR; }
87 +incrdecr: INCR { $$ = OP_INCR; }
88 + | DECR { $$ = OP_DECR; }
91 +simpstmt: /* simple variable assignment, op-assignment, incr/decrement */
92 + SYMBOL '=' blank expr {
93 ADD_OP(OP_ASSIGN); ADD_SYM($1);
95 - | evalsym ADDEQ expr {
96 - ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM($1);
97 + | evalsym operassign blank expr {
98 + ADD_OP($2); ADD_OP(OP_ASSIGN); ADD_SYM($1);
100 - | evalsym SUBEQ expr {
101 - ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM($1);
102 + | incrdecr blank SYMBOL {
103 + ADD_OP(OP_PUSH_SYM); ADD_SYM($3); ADD_OP($1);
104 + ADD_OP(OP_ASSIGN); ADD_SYM($3);
106 - | evalsym MULEQ expr {
107 - ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM($1);
109 - | evalsym DIVEQ expr {
110 - ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM($1);
112 - | evalsym MODEQ expr {
113 - ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM($1);
115 - | evalsym ANDEQ expr {
116 - ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN); ADD_SYM($1);
118 - | evalsym OREQ expr {
119 - ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN); ADD_SYM($1);
120 + | SYMBOL incrdecr {
121 + ADD_OP(OP_PUSH_SYM); ADD_SYM($1); ADD_OP($2);
122 + ADD_OP(OP_ASSIGN); ADD_SYM($1);
124 - | DELETE arraylv '[' arglist ']' {
125 - ADD_OP(OP_ARRAY_DELETE); ADD_IMMED($4);
126 + /* delete array entry simple statement */
127 + | DELETE arraylv '[' arglistopt ']' {
128 + ADD_OP(OP_ARRAY_DELETE); ADD_IMMED($4);
130 | DELETE arraylv dot field {
131 - ADD_OP(OP_ARRAY_DELETE); ADD_IMMED(1);
132 + ADD_OP(OP_ARRAY_DELETE); ADD_IMMED(1);
134 -/* array[index] assignment */
135 - | initarraylv '[' arglist ']' '=' expr {
136 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
138 - | initarraylv '[' arglist ']' ADDEQ expr {
139 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
141 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
143 - | initarraylv '[' arglist ']' SUBEQ expr {
144 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
146 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
148 - | initarraylv '[' arglist ']' MULEQ expr {
149 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
151 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
153 - | initarraylv '[' arglist ']' DIVEQ expr {
154 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
156 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
158 - | initarraylv '[' arglist ']' MODEQ expr {
159 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
161 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
163 - | initarraylv '[' arglist ']' ANDEQ expr {
164 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
165 - ADD_OP(OP_BIT_AND);
166 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
168 - | initarraylv '[' arglist ']' OREQ expr {
169 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
171 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
173 - | initarraylv '[' arglist ']' INCR {
174 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($3);
176 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
178 - | initarraylv '[' arglist ']' DECR {
179 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($3);
181 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
183 - | INCR initarraylv '[' arglist ']' {
184 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($4);
186 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($4);
188 - | DECR initarraylv '[' arglist ']' {
189 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($4);
191 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($4);
193 -/* array.field assignment */
194 - | initarraylv dot field '=' expr {
195 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
197 - | initarraylv dot field ADDEQ expr {
198 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
200 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
202 - | initarraylv dot field SUBEQ expr {
203 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
205 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
207 - | initarraylv dot field MULEQ expr {
208 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
210 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
212 - | initarraylv dot field DIVEQ expr {
213 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
215 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
217 - | initarraylv dot field MODEQ expr {
218 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
220 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
222 - | initarraylv dot field ANDEQ expr {
223 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
224 - ADD_OP(OP_BIT_AND);
225 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
227 - | initarraylv dot field OREQ expr {
228 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED(1);
230 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
232 - | initarraylv dot field INCR {
233 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
235 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
237 - | initarraylv dot field DECR {
238 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
240 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
242 - | INCR initarraylv dot field {
243 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
245 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
247 - | DECR initarraylv dot field {
248 - ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
250 - ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
251 + /* array[index] assignment, op-assignment, incr/decrement */
252 + | initarraylv '[' arglistopt ']' '=' blank expr {
253 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
255 + | initarraylv '[' arglistopt ']' operassign blank expr {
256 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1); ADD_IMMED($3);
258 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
260 + | initarraylv '[' arglistopt ']' incrdecr {
261 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($3);
263 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($3);
265 + | incrdecr blank initarraylv '[' arglistopt ']' {
266 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED($5);
268 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED($5);
270 + /* array.field assignment, op-assignment, incr/decrement */
271 + | initarraylv dot field '=' blank expr {
272 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
274 + | initarraylv dot field operassign blank expr {
275 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(1);ADD_IMMED(1);
277 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
279 + | initarraylv dot field incrdecr {
280 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
282 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
284 + | incrdecr blank initarraylv dot field {
285 + ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP); ADD_IMMED(0); ADD_IMMED(1);
287 + ADD_OP(OP_ARRAY_ASSIGN); ADD_IMMED(1);
289 - | SYMBOL '(' arglist ')' {
290 + /* function call */
291 + | SYMBOL '(' arglistopt ')' {
292 ADD_OP(OP_SUBR_CALL);
293 - ADD_SYM(PromoteToGlobal($1)); ADD_IMMED($3);
296 - ADD_OP(OP_PUSH_SYM); ADD_SYM($2); ADD_OP(OP_INCR);
297 - ADD_OP(OP_ASSIGN); ADD_SYM($2);
300 - ADD_OP(OP_PUSH_SYM); ADD_SYM($1); ADD_OP(OP_INCR);
301 - ADD_OP(OP_ASSIGN); ADD_SYM($1);
304 - ADD_OP(OP_PUSH_SYM); ADD_SYM($2); ADD_OP(OP_DECR);
305 - ADD_OP(OP_ASSIGN); ADD_SYM($2);
308 - ADD_OP(OP_PUSH_SYM); ADD_SYM($1); ADD_OP(OP_DECR);
309 - ADD_OP(OP_ASSIGN); ADD_SYM($1);
310 + ADD_SYM(PromoteToGlobal($1)); ADD_IMMED($3);
315 $$ = $1; ADD_OP(OP_PUSH_SYM); ADD_SYM($1);
318 -comastmts: /* nothing */ {
324 - | comastmts ',' simpstmt {
327 +comastmts: blank { $$ = GetPC(); }
328 + | blank comastmtlst { $$ = $2; }
330 -arglist: /* nothing */ {
336 - | arglist ',' expr {
339 +comastmtlst: simpstmt blank { $$ = GetPC(); }
340 + | comastmtlst ',' blank simpstmt blank { $$ = GetPC(); }
343 +arglistopt: blank { $$ = 0; }
344 + | arglist { $$ = $1; }
346 +arglist: blank expr blank { $$ = 1; }
347 + | arglist ',' blank expr blank { $$ = $1 + 1; }
349 +catlist: numexpr %prec CONCAT { $$ = 1; }
350 + | catlist numexpr %prec CONCAT { $$ = $1 + 1; }
352 -catlist: numexpr %prec CONCAT {
355 - | catlist numexpr %prec CONCAT {
360 - ADD_OP(OP_CONCAT); ADD_IMMED($1);
361 + ADD_OP(OP_CONCAT); ADD_IMMED($1);
365 initarraylv: SYMBOL {
366 - ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM($1); ADD_IMMED(1);
367 + ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM($1); ADD_IMMED(1);
369 - | initarraylv '[' arglist ']' {
370 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
371 + | initarraylv '[' arglistopt ']' {
372 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
374 | initarraylv dot field {
375 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
376 + ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
380 - ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM($1); ADD_IMMED(0);
381 + ADD_OP(OP_PUSH_ARRAY_SYM); ADD_SYM($1); ADD_IMMED(0);
383 - | arraylv '[' arglist ']' {
384 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
385 + | arraylv '[' arglistopt ']' {
386 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
388 | arraylv dot field {
389 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
390 + ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
394 @@ -400,130 +311,82 @@
399 - ADD_OP(OP_PUSH_SYM); ADD_SYM($1);
402 - ADD_OP(OP_PUSH_SYM); ADD_SYM($1);
405 - ADD_OP(OP_PUSH_SYM); ADD_SYM($1);
407 - | SYMBOL '(' arglist ')' {
408 +numexpr: '(' blank expr blank ')'
409 + | NUMBER { ADD_OP(OP_PUSH_SYM); ADD_SYM($1); }
410 + | STRING { ADD_OP(OP_PUSH_SYM); ADD_SYM($1); }
411 + | SYMBOL { ADD_OP(OP_PUSH_SYM); ADD_SYM($1); }
412 + | SYMBOL '(' arglistopt ')' {
413 ADD_OP(OP_SUBR_CALL);
414 - ADD_SYM(PromoteToGlobal($1)); ADD_IMMED($3);
415 + ADD_SYM(PromoteToGlobal($1)); ADD_IMMED($3);
416 ADD_OP(OP_FETCH_RET_VAL);
419 - | ARG_LOOKUP '[' numexpr ']' {
420 - ADD_OP(OP_PUSH_ARG);
422 - | ARG_LOOKUP '[' ']' {
423 - ADD_OP(OP_PUSH_ARG_COUNT);
426 - ADD_OP(OP_PUSH_ARG_ARRAY);
428 - | numexpr '[' arglist ']' {
429 - ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
430 + | ARG_LOOKUP '[' blank numexpr blank ']' { ADD_OP(OP_PUSH_ARG); }
431 + | ARG_LOOKUP '[' blank ']' { ADD_OP(OP_PUSH_ARG_COUNT); }
432 + | ARG_LOOKUP { ADD_OP(OP_PUSH_ARG_ARRAY); }
433 + | numexpr '[' arglistopt ']' {
434 + ADD_OP(OP_ARRAY_REF); ADD_IMMED($3);
436 | numexpr dot field {
437 - ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
439 - | numexpr '+' numexpr {
442 - | numexpr '-' numexpr {
445 - | numexpr '*' numexpr {
448 - | numexpr '/' numexpr {
451 - | numexpr '%' numexpr {
454 - | numexpr POW numexpr {
456 + ADD_OP(OP_ARRAY_REF); ADD_IMMED(1);
458 - | '-' numexpr %prec UNARY_MINUS {
461 - | numexpr GT numexpr {
464 - | numexpr GE numexpr {
467 - | numexpr LT numexpr {
470 - | numexpr LE numexpr {
473 - | numexpr EQ numexpr {
476 - | numexpr NE numexpr {
479 - | numexpr '&' numexpr {
480 - ADD_OP(OP_BIT_AND);
482 - | numexpr '|' numexpr {
485 - | numexpr and numexpr %prec AND {
486 + | '-' blank numexpr %prec UNARY_MINUS { ADD_OP(OP_NEGATE); }
487 + | NOT blank numexpr { ADD_OP(OP_NOT); }
488 + | numexpr '+' blank numexpr { ADD_OP(OP_ADD); }
489 + | numexpr '-' blank numexpr { ADD_OP(OP_SUB); }
490 + | numexpr '*' blank numexpr { ADD_OP(OP_MUL); }
491 + | numexpr '/' blank numexpr { ADD_OP(OP_DIV); }
492 + | numexpr '%' blank numexpr { ADD_OP(OP_MOD); }
493 + | numexpr POW blank numexpr { ADD_OP(OP_POWER); }
494 + | numexpr GT blank numexpr { ADD_OP(OP_GT); }
495 + | numexpr GE blank numexpr { ADD_OP(OP_GE); }
496 + | numexpr LT blank numexpr { ADD_OP(OP_LT); }
497 + | numexpr LE blank numexpr { ADD_OP(OP_LE); }
498 + | numexpr EQ blank numexpr { ADD_OP(OP_EQ); }
499 + | numexpr NE blank numexpr { ADD_OP(OP_NE); }
500 + | numexpr '&' blank numexpr { ADD_OP(OP_BIT_AND); }
501 + | numexpr '|' blank numexpr { ADD_OP(OP_BIT_OR); }
502 + | numexpr and blank numexpr %prec AND {
503 ADD_OP(OP_AND); SET_BR_OFF($2, GetPC());
505 - | numexpr or numexpr %prec OR {
506 + | numexpr or blank numexpr %prec OR {
507 ADD_OP(OP_OR); SET_BR_OFF($2, GetPC());
513 - ADD_OP(OP_PUSH_SYM); ADD_SYM($2); ADD_OP(OP_INCR);
514 - ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM($2);
517 - ADD_OP(OP_PUSH_SYM); ADD_SYM($1); ADD_OP(OP_DUP);
518 - ADD_OP(OP_INCR); ADD_OP(OP_ASSIGN); ADD_SYM($1);
521 - ADD_OP(OP_PUSH_SYM); ADD_SYM($2); ADD_OP(OP_DECR);
522 - ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM($2);
523 + | incrdecr blank SYMBOL %prec INCR {
524 + ADD_OP(OP_PUSH_SYM); ADD_SYM($3); ADD_OP($1);
525 + ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM($3);
528 + | SYMBOL incrdecr %prec INCR {
529 ADD_OP(OP_PUSH_SYM); ADD_SYM($1); ADD_OP(OP_DUP);
530 - ADD_OP(OP_DECR); ADD_OP(OP_ASSIGN); ADD_SYM($1);
531 + ADD_OP($2); ADD_OP(OP_ASSIGN); ADD_SYM($1);
533 - | numexpr IN numexpr {
534 + | numexpr IN blank numexpr {
537 - | numexpr NOT IN numexpr {
538 + | numexpr NOT IN blank numexpr %prec IN {
544 +while: WHILE blank {
545 + $$ = GetPC(); StartLoopAddrList();
549 $$ = GetPC(); StartLoopAddrList();
554 StartLoopAddrList(); $$ = GetPC();
559 ADD_OP(OP_BRANCH); $$ = GetPC(); ADD_BR_OFF(0);
562 -cond: /* nothing */ {
564 ADD_OP(OP_BRANCH_NEVER); $$ = GetPC(); ADD_BR_OFF(0);
567 + | blank numexpr blank {
568 ADD_OP(OP_BRANCH_FALSE); $$ = GetPC(); ADD_BR_OFF(0);
573 %% /* User Subroutines Section */
577 ** Parse a null terminated string and create a program from it (this is the
578 ** parser entry point). The program created by this routine can be
584 -static int yylex(void)
588 - static DataValue value = {NO_TAG, {0}};
589 - static char escape[] = "\\\"ntbrfave";
590 -#ifdef EBCDIC_CHARSET
591 - static char replace[] = "\\\"\n\t\b\r\f\a\v\x27"; /* EBCDIC escape */
593 - static char replace[] = "\\\"\n\t\b\r\f\a\v\x1B"; /* ASCII escape */
596 +static char skipWhitespace(void)
598 /* skip whitespace, backslash-newline combinations, and comments, which are
599 all considered whitespace */
603 else if (*InPtr == ' ' || *InPtr == '\t')
605 - else if (*InPtr == '#')
606 + else if (*InPtr == '#') {
608 while (*InPtr != '\n' && *InPtr != '\0') {
609 /* Comments stop at escaped newlines */
610 if (*InPtr == '\\' && *(InPtr + 1) == '\n') {
611 @@ -617,10 +469,28 @@
624 +static int yylex(void)
628 + static DataValue value = {NO_TAG, {0}};
629 + static char escape[] = "\\\"ntbrfave";
630 +#ifdef EBCDIC_CHARSET
631 + static char replace[] = "\\\"\n\t\b\r\f\a\v\x27"; /* EBCDIC escape */
633 + static char replace[] = "\\\"\n\t\b\r\f\a\v\x1B"; /* ASCII escape */
639 /* return end of input at the end of the string */
640 if (*InPtr == '\0') {
644 if (!strcmp(symName, "while")) return WHILE;
645 + if (!strcmp(symName, "do")) return DO;
646 if (!strcmp(symName, "if")) return IF;
647 if (!strcmp(symName, "else")) return ELSE;
648 if (!strcmp(symName, "for")) return FOR;
652 /* process remaining two character tokens or return single char as token */
656 case '>': return follow('=', GE, GT);
657 case '<': return follow('=', LE, LT);
658 case '=': return follow('=', EQ, '=');
660 case '/': return follow('=', DIVEQ, '/');
661 case '%': return follow('=', MODEQ, '%');
662 case '^': return POW;
666 + /* skip newline ( whitespace* newline )* */
667 + while (skipWhitespace() == '\n')
669 + return result; /* but return what we started with */
671 default: return *(InPtr-1);