Annotation of parser3/src/main/compile.y, revision 1.34
1.24 paf 1: /*
1.34 ! paf 2: $Id: compile.y,v 1.33 2001/02/24 09:56:02 paf Exp $
1.24 paf 3: */
4:
1.1 paf 5: %{
1.9 paf 6: #define YYSTYPE Array/*<op>*/ *
7: #define YYPARSE_PARAM pc
8: #define YYLEX_PARAM pc
9: #define YYDEBUG 1
1.1 paf 10: #define YYERROR_VERBOSE
1.9 paf 11: #define yyerror(msg) real_yyerror((parse_control *)pc, msg)
12: #define YYPRINT(file, type, value) yyprint(file, type, value)
1.1 paf 13:
14: #include <stdio.h>
15: #include <string.h>
16: #include <stdlib.h>
17:
18: #include "compile_tools.h"
1.8 paf 19: #include "pa_value.h"
1.12 paf 20: #include "pa_request.h"
1.1 paf 21:
1.9 paf 22: int real_yyerror(parse_control *pc, char *s);
23: static void yyprint(FILE *file, int type, YYSTYPE value);
1.1 paf 24: int yylex(YYSTYPE *lvalp, void *pc);
25:
26:
1.8 paf 27: // local convinient inplace typecast & var
1.9 paf 28: #define PC ((parse_control *)pc)
1.25 paf 29: #define POOL *PC->pool
30: #undef NEW
31: #define NEW new(POOL)
1.1 paf 32: %}
33:
34: %pure_parser
35:
1.13 paf 36: %token EON
1.4 paf 37: %token STRING
1.1 paf 38: %token BOGUS
39:
40: %%
41:
1.10 paf 42: all:
43: one_big_piece {
1.25 paf 44: String& name_main=*NEW String(POOL);
1.11 paf 45: name_main.APPEND_CONST(MAIN_METHOD_NAME);
1.25 paf 46: Array& param_names=*NEW Array(POOL);
47: Array& local_names=*NEW Array(POOL);
1.34 ! paf 48: Method& method=*NEW Method(POOL, name_main, param_names, local_names, *$1);
! 49: PC->vclass->add_method(name_main, method);
1.10 paf 50: }
51: | methods;
52:
53: methods: method | methods method;
54: one_big_piece: maybe_codes;
55:
1.34 ! paf 56: method: control_method | code_method;
! 57:
! 58: control_method: '@' STRING '\n'
! 59: control_strings {
! 60: String *name=LA2S($2);
! 61: YYSTYPE strings_code=$4;
! 62: if(*name==CLASS_NAME) {
! 63: if(strings_code->size()==1*2)
! 64: PC->vclass->set_name(*LA2S(strings_code));
! 65: else {
! 66: strcpy(PC->error, "@"CLASS_NAME" must contain sole name");
! 67: YYERROR;
! 68: }
! 69: } else {
! 70: if(*name==USES_NAME) {
! 71: for(int i=0; i<strings_code->size(); i+=2) {
! 72: char file[MAX_STRING];
! 73: strcpy(file, LA2S(strings_code, i)->cstr());
! 74: strcat(file, ".p");
! 75: PC->request->use(file, 0);
! 76: }
! 77: } else if(*name==PARENTS_NAME) {
! 78: for(int i=0; i<strings_code->size(); i+=2) {
! 79: String *parent_name=LA2S(strings_code, i);
! 80: VClass *parent=static_cast<VClass *>(
! 81: PC->request->classes().get(*parent_name));
! 82: if(!parent) {
! 83: strcpy(PC->error, parent_name->cstr());
! 84: strcat(PC->error, ": undefined class");
! 85: YYERROR;
! 86: }
! 87: PC->vclass->add_parent(*parent);
! 88: }
! 89: } else {
! 90: strcpy(PC->error, name->cstr());
! 91: strcat(PC->error, ": invalid special name. valid names are "
! 92: CLASS_NAME", "USES_NAME" and "PARENTS_NAME);
! 93: YYERROR;
! 94: }
! 95: }
! 96: };
! 97: control_strings: control_string | control_strings '\n' control_string { $$=$1; P($$, $3) };
! 98: control_string: STRING;
! 99:
! 100: code_method: '@' STRING bracketed_maybe_strings maybe_bracketed_strings maybe_comment '\n'
1.10 paf 101: maybe_codes {
102: const String *name=LA2S($2);
103:
104: YYSTYPE params_names_code=$3;
1.25 paf 105: Array& params_names=*NEW Array(POOL);
1.10 paf 106: for(int i=0; i<params_names_code->size(); i+=2)
107: params_names+=LA2S(params_names_code, i);
108:
109: YYSTYPE locals_names_code=$4;
1.25 paf 110: Array& locals_names=*NEW Array(POOL);
1.10 paf 111: for(int i=0; i<locals_names_code->size(); i+=2)
112: locals_names+=LA2S(locals_names_code, i);
113:
1.34 ! paf 114: Method& method=*NEW Method(POOL, *name, params_names, locals_names, *$7);
! 115: PC->vclass->add_method(*name, method);
1.8 paf 116: };
1.10 paf 117:
118: maybe_bracketed_strings: empty | bracketed_maybe_strings;
119: bracketed_maybe_strings: '[' maybe_strings ']' {$$=$2};
120: maybe_strings: empty | strings;
121: strings: STRING | strings ';' STRING { $$=$1; P($$, $3) };
122:
123: maybe_comment: empty | STRING;
1.1 paf 124:
125: /* codes */
126:
1.10 paf 127: maybe_codes: empty | codes;
128:
1.1 paf 129: codes: code | codes code {
130: $$=$1;
1.9 paf 131: P($$, $2);
1.1 paf 132: };
133: code: write_str_literal | action;
134: action: get | put | with | call;
135:
136: /* get */
137:
138: get: '$' any_name {
139: $$=$2; /* stack: resulting value */
1.17 paf 140: OP($$, OP_WRITE); /* value=pop; write(value) */
1.1 paf 141: };
142:
1.13 paf 143: any_name: name_without_curly_rdive EON | name_in_curly_rdive;
1.1 paf 144:
145: name_in_curly_rdive: '{' name_without_curly_rdive '}' { $$=$2 };
1.19 paf 146: name_without_curly_rdive: name_without_curly_rdive_read | name_without_curly_rdive_root;
147: name_without_curly_rdive_read: name_without_curly_rdive_code {
1.25 paf 148: $$=N(POOL);
1.22 paf 149: Array *diving_code=$1;
150: String *first_name=LA2S(diving_code);
1.23 paf 151: if(first_name && *first_name==SELF_NAME) {
1.22 paf 152: OP($$, OP_WITH_SELF); /* stack: starting context */
153: P($$, diving_code,
154: /* skip over... */
155: diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/);
156: } else {
157: OP($$, OP_WITH_READ); /* stack: starting context */
158: P($$, diving_code);
159: }
160: /* diving code; stack: current context */
1.1 paf 161: };
1.19 paf 162: name_without_curly_rdive_root: ':' name_without_curly_rdive_code {
1.25 paf 163: $$=N(POOL);
1.19 paf 164: OP($$, OP_WITH_ROOT); /* stack: starting context */
165: P($$, $2); /* diving code; stack: current context */
166: };
167: name_without_curly_rdive_code: name_advance2 | name_path name_advance2 { $$=$1; P($$, $2) };
1.1 paf 168:
169: /* put */
170:
1.28 paf 171: put: '$' name_expr_wdive '(' constructor_value ')' {
1.20 paf 172: $$=$2; /* stack: context,name */
173: P($$, $4); /* stack: context,name,constructor_value */
174: OP($$, OP_CONSTRUCT); /* value=pop; name=pop; context=pop; construct(context,name,value) */
175: };
1.28 paf 176: name_expr_wdive: name_expr_wdive_write | name_expr_wdive_root;
177: name_expr_wdive_write: name_expr_dive_code {
1.25 paf 178: $$=N(POOL);
1.23 paf 179: Array *diving_code=$1;
180: String *first_name=LA2S(diving_code);
181: if(first_name && *first_name==SELF_NAME) {
182: OP($$, OP_WITH_SELF); /* stack: starting context */
183: P($$, diving_code,
184: /* skip over... */
185: diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/);
186: } else {
187: OP($$, OP_WITH_WRITE); /* stack: starting context */
188: P($$, diving_code);
189: }
190: /* diving code; stack: current context */
1.20 paf 191: };
1.28 paf 192: name_expr_wdive_root: ':' name_expr_dive_code {
1.25 paf 193: $$=N(POOL);
1.20 paf 194: OP($$, OP_WITH_ROOT); /* stack: starting context */
1.9 paf 195: P($$, $2); /* diving code; stack: context,name */
1.1 paf 196: };
1.20 paf 197:
1.1 paf 198: constructor_value:
1.32 paf 199: constructor_one_param_value
200: | constructor_two_params_value /* $var(=;2*2) $var(%d;2*2) $var(+;1) */
1.1 paf 201: ;
1.27 paf 202:
1.32 paf 203: constructor_one_param_value:
204: empty_value /* optimized $var() case */
205: | STRING /* optimized $var(STRING) case */
206: | complex_constructor_param_value /* $var(something complex) */
1.1 paf 207: ;
208: complex_constructor_param_value: complex_constructor_param_body {
1.25 paf 209: $$=N(POOL);
1.3 paf 210: OP($$, OP_CREATE_EWPOOL); /* stack: empty write context */
1.9 paf 211: P($$, $1); /* some codes to that context */
212: OP($$, OP_REDUCE_EWPOOL); /* context=pop; stack: context.value() */
1.1 paf 213: };
1.27 paf 214: complex_constructor_param_body: codes__excluding_sole_str_literal;
215: codes__excluding_sole_str_literal: action | code codes { $$=$1; P($$, $2) };
216:
1.32 paf 217: constructor_two_params_value: STRING ';' constructor_one_param_value {
1.7 paf 218: char *operator_or_fmt=LA2S($1)->cstr();
1.25 paf 219: $$=N(POOL);
1.9 paf 220: P($$, $1); /* stack: ncontext name operator_or_fmt */
1.3 paf 221: P($$, $3); /* stack: ncontext name operator_or_fmt expr */
1.1 paf 222: switch(operator_or_fmt[0]) {
223: case '=': case '%':
1.3 paf 224: OP($$, OP_EXPRESSION_EVAL);
1.1 paf 225: break;
226: case '+': case '-': case '*': case '/':
1.3 paf 227: OP($$, OP_MODIFY_EVAL);
1.1 paf 228: break;
229: default:
1.6 paf 230: strcpy(PC->error, "invalid modification operator");
231: YYERROR;
1.1 paf 232: }
233: /* stack: ncontext name value */
234: };
235:
236: /* call */
237:
1.28 paf 238: call: '^' name_without_curly_rdive store_params EON { /* ^field.$method{vasya} */
239: $$=$2; /* with_xxx,diving code; stack: context,method_name */
1.9 paf 240: OP($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */
241: P($$, $3); /* filling method_frame.store_params */
242: OP($$, OP_CALL); /* method_frame=pop; ncontext=pop; call(ncontext,method_frame) */
1.1 paf 243: };
244:
1.9 paf 245: store_params: store_param | store_params store_param { $$=$1; P($$, $2) };
1.1 paf 246: store_param: store_round_param | store_curly_param;
247: store_round_param: '(' store_param_parts ')' {$$=$2};
1.31 paf 248: store_param_parts:
1.32 paf 249: store_param_part
250: | store_param_parts ';' store_param_part { $$=$1; P($$, $3) }
1.31 paf 251: ;
1.10 paf 252: store_curly_param: '{' maybe_codes '}' {
1.25 paf 253: $$=N(POOL);
1.29 paf 254: PCA($$, $2);
1.9 paf 255: OP($$, OP_STORE_PARAM);
1.1 paf 256: };
1.32 paf 257: store_param_part:
1.33 paf 258: empty /* optimized () case */
259: | STRING { /* optimized (STRING) case */
1.32 paf 260: $$=$1;
261: OP($$, OP_STORE_PARAM);
262: }
1.33 paf 263: | complex_constructor_param_value { /* (something complex) */
1.32 paf 264: $$=$1;
265: OP($$, OP_STORE_PARAM);
266: }
267: ;
1.1 paf 268:
269: /* name */
270:
1.20 paf 271: name_expr_dive_code: name_expr_value | name_path name_expr_value { $$=$1; P($$, $2) };
1.1 paf 272:
1.9 paf 273: name_path: name_step | name_path name_step { $$=$1; P($$, $2) };
1.1 paf 274: name_step: name_advance1 '.';
275: name_advance1: name_expr_value {
276: /* stack: context */
277: $$=$1; /* stack: context,name */
1.9 paf 278: OP($$, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.1 paf 279: };
280: name_advance2: name_expr_value {
281: /* stack: context */
282: $$=$1; /* stack: context,name */
1.9 paf 283: OP($$, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.1 paf 284: }
1.4 paf 285: | STRING BOGUS
1.1 paf 286: ;
287: name_expr_value:
1.4 paf 288: STRING /* subname_is_const */
1.1 paf 289: | name_expr_subvar_value /* $subname_is_var_value */
290: | name_expr_with_subvar_value /* xxx$part_of_subname_is_var_value[$...] */
291: ;
292: name_expr_subvar_value: '$' subvar_ref_name_rdive {
293: $$=$2;
1.9 paf 294: OP($$, OP_GET_ELEMENT);
1.1 paf 295: };
1.4 paf 296: name_expr_with_subvar_value: STRING subvar_get_writes {
1.25 paf 297: $$=N(POOL);
1.3 paf 298: OP($$, OP_CREATE_EWPOOL);
1.9 paf 299: P($$, $1);
1.17 paf 300: OP($$, OP_WRITE);
1.9 paf 301: P($$, $2);
302: OP($$, OP_REDUCE_EWPOOL);
1.1 paf 303: };
1.18 paf 304: subvar_ref_name_rdive: subvar_ref_name_rdive_read | subvar_ref_name_rdive_root;
305: subvar_ref_name_rdive_read: STRING {
1.25 paf 306: $$=N(POOL);
1.18 paf 307: OP($$, OP_WITH_READ);
1.9 paf 308: P($$, $1);
1.1 paf 309: };
1.18 paf 310: subvar_ref_name_rdive_root: ':' STRING {
1.25 paf 311: $$=N(POOL);
1.18 paf 312: OP($$, OP_WITH_ROOT);
313: P($$, $2);
314: };
1.9 paf 315: subvar_get_writes: subvar__get_write | subvar_get_writes subvar__get_write { $$=$1; P($$, $2) };
1.1 paf 316: subvar__get_write: '$' subvar_ref_name_rdive {
317: $$=$2;
1.17 paf 318: OP($$, OP_GET_ELEMENT__WRITE);
1.1 paf 319: };
320:
321:
322: /* with */
323:
324: with: '$' name_without_curly_rdive '{' codes '}' {
325: $$=$2;
1.9 paf 326: OP($$, OP_CREATE_RWPOOL);
327: P($$, $4);
328: OP($$, OP_REDUCE_RWPOOL);
1.17 paf 329: OP($$, OP_WRITE);
1.1 paf 330: };
331:
1.27 paf 332: /* basics */
1.1 paf 333:
1.4 paf 334: write_str_literal: STRING {
1.30 paf 335: if(LA2S($1)->size()) {
336: $$=$1;
337: OP($$, OP_WRITE);
338: } else {
339: // optimized case of special end of macro. see yylex
340: $$=N(POOL);
341: }
1.26 paf 342: };
1.32 paf 343: empty_value: /* empty */ { $$=L(NEW VString(POOL)) };
1.25 paf 344: empty: /* empty */ { $$=N(POOL) };
1.1 paf 345:
346: %%
347:
348: /*
349: 000$111(2222)00
350: 000$111{3333}00
1.9 paf 351: $,^: push,=0
1.1 paf 352: 1:( { break=pop
353: 2:( ) pop
354: 3:{ } pop
355:
356: 000^111(2222)4444{33333}4000
1.9 paf 357: $,^: push,=0
1.1 paf 358: 1:( { break=pop
359: 2:( )=4
360: 3:{ }=4
361: 4:[^({]=pop
362: */
363:
364: int yylex(YYSTYPE *lvalp, void *pc) {
365: #define lexical_brackets_nestage PC->brackets_nestages[PC->sp]
366:
367: register int c;
368: int result;
369:
370: if(PC->pending_state) {
371: result=PC->pending_state;
372: PC->pending_state=0;
373: return result;
374: }
375:
1.9 paf 376: char *begin=PC->source;
377: char *end;
378: int begin_line=PC->line;
1.1 paf 379: while(1) {
1.9 paf 380: c=*(end=(PC->source++));
1.1 paf 381:
1.4 paf 382: if(c=='\n') {
1.1 paf 383: PC->line++;
1.8 paf 384: PC->col=0;
1.10 paf 385: } else
1.4 paf 386: PC->col++;
1.1 paf 387:
388: /* escaping: ^^ ^$ ^; ^) ^} ^( ^{ */
389: if(c=='^') {
390: char pending_c=*PC->source;
391:
1.9 paf 392: if(pending_c=='^' || pending_c=='$' || pending_c==';' ||
393: pending_c=='(' || pending_c==')' ||
394: pending_c=='{' || pending_c=='}') {
1.1 paf 395: /* append piece till ^ */
1.9 paf 396: PC->string->APPEND(begin, end-begin, PC->file, begin_line);
1.1 paf 397: /* reset piece 'start' position & line */
1.9 paf 398: begin=PC->source/*^*/;
399: begin_line=PC->line;
1.1 paf 400: /* skip over ^ and _ */
401: PC->source+=2;
402: /* skip analysis = forced literal */
403: continue;
404: }
405: }
406: switch(PC->ls) {
1.10 paf 407:
408: // USER'S = NOT OURS
1.1 paf 409: case LS_USER:
410: if(c=='$') {
1.10 paf 411: push_LS(PC, LS_VAR_NAME_SIMPLE);
1.1 paf 412: result=c;
413: goto break2;
414: }
415: if(c=='^') {
1.10 paf 416: push_LS(PC, LS_METHOD_NAME);
417: result=c;
418: goto break2;
419: }
420: if(c=='@' && PC->col==0+1) {
1.1 paf 421: result=c;
1.10 paf 422: push_LS(PC, LS_DEF_NAME);
423: goto break2;
424: }
425:
426: break;
427:
428: // METHOD DEFINITION
429: case LS_DEF_NAME:
430: if(c=='[') {
431: result=c;
432: PC->ls=LS_DEF_PARAMS;
433: goto break2;
434: }
1.34 ! paf 435: if(c=='\n') { // special @NAME or wrong
1.10 paf 436: result=c;
437: pop_LS(PC);
438: goto break2;
439: }
440: break;
441: case LS_DEF_PARAMS:
442: if(c==';') {
443: result=c;
444: goto break2;
445: }
446: if(c==']') {
447: result=c;
448: PC->ls=*PC->source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT;
449: goto break2;
450: }
451: if(c=='\n') { // wrong. bailing out
452: result=c;
453: pop_LS(PC);
454: goto break2;
455: }
456: break;
457: case LS_DEF_LOCALS:
458: if(c=='[' || c==';') {
459: result=c;
460: goto break2;
461: }
462: if(c==']') {
463: result=c;
464: PC->ls=LS_DEF_COMMENT;
465: goto break2;
466: }
467: if(c=='\n') { // wrong. bailing out
468: result=c;
469: pop_LS(PC);
470: goto break2;
471: }
472: break;
473: case LS_DEF_COMMENT:
474: if(c=='\n') {
475: result=c;
476: pop_LS(PC);
1.1 paf 477: goto break2;
478: }
479: break;
480:
1.10 paf 481: // VARIABLE GET/PUT/WITH
1.1 paf 482: case LS_VAR_NAME_SIMPLE:
483: if(c==0 ||
484: c==' '|| c=='\t' || c=='\n' ||
485: c==')' || c=='}') {
486: pop_LS(PC);
1.32 paf 487: PC->source--; if(--PC->col<0) { PC->line--; PC->col=-1; }
1.13 paf 488: result=EON;
1.1 paf 489: goto break2;
490: }
1.13 paf 491: if(begin==end && c=='{') { /* ${name}, no need of EON, switching LS */
1.1 paf 492: PC->ls=LS_VAR_NAME_CURLY;
493: result=c;
494: goto break2;
495: }
1.18 paf 496: if(c==':') {
497: result=c;
498: goto break2;
499: }
1.1 paf 500: if(c=='(') {
501: PC->ls=LS_VAR_ROUND;
502: lexical_brackets_nestage=1;
503: result=c;
504: goto break2;
505: }
506: if(c=='{') {
507: PC->ls=LS_VAR_CURLY;
508: lexical_brackets_nestage=1;
509: result=c;
510: goto break2;
511: }
512: if(c=='.'/* name part delim */ || c=='$'/* name part subvar */) {
513: result=c;
514: goto break2;
515: }
516: break;
517: case LS_VAR_NAME_CURLY:
1.18 paf 518: if(c==':') {
519: result=c;
520: goto break2;
521: }
1.1 paf 522: if(c=='}') { /* ${name} finished, restoring LS */
523: pop_LS(PC);
524: result=c;
525: goto break2;
526: }
527: if(c=='.'/* name part delim */ || c=='$'/*name part subvar*/) {
528: result=c;
529: goto break2;
530: }
531: break;
532: case LS_VAR_ROUND:
533: if(c=='$') {
1.10 paf 534: push_LS(PC, LS_VAR_NAME_SIMPLE);
1.1 paf 535: result=c;
536: goto break2;
537: }
538: if(c=='^') {
1.10 paf 539: push_LS(PC, LS_METHOD_NAME);
1.1 paf 540: result=c;
541: goto break2;
542: }
543: if(c==')') {
544: if(--lexical_brackets_nestage==0) {
545: pop_LS(PC);
546: result=c;
547: goto break2;
548: }
549: }
550: if(c==';'/* operator_or_fmt;value delim */) {
551: result=c;
552: goto break2;
553: }
554: if(c=='(')
555: lexical_brackets_nestage++;
556: break;
557: case LS_VAR_CURLY:
558: if(c=='$') {
1.10 paf 559: push_LS(PC, LS_VAR_NAME_SIMPLE);
1.1 paf 560: result=c;
561: goto break2;
562: }
563: if(c=='^') {
1.10 paf 564: push_LS(PC, LS_METHOD_NAME);
1.1 paf 565: result=c;
566: goto break2;
567: }
568: if(c=='}')
569: if(--lexical_brackets_nestage==0) {
570: pop_LS(PC);
571: result=c;
572: goto break2;
573: }
574: if(c=='{')
575: lexical_brackets_nestage++;
576: break;
577:
1.10 paf 578: // METHOD CALL
1.1 paf 579: case LS_METHOD_NAME:
580: if(c=='(') {
581: PC->ls=LS_METHOD_ROUND;
582: lexical_brackets_nestage=1;
583: result=c;
584: goto break2;
585: }
586: if(c=='{') {
587: PC->ls=LS_METHOD_CURLY;
588: lexical_brackets_nestage=1;
589: result=c;
590: goto break2;
591: }
592: if(c=='.'/* name part delim */ || c=='$'/* name part subvar */) {
593: result=c;
594: goto break2;
595: }
596: break;
597: case LS_METHOD_ROUND:
598: if(c=='$') {
1.10 paf 599: push_LS(PC, LS_VAR_NAME_SIMPLE);
1.1 paf 600: result=c;
601: goto break2;
602: }
603: if(c=='^') {
1.10 paf 604: push_LS(PC, LS_METHOD_NAME);
1.1 paf 605: result=c;
606: goto break2;
607: }
608: if(c==';'/* param delim */) {
609: result=c;
610: goto break2;
611: }
612: if(c==')')
613: if(--lexical_brackets_nestage==0) {
614: PC->ls=LS_METHOD_AFTER;
615: result=c;
616: goto break2;
617: }
618: if(c=='(')
619: lexical_brackets_nestage++;
620: break;
621: case LS_METHOD_CURLY:
622: if(c=='$') {
1.10 paf 623: push_LS(PC, LS_VAR_NAME_SIMPLE);
1.1 paf 624: result=c;
625: goto break2;
626: }
627: if(c=='^') {
1.10 paf 628: push_LS(PC, LS_METHOD_NAME);
1.1 paf 629: result=c;
630: goto break2;
631: }
632: if(c=='}')
633: if(--lexical_brackets_nestage==0) {
634: PC->ls=LS_METHOD_AFTER;
635: result=c;
636: goto break2;
637: }
638: if(c=='{')
639: lexical_brackets_nestage++;
640: break;
641: case LS_METHOD_AFTER:
642: if(c=='(') {/* )( }( */
643: PC->ls=LS_METHOD_ROUND;
644: lexical_brackets_nestage=1;
645: result=c;
646: goto break2;
647: }
648: if(c=='{') {/* ){ }{ */
649: PC->ls=LS_METHOD_CURLY;
650: lexical_brackets_nestage=1;
651: result=c;
652: goto break2;
653: }
654: pop_LS(PC);
1.32 paf 655: PC->source--; if(--PC->col<0) { PC->line--; PC->col=-1; }
1.13 paf 656: result=EON;
1.1 paf 657: goto break2;
658: }
1.9 paf 659: if(c==0) {
1.1 paf 660: result=-1;
661: break;
662: }
663: }
664:
665: break2:
1.9 paf 666: if(begin==end)
1.1 paf 667: return result;
668: else {
669: PC->pending_state=result;
1.10 paf 670: // strip last \n before LS_DEF_NAME or EOF
671: if((c=='@' || c==0) && end[-1]=='\n')
672: end--;
1.30 paf 673: if(end!=begin) {
674: // append last piece
675: PC->string->APPEND(begin, end-begin, PC->file, begin_line/*, start_col*/);
676: }
1.17 paf 677: // create STRING value: array of OP_VALUE+vstring
1.25 paf 678: *lvalp=L(NEW VString(PC->string));
1.10 paf 679: // new pieces storage
1.25 paf 680: PC->string=NEW String(POOL);
1.10 paf 681: // go!
1.4 paf 682: return STRING;
1.1 paf 683: }
684: }
685:
1.9 paf 686: int real_yyerror(parse_control *pc, char *s) /* Called by yyparse on error */
1.1 paf 687: {
1.16 paf 688: //fprintf(stderr, "[%s]\n", s);
1.6 paf 689:
690: s[MAX_STRING-1]=0; strcpy(pc->error, s);
1.1 paf 691: return 1;
692: }
693:
694: static void
1.9 paf 695: yyprint(
1.1 paf 696: FILE *file,
697: int type,
698: YYSTYPE value)
699: {
1.9 paf 700: if(type==STRING)
701: fprintf(file, " \"%s\"", LA2S(value)->cstr());
1.1 paf 702: }
703:
E-mail: