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

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

E-mail: