Annotation of parser3/src/main/compile.y, revision 1.30

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

E-mail: