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

1.105     paf         1: /** @file
1.106     paf         2:        Parser: compiler(lexical parser and grammar).
                      3: 
1.87      paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.106     paf         5: 
1.89      paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.87      paf         7: 
1.111   ! paf         8:        $Id: compile.y,v 1.110 2001/03/24 10:54:46 paf Exp $
1.88      paf         9: */
                     10: 
1.106     paf        11: /**
                     12:        @todo parser4: 
                     13:        - cache compiled code from request to request. to do that...
                     14:                -#:     make method definitions, @CLASS, @BASE, @USE instructions,
1.88      paf        15:                        which would be executed afterwards, and actions
                     16:                        now performed at compile time would be delayed to run time.
1.106     paf        17:                -#:     make cache expiration on time and on disk-change of class source
                     18:                -#:     in apache use subpools for compiled class storage
                     19:                -#:     in iis make up specialized Pool object for that
1.24      paf        20: */
                     21: 
1.1       paf        22: %{
1.90      paf        23: #define YYSTYPE  Array/*<Operation>*/ *
1.9       paf        24: #define YYPARSE_PARAM  pc
                     25: #define YYLEX_PARAM  pc
                     26: #define YYDEBUG  1
1.106     paf        27: #define YYERROR_VERBOSE        1
1.9       paf        28: #define yyerror(msg)  real_yyerror((parse_control *)pc, msg)
                     29: #define YYPRINT(file, type, value)  yyprint(file, type, value)
1.1       paf        30: 
1.108     paf        31: #include "pa_config_includes.h"
1.1       paf        32: #include <stdio.h>
                     33: #include <stdlib.h>
                     34: 
                     35: #include "compile_tools.h"
1.8       paf        36: #include "pa_value.h"
1.12      paf        37: #include "pa_request.h"
1.39      paf        38: #include "pa_vobject.h"
1.52      paf        39: #include "pa_vdouble.h"
1.98      paf        40: #include "pa_globals.h"
1.39      paf        41: 
1.85      paf        42: #define SELF_ELEMENT_NAME "self"
1.97      paf        43: #define USE_CONTROL_METHOD_NAME "USE"
1.1       paf        44: 
1.9       paf        45: int real_yyerror(parse_control *pc, char *s);
                     46: static void yyprint(FILE *file, int type, YYSTYPE value);
1.1       paf        47: int yylex(YYSTYPE *lvalp, void *pc);
                     48: 
                     49: 
1.8       paf        50: // local convinient inplace typecast & var
1.9       paf        51: #define PC  ((parse_control *)pc)
1.25      paf        52: #define POOL  *PC->pool
                     53: #undef NEW
                     54: #define NEW new(POOL)
1.107     paf        55: #ifndef DOXYGEN
1.1       paf        56: %}
                     57: 
                     58: %pure_parser
                     59: 
1.13      paf        60: %token EON
1.4       paf        61: %token STRING
1.1       paf        62: %token BOGUS
1.55      paf        63: 
1.58      paf        64: %token BAD_STRING_COMPARISON_OPERATOR
                     65: 
1.59      paf        66: %token LAND "&&"
1.58      paf        67: %token LOR "||"
1.59      paf        68: %token LXOR "##"
1.58      paf        69: 
                     70: %token NLE "<="
                     71: %token NGE ">="
                     72: %token NEQ "=="
                     73: %token NNE "!="
                     74: 
                     75: %token SLT "lt"
                     76: %token SGT "gt"
                     77: %token SLE "le"
                     78: %token SGE "ge"
                     79: %token SEQ "eq"
                     80: %token SNE "ne"
                     81: 
1.67      paf        82: %token DEF "def"
                     83: %token IN "in"
                     84: %token FEXISTS "-f"
1.95      paf        85: %token IS "is"
1.67      paf        86: 
1.57      paf        87: /* logical */
1.95      paf        88: %left "is"
1.61      paf        89: %left "lt" "gt" "le" "ge"
                     90: %left "eq" "ne"
1.59      paf        91: %left '<' '>' "<=" ">=" "##"
1.57      paf        92: %left "==" "!="
                     93: %left "||"
                     94: %left "&&"
1.67      paf        95: %left "def" "in" "-f"
1.68      paf        96: %left '!'
1.57      paf        97: 
                     98: /* bitwise */
1.59      paf        99: %left '#'
1.57      paf       100: %left '&' '|'
1.68      paf       101: %left '~'
1.57      paf       102: 
1.56      paf       103: /* numerical */
1.55      paf       104: %left '-' '+'
1.57      paf       105: %left '*' '/' '%'
1.56      paf       106: %left NEG     /* negation: unary - */
1.1       paf       107: 
                    108: %%
1.88      paf       109: all:
1.10      paf       110:        one_big_piece {
1.75      paf       111:        Method& method=*NEW Method(POOL, 
1.85      paf       112:                *main_method_name, 
1.81      paf       113:                0, 0, /*min, max numbered_params_count*/
1.75      paf       114:                0/*param_names*/, 0/*local_names*/, 
                    115:                $1/*parser_code*/, 0/*native_code*/);
1.91      paf       116:        PC->cclass->add_method(*main_method_name, method);
1.10      paf       117: }
                    118: |      methods;
                    119: 
                    120: methods: method | methods method;
                    121: one_big_piece: maybe_codes;
                    122: 
1.34      paf       123: method: control_method | code_method;
                    124: 
                    125: control_method: '@' STRING '\n' 
                    126:                                control_strings {
1.82      paf       127:        const String& command=*SLA2S($2);
1.34      paf       128:        YYSTYPE strings_code=$4;
1.37      paf       129:        if(strings_code->size()<1*2) {
                    130:                strcpy(PC->error, "@");
1.74      paf       131:                strcat(PC->error, command.cstr());
1.37      paf       132:                strcat(PC->error, " is empty");
                    133:                YYERROR;
                    134:        }
1.74      paf       135:        if(command==CLASS_NAME) {
1.104     paf       136:                if(PC->cclass!=&PC->request->ROOT) { // already changed from default?
1.73      paf       137:                        strcpy(PC->error, "class already have a name '");
1.91      paf       138:                        strncat(PC->error, PC->cclass->name().cstr(), 100);
1.73      paf       139:                        strcat(PC->error, "'");
                    140:                        YYERROR;
                    141:                }
                    142:                if(strings_code->size()==1*2) {
                    143:                        // new class' name
1.82      paf       144:                        const String *name=SLA2S(strings_code);
1.73      paf       145:                        // creating the class
1.91      paf       146:                        PC->cclass=NEW VClass(POOL);
                    147:                        PC->cclass->set_name(*name);
1.73      paf       148:                        // defaulting base. may change with @BASE
1.104     paf       149:                        PC->cclass->set_base(PC->request->ROOT);
1.73      paf       150:                        // append to request's classes
1.91      paf       151:                        PC->request->classes().put(*name, PC->cclass);
1.73      paf       152:                } else {
1.34      paf       153:                        strcpy(PC->error, "@"CLASS_NAME" must contain sole name");
                    154:                        YYERROR;
                    155:                }
                    156:        } else {
1.85      paf       157:                if(command==USE_CONTROL_METHOD_NAME) {
1.109     paf       158:                        for(int i=0; i<strings_code->size(); i+=2) 
                    159:                                PC->request->use_file(
1.111   ! paf       160:                                        PC->request->absolute(*SLA2S(strings_code, i)));
1.74      paf       161:                } else if(command==BASE_NAME) {
1.104     paf       162:                        if(PC->cclass->base()!=&PC->request->ROOT) { // already changed from default?
1.86      paf       163:                                strcpy(PC->error, "class already have a base '");
1.91      paf       164:                                strncat(PC->error, PC->cclass->base()->name().cstr(), 100);
1.86      paf       165:                                strcat(PC->error, "'");
1.73      paf       166:                                YYERROR;
                    167:                        }
1.45      paf       168:                        if(strings_code->size()==1*2) {
1.82      paf       169:                                const String& base_name=*SLA2S(strings_code);
1.45      paf       170:                                VClass *base=static_cast<VClass *>(
                    171:                                        PC->request->classes().get(base_name));
                    172:                                if(!base) {
                    173:                                        strcpy(PC->error, base_name.cstr());
                    174:                                        strcat(PC->error, ": undefined class in @"BASE_NAME);
1.109     paf       175:                                        YYERROR;
                    176:                                }
                    177:                                // @CLASS == @BASE sanity check
                    178:                                if(PC->cclass==base) {
                    179:                                        strcpy(PC->error, "@"CLASS_NAME" equals @"BASE_NAME);
1.34      paf       180:                                        YYERROR;
                    181:                                }
1.91      paf       182:                                PC->cclass->set_base(*base);
1.45      paf       183:                        } else {
                    184:                                strcpy(PC->error, "@"BASE_NAME" must contain sole name");
                    185:                                YYERROR;
1.34      paf       186:                        }
                    187:                } else {
1.92      paf       188:                        strcpy(PC->error, "'");
1.93      paf       189:                        strncat(PC->error, command.cstr(), MAX_STRING/2);
1.92      paf       190:                        strcat(PC->error, "' invalid special name. valid names are "
                    191:                                "'"CLASS_NAME"', '"USE_CONTROL_METHOD_NAME"' and '"BASE_NAME"'");
1.34      paf       192:                        YYERROR;
                    193:                }
                    194:        }
                    195: };
1.37      paf       196: control_strings: control_string | control_strings control_string { $$=$1; P($$, $2) };
                    197: control_string: maybe_string '\n';
                    198: maybe_string: empty | STRING;
1.34      paf       199: 
                    200: code_method: '@' STRING bracketed_maybe_strings maybe_bracketed_strings maybe_comment '\n' 
1.10      paf       201:                        maybe_codes {
1.38      paf       202:        const String *name=SLA2S($2);
1.10      paf       203: 
                    204:        YYSTYPE params_names_code=$3;
1.75      paf       205:        Array *params_names=0;
                    206:        if(int size=params_names_code->size()) {
                    207:                params_names=NEW Array(POOL);
                    208:                for(int i=0; i<size; i+=2)
                    209:                        *params_names+=SLA2S(params_names_code, i);
                    210:        }
1.10      paf       211: 
                    212:        YYSTYPE locals_names_code=$4;
1.75      paf       213:        Array *locals_names=0;
                    214:        if(int size=locals_names_code->size()) {
                    215:                locals_names=NEW Array(POOL);
                    216:                for(int i=0; i<size; i+=2)
                    217:                        *locals_names+=SLA2S(locals_names_code, i);
                    218:        }
1.10      paf       219: 
1.76      paf       220:        Method& method=*NEW Method(POOL, 
                    221:                *name, 
1.81      paf       222:                0, 0/*min,max numbered_params_count*/, 
1.76      paf       223:                params_names, locals_names, 
                    224:                $7, 0);
1.91      paf       225:        PC->cclass->add_method(*name, method);
1.8       paf       226: };
1.10      paf       227: 
                    228: maybe_bracketed_strings: empty | bracketed_maybe_strings;
                    229: bracketed_maybe_strings: '[' maybe_strings ']' {$$=$2};
                    230: maybe_strings: empty | strings;
                    231: strings: STRING | strings ';' STRING { $$=$1; P($$, $3) };
                    232: 
                    233: maybe_comment: empty | STRING;
1.1       paf       234: 
                    235: /* codes */
                    236: 
1.10      paf       237: maybe_codes: empty | codes;
                    238: 
1.90      paf       239: codes: code | codes code { $$=$1; P($$, $2) };
1.81      paf       240: code: write_string | action;
1.1       paf       241: action: get | put | with | call;
                    242: 
                    243: /* get */
                    244: 
1.64      paf       245: get: get_value {
                    246:        $$=$1; /* stack: resulting value */
1.102     paf       247:        O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */
1.1       paf       248: };
1.64      paf       249: get_value: '$' get_name_value { $$=$2 }
                    250: get_name_value: name_without_curly_rdive EON | name_in_curly_rdive;
1.1       paf       251: name_in_curly_rdive: '{' name_without_curly_rdive '}' { $$=$2 };
1.44      paf       252: name_without_curly_rdive: 
                    253:        name_without_curly_rdive_read 
                    254: |      name_without_curly_rdive_root
                    255: |      name_without_curly_rdive_class;
1.19      paf       256: name_without_curly_rdive_read: name_without_curly_rdive_code {
1.25      paf       257:        $$=N(POOL); 
1.22      paf       258:        Array *diving_code=$1;
1.82      paf       259:        const String *first_name=SLA2S(diving_code);
1.85      paf       260:        if(first_name && *first_name==SELF_ELEMENT_NAME) {
1.54      paf       261:                O($$, OP_WITH_SELF); /* stack: starting context */
1.22      paf       262:                P($$, diving_code, 
                    263:                        /* skip over... */
                    264:                        diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/);
                    265:        } else {
1.54      paf       266:                O($$, OP_WITH_READ); /* stack: starting context */
1.22      paf       267:                P($$, diving_code);
                    268:        }
                    269:        /* diving code; stack: current context */
1.1       paf       270: };
1.19      paf       271: name_without_curly_rdive_root: ':' name_without_curly_rdive_code {
1.25      paf       272:        $$=N(POOL); 
1.54      paf       273:        O($$, OP_WITH_ROOT); /* stack: starting context */
1.19      paf       274:        P($$, $2); /* diving code; stack: current context */
                    275: };
1.44      paf       276: name_without_curly_rdive_class: class_prefix name_without_curly_rdive_code { $$=$1; P($$, $2) };
1.19      paf       277: name_without_curly_rdive_code: name_advance2 | name_path name_advance2 { $$=$1; P($$, $2) };
1.1       paf       278: 
                    279: /* put */
                    280: 
1.81      paf       281: put: '$' name_expr_wdive construct {
1.20      paf       282:        $$=$2; /* stack: context,name */
1.52      paf       283:        P($$, $3); /* stack: context,name,constructor_value */
1.20      paf       284: };
1.44      paf       285: name_expr_wdive: 
                    286:        name_expr_wdive_write
                    287: |      name_expr_wdive_root
                    288: |      name_expr_wdive_class;
1.28      paf       289: name_expr_wdive_write: name_expr_dive_code {
1.44      paf       290:        $$=N(POOL);
1.23      paf       291:        Array *diving_code=$1;
1.82      paf       292:        const String *first_name=SLA2S(diving_code);
1.85      paf       293:        if(first_name && *first_name==SELF_ELEMENT_NAME) {
1.54      paf       294:                O($$, OP_WITH_SELF); /* stack: starting context */
1.23      paf       295:                P($$, diving_code, 
                    296:                        /* skip over... */
                    297:                        diving_code->size()>2?3/*OP_+string+get_element*/:2/*OP_+string*/);
                    298:        } else {
1.54      paf       299:                O($$, OP_WITH_WRITE); /* stack: starting context */
1.23      paf       300:                P($$, diving_code);
                    301:        }
                    302:        /* diving code; stack: current context */
1.20      paf       303: };
1.28      paf       304: name_expr_wdive_root: ':' name_expr_dive_code {
1.25      paf       305:        $$=N(POOL); 
1.54      paf       306:        O($$, OP_WITH_ROOT); /* stack: starting context */
1.9       paf       307:        P($$, $2); /* diving code; stack: context,name */
1.1       paf       308: };
1.44      paf       309: name_expr_wdive_class: class_prefix name_expr_dive_code { $$=$1; P($$, $2) };
1.20      paf       310: 
1.81      paf       311: construct: construct_by_code | construct_by_expr;
                    312: construct_by_code: '[' any_constructor_code_value ']' {
                    313:        $$=$2; /* stack: context, name, value */
                    314:        O($$, OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */
                    315: }
                    316: ;
1.90      paf       317: construct_by_expr: '(' expr_value ')' { 
1.81      paf       318:        $$=$2; /* stack: context, name, value */
                    319:        O($$, OP_CONSTRUCT_EXPR); /* value=pop; name=pop; context=pop; construct(context,name,value) */
                    320: }
1.52      paf       321: ;
1.55      paf       322: any_constructor_code_value: 
                    323:        empty_string_value /* optimized $var[] case */
1.52      paf       324: |      STRING /* optimized $var[STRING] case */
1.55      paf       325: |      constructor_code_value /* $var[something complex] */
1.1       paf       326: ;
1.55      paf       327: constructor_code_value: constructor_code {
1.25      paf       328:        $$=N(POOL); 
1.54      paf       329:        O($$, OP_CREATE_EWPOOL); /* stack: empty write context */
1.69      paf       330:        P($$, $1); /* some code that writes to that context */
1.54      paf       331:        O($$, OP_REDUCE_EWPOOL); /* context=pop; stack: context.value() */
1.1       paf       332: };
1.55      paf       333: constructor_code: codes__excluding_sole_str_literal;
1.27      paf       334: codes__excluding_sole_str_literal: action | code codes { $$=$1; P($$, $2) };
                    335: 
1.1       paf       336: /* call */
                    337: 
1.66      paf       338: call: call_value {
                    339:        $$=$1; /* stack: value */
1.102     paf       340:        O($$, OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */
1.66      paf       341: };
                    342: call_value: '^' call_name store_params EON { /* ^field.$method{vasya} */
1.42      paf       343:        $$=$2; /* with_xxx,diving code; stack: context,method_junction */
1.54      paf       344:        O($$, OP_GET_METHOD_FRAME); /* stack: context,method_frame */
1.9       paf       345:        P($$, $3); /* filling method_frame.store_params */
1.66      paf       346:        O($$, OP_CALL); /* method_frame=pop; ncontext=pop; call(ncontext,method_frame) stack: value */
1.1       paf       347: };
                    348: 
1.43      paf       349: call_name: name_without_curly_rdive;
1.38      paf       350: 
1.9       paf       351: store_params: store_param | store_params store_param { $$=$1; P($$, $2) };
1.69      paf       352: store_param: 
                    353:        store_square_param
                    354: |      store_round_param
                    355: |      store_curly_param
1.31      paf       356: ;
1.69      paf       357: store_square_param: '[' store_code_param_parts ']' {$$=$2};
                    358: store_round_param: '(' store_expr_param_parts ')' {$$=$2};
1.94      paf       359: store_curly_param: '{' store_curly_param_parts '}' {$$=$2};
1.69      paf       360: store_code_param_parts:
                    361:        store_code_param_part
                    362: |      store_code_param_parts ';' store_code_param_part { $$=$1; P($$, $3) }
                    363: ;
                    364: store_expr_param_parts:
                    365:        store_expr_param_part
                    366: |      store_expr_param_parts ';' store_expr_param_part { $$=$1; P($$, $3) }
                    367: ;
1.94      paf       368: store_curly_param_parts:
                    369:        store_curly_param_part
                    370: |      store_curly_param_parts ';' store_curly_param_part { $$=$1; P($$, $3) }
                    371: ;
1.69      paf       372: store_code_param_part: 
1.78      paf       373:        empty /* optimized [] case */
                    374: |      STRING { /* optimized [STRING] case */
1.32      paf       375:        $$=$1;
1.54      paf       376:        O($$, OP_STORE_PARAM);
1.32      paf       377: }
1.78      paf       378: |      constructor_code_value { /* [something complex] */
1.32      paf       379:        $$=$1;
1.77      paf       380:        O($$, OP_STORE_PARAM);
1.32      paf       381: }
                    382: ;
1.69      paf       383: store_expr_param_part: write_expr_value {
                    384:        $$=N(POOL); 
1.103     paf       385:        PEA($$, $1);
1.69      paf       386: };
1.94      paf       387: store_curly_param_part: maybe_codes {
                    388:        $$=N(POOL); 
                    389:        PCA($$, $1);
                    390: };
1.90      paf       391: write_expr_value: expr_value {
1.69      paf       392:        $$=$1;
1.102     paf       393:        O($$, OP_WRITE_EXPR_RESULT);
1.69      paf       394: };
1.1       paf       395: 
                    396: /* name */
                    397: 
1.20      paf       398: name_expr_dive_code: name_expr_value | name_path name_expr_value { $$=$1; P($$, $2) };
1.1       paf       399: 
1.9       paf       400: name_path: name_step | name_path name_step { $$=$1; P($$, $2) };
1.1       paf       401: name_step: name_advance1 '.';
                    402: name_advance1: name_expr_value {
                    403:        /* stack: context */
                    404:        $$=$1; /* stack: context,name */
1.54      paf       405:        O($$, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.1       paf       406: };
                    407: name_advance2: name_expr_value {
                    408:        /* stack: context */
                    409:        $$=$1; /* stack: context,name */
1.54      paf       410:        O($$, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */
1.1       paf       411: }
1.4       paf       412: |      STRING BOGUS
1.1       paf       413: ;
                    414: name_expr_value: 
1.4       paf       415:        STRING /* subname_is_const */
1.1       paf       416: |      name_expr_subvar_value /* $subname_is_var_value */
                    417: |      name_expr_with_subvar_value /* xxx$part_of_subname_is_var_value[$...] */
                    418: ;
                    419: name_expr_subvar_value: '$' subvar_ref_name_rdive {
                    420:        $$=$2;
1.54      paf       421:        O($$, OP_GET_ELEMENT);
1.1       paf       422: };
1.4       paf       423: name_expr_with_subvar_value: STRING subvar_get_writes {
1.25      paf       424:        $$=N(POOL); 
1.54      paf       425:        O($$, OP_CREATE_EWPOOL);
1.9       paf       426:        P($$, $1);
1.102     paf       427:        O($$, OP_WRITE_VALUE);
1.9       paf       428:        P($$, $2);
1.54      paf       429:        O($$, OP_REDUCE_EWPOOL);
1.1       paf       430: };
1.18      paf       431: subvar_ref_name_rdive: subvar_ref_name_rdive_read | subvar_ref_name_rdive_root;
                    432: subvar_ref_name_rdive_read: STRING {
1.25      paf       433:        $$=N(POOL); 
1.54      paf       434:        O($$, OP_WITH_READ);
1.9       paf       435:        P($$, $1);
1.1       paf       436: };
1.18      paf       437: subvar_ref_name_rdive_root: ':' STRING {
1.25      paf       438:        $$=N(POOL); 
1.54      paf       439:        O($$, OP_WITH_ROOT);
1.18      paf       440:        P($$, $2);
                    441: };
1.9       paf       442: subvar_get_writes: subvar__get_write | subvar_get_writes subvar__get_write { $$=$1; P($$, $2) };
1.1       paf       443: subvar__get_write: '$' subvar_ref_name_rdive {
                    444:        $$=$2;
1.54      paf       445:        O($$, OP_GET_ELEMENT__WRITE);
1.42      paf       446: };
                    447: 
1.44      paf       448: class_prefix: STRING ':' {
1.72      paf       449:        $$=$1; // stack: class name string
                    450:        O($$, OP_GET_CLASS);
1.1       paf       451: };
                    452: 
                    453: 
                    454: /* with */
                    455: 
                    456: with: '$' name_without_curly_rdive '{' codes '}' {
                    457:        $$=$2;
1.54      paf       458:        O($$, OP_CREATE_RWPOOL);
1.9       paf       459:        P($$, $4);
1.54      paf       460:        O($$, OP_REDUCE_RWPOOL);
1.102     paf       461:        O($$, OP_WRITE_VALUE);
1.1       paf       462: };
1.53      paf       463: 
1.56      paf       464: /* expr */
1.53      paf       465: 
1.81      paf       466: expr_value: expr {
                    467:        if(($$=$1)->size()==2) // only one string literal in there?
1.62      paf       468:                change_string_literal_to_double_literal($$); // make that string literal Double
                    469: };
1.56      paf       470: expr: 
1.62      paf       471:        STRING
1.64      paf       472: |      get_value
1.66      paf       473: |      call_value
1.64      paf       474: |      '"' string_inside_quotes_value '"' { $$ = $2; }
1.60      paf       475: |      '(' expr ')' { $$ = $2; }
                    476: /* stack: operand // stack: @operand */
                    477: |      '-' expr %prec NEG { $$=$2;  O($$, OP_NEG) }
1.68      paf       478: |      '~' expr { $$=$2;        O($$, OP_INV) }
                    479: |      '!' expr { $$=$2;  O($$, OP_NOT) }
                    480: |      "def" expr { $$=$2;  O($$, OP_DEF) }
                    481: |      "in" expr { $$=$2;  O($$, OP_IN) }
                    482: |      "-f" expr { $$=$2;  O($$, OP_FEXISTS) }
1.60      paf       483: /* stack: a,b // stack: a@b */
                    484: |      expr '-' expr { $$=$1;  P($$, $3);  O($$, OP_SUB) }
                    485: |      expr '+' expr { $$=$1;  P($$, $3);  O($$, OP_ADD) }
                    486: |      expr '*' expr { $$=$1;  P($$, $3);  O($$, OP_MUL) }
                    487: |      expr '/' expr { $$=$1;  P($$, $3);  O($$, OP_DIV) }
                    488: |      expr '%' expr { $$=$1;  P($$, $3);  O($$, OP_MOD) }
                    489: |      expr '&' expr { $$=$1;  P($$, $3);  O($$, OP_BIN_AND) }
                    490: |      expr '|' expr { $$=$1;  P($$, $3);  O($$, OP_BIN_OR) }
                    491: |      expr '#' expr { $$=$1;  P($$, $3);  O($$, OP_BIN_XOR) }
                    492: |      expr "&&" expr { $$=$1;  P($$, $3);  O($$, OP_LOG_AND) }
                    493: |      expr "||" expr { $$=$1;  P($$, $3);  O($$, OP_LOG_OR) }
                    494: |      expr "##" expr { $$=$1;  P($$, $3);  O($$, OP_LOG_XOR) }
                    495: |      expr '<' expr { $$=$1;  P($$, $3);  O($$, OP_NUM_LT) }
                    496: |      expr '>' expr { $$=$1;  P($$, $3);  O($$, OP_NUM_GT) }
                    497: |      expr "<=" expr { $$=$1;  P($$, $3);  O($$, OP_NUM_LE) }
                    498: |      expr ">=" expr { $$=$1;  P($$, $3);  O($$, OP_NUM_GE) }
                    499: |      expr "==" expr { $$=$1;  P($$, $3);  O($$, OP_NUM_EQ) }
                    500: |      expr "!=" expr { $$=$1;  P($$, $3);  O($$, OP_NUM_NE) }
1.61      paf       501: |      expr "lt" expr { $$=$1;  P($$, $3);  O($$, OP_STR_LT) }
                    502: |      expr "gt" expr { $$=$1;  P($$, $3);  O($$, OP_STR_GT) }
                    503: |      expr "le" expr { $$=$1;  P($$, $3);  O($$, OP_STR_LE) }
                    504: |      expr "ge" expr { $$=$1;  P($$, $3);  O($$, OP_STR_GE) }
                    505: |      expr "eq" expr { $$=$1;  P($$, $3);  O($$, OP_STR_EQ) }
                    506: |      expr "ne" expr { $$=$1;  P($$, $3);  O($$, OP_STR_NE) }
1.95      paf       507: |      expr "is" expr { $$=$1;  P($$, $3);  O($$, OP_IS) }
1.56      paf       508: ;
1.55      paf       509: 
1.65      paf       510: string_inside_quotes_value: maybe_codes {
1.64      paf       511:        $$=N(POOL);
                    512:        O($$, OP_CREATE_SWPOOL); /* stack: empty write context */
1.69      paf       513:        P($$, $1); /* some code that writes to that context */
1.64      paf       514:        O($$, OP_REDUCE_SWPOOL); /* context=pop; stack: context.get_string() */
1.53      paf       515: };
1.1       paf       516: 
1.27      paf       517: /* basics */
1.1       paf       518: 
1.81      paf       519: write_string: STRING {
1.102     paf       520:        // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE
1.84      paf       521:        change_string_literal_to_write_string_literal($$=$1)
1.54      paf       522: };
                    523: 
1.81      paf       524: empty_string_value: /* empty */ { $$=VL(NEW VString(POOL)) };
1.25      paf       525: empty: /* empty */ { $$=N(POOL) };
1.1       paf       526: 
                    527: %%
1.105     paf       528: #endif
1.1       paf       529: 
                    530: /*
                    531:        000$111(2222)00 
                    532:                000$111{3333}00
1.9       paf       533:        $,^: push,=0
1.1       paf       534:        1:( { break=pop
                    535:        2:( )  pop
                    536:        3:{ }  pop
                    537: 
                    538:        000^111(2222)4444{33333}4000
1.9       paf       539:        $,^: push,=0
1.1       paf       540:        1:( { break=pop
                    541:        2:( )=4
                    542:        3:{ }=4
                    543:                4:[^({]=pop
                    544: */
                    545: 
1.110     paf       546: static int yylex(YYSTYPE *lvalp, void *pc) {
1.1       paf       547:        #define lexical_brackets_nestage PC->brackets_nestages[PC->sp]
1.48      paf       548:        #define RC {result=c; goto break2; }
1.1       paf       549: 
                    550:     register int c;
                    551:     int result;
                    552:        
                    553:        if(PC->pending_state) {
                    554:                result=PC->pending_state;
                    555:                PC->pending_state=0;
                    556:                return result;
                    557:        }
                    558:        
1.91      paf       559:        const char *begin=PC->source;
                    560:        const char *end;
1.9       paf       561:        int begin_line=PC->line;
1.67      paf       562:        int skip_analized=0;
1.50      paf       563:        while(true) {
1.9       paf       564:                c=*(end=(PC->source++));
1.1       paf       565: 
1.4       paf       566:                if(c=='\n') {
1.1       paf       567:                        PC->line++;
1.8       paf       568:                        PC->col=0;
1.10      paf       569:                } else
1.4       paf       570:                        PC->col++;
1.73      paf       571: 
                    572:                // todo: # in 0+1 column comment
1.1       paf       573: 
1.48      paf       574:                // escaping: ^^ ^$ ^; ^) ^} ^( ^{ ^"
                    575:                if(c=='^') 
                    576:                        switch(*PC->source) {
                    577:                        case '^': case '$': case ';':
                    578:                        case '[': case ']':
                    579:                        case '{': case '}':
                    580:                        case '"':
1.40      paf       581:                                if(end!=begin) {
                    582:                                        // append piece till ^
                    583:                                        PC->string->APPEND(begin, end-begin, PC->file, begin_line);
                    584:                                }
1.63      paf       585:                                // reset piece 'begin' position & line
1.40      paf       586:                                begin=PC->source; // ^
1.9       paf       587:                                begin_line=PC->line;
1.40      paf       588:                                // skip over ^ and _
1.50      paf       589:                                PC->source++;  PC->col++;
1.40      paf       590:                                // skip analysis = forced literal
1.1       paf       591:                                continue;
                    592:                        }
                    593:                switch(PC->ls) {
1.10      paf       594: 
                    595:                // USER'S = NOT OURS
1.1       paf       596:                case LS_USER:
1.48      paf       597:                        switch(c) {
                    598:                        case '$':
1.10      paf       599:                                push_LS(PC, LS_VAR_NAME_SIMPLE);
1.48      paf       600:                                RC;
                    601:                        case '^':
                    602:                                push_LS(PC, LS_METHOD_NAME);
                    603:                                RC;
                    604:                        case '@':
                    605:                                if(PC->col==0+1) {
                    606:                                        push_LS(PC, LS_DEF_NAME);
                    607:                                        RC;
                    608:                                }
                    609:                                break;
1.1       paf       610:                        }
1.48      paf       611:                        break;
                    612:                        
                    613:                // STRING IN EXPRESSION
                    614:                case LS_EXPRESSION_STRING:
                    615:                        switch(c) {
                    616:                        case '"':
                    617:                                pop_LS(PC); //"abc".
                    618:                                RC;
                    619:                        case '$':
                    620:                                push_LS(PC, LS_VAR_NAME_SIMPLE);
                    621:                                RC;
                    622:                        case '^':
1.10      paf       623:                                push_LS(PC, LS_METHOD_NAME);
1.48      paf       624:                                RC;
1.10      paf       625:                        }
                    626:                        break;
                    627: 
                    628:                // METHOD DEFINITION
                    629:                case LS_DEF_NAME:
1.48      paf       630:                        switch(c) {
                    631:                        case '[':
1.10      paf       632:                                PC->ls=LS_DEF_PARAMS;
1.48      paf       633:                                RC;
                    634:                        case '\n':
                    635:                                PC->ls=LS_DEF_SPECIAL_BODY;
                    636:                                RC;
1.10      paf       637:                        }
                    638:                        break;
1.48      paf       639: 
1.10      paf       640:                case LS_DEF_PARAMS:
1.48      paf       641:                        switch(c) {
                    642:                        case ';':
                    643:                                RC;
                    644:                        case ']':
1.10      paf       645:                                PC->ls=*PC->source=='['?LS_DEF_LOCALS:LS_DEF_COMMENT;
1.48      paf       646:                                RC;
1.49      paf       647:                        case '\n': // wrong. bailing out
1.10      paf       648:                                pop_LS(PC);
1.48      paf       649:                                RC;
1.10      paf       650:                        }
                    651:                        break;
1.48      paf       652: 
1.10      paf       653:                case LS_DEF_LOCALS:
1.48      paf       654:                        switch(c) {
                    655:                        case '[':
                    656:                        case ';':
                    657:                                RC;
                    658:                        case ']':
1.10      paf       659:                                PC->ls=LS_DEF_COMMENT;
1.48      paf       660:                                RC;
                    661:                        case '\n': // wrong. bailing out
1.10      paf       662:                                pop_LS(PC);
1.48      paf       663:                                RC;
1.10      paf       664:                        }
                    665:                        break;
1.48      paf       666: 
1.10      paf       667:                case LS_DEF_COMMENT:
                    668:                        if(c=='\n') {
                    669:                                pop_LS(PC);
1.48      paf       670:                                RC;
1.37      paf       671:                        }
                    672:                        break;
                    673: 
1.48      paf       674:                case LS_DEF_SPECIAL_BODY:
1.37      paf       675:                        if(c=='\n') {
1.48      paf       676:                                switch(*PC->source) {
                    677:                                case '@': case 0: // end of special_code
1.37      paf       678:                                        pop_LS(PC);
1.48      paf       679:                                        break;
                    680:                                }
                    681:                                RC;
                    682:                        }
                    683:                        break;
                    684: 
                    685:                // (EXPRESSION)
1.69      paf       686:                case LS_VAR_ROUND:
                    687:                case LS_METHOD_ROUND:
1.48      paf       688:                        switch(c) {
                    689:                        case ')':
                    690:                                if(--lexical_brackets_nestage==0)
1.69      paf       691:                                        if(PC->ls==LS_METHOD_ROUND) // method round param ended
                    692:                                                PC->ls=LS_METHOD_AFTER; // look for method end
                    693:                                        else // PC->ls==LS_VAR_ROUND // variable constructor ended
                    694:                                                pop_LS(PC); // return to normal life
1.48      paf       695:                                RC;
                    696:                        case '$':
1.69      paf       697:                                push_LS(PC, LS_EXPRESSION_VAR_NAME);                            
1.48      paf       698:                                RC;
                    699:                        case '^':
                    700:                                push_LS(PC, LS_METHOD_NAME);
                    701:                                RC;
                    702:                        case '(':
                    703:                                lexical_brackets_nestage++;
                    704:                                RC;
1.67      paf       705:                        case '-':
                    706:                                if(*PC->source=='f') { // -f
                    707:                                        skip_analized=1;
                    708:                                        result=FEXISTS;
                    709:                                } else
                    710:                                        result=c;
                    711:                                goto break2;
                    712:                        case '+': case '*': case '/': case '%': 
1.58      paf       713:                        case '~':
1.48      paf       714:                        case ';':
                    715:                                RC;
1.59      paf       716:                        case '&': case '|':  case '#':
1.58      paf       717:                                if(*PC->source==c) { // && ||
1.59      paf       718:                                        result=c=='#'?LXOR:c=='&'?LAND:LOR;
1.67      paf       719:                                        skip_analized=1;
1.58      paf       720:                                } else
                    721:                                        result=c;
                    722:                                goto break2;
                    723:                        case '<': case '>': case '=': case '!': 
                    724:                                if(*PC->source=='=') { // <= >= == !=
1.67      paf       725:                                        skip_analized=1;
1.58      paf       726:                                        switch(c) {
                    727:                                        case '<': result=NLE; break;
                    728:                                        case '>': result=NGE; break;
                    729:                                        case '=': result=NEQ; break;
                    730:                                        case '!': result=NNE; break;
                    731:                                        }
                    732:                                } else
                    733:                                        result=c;
                    734:                                goto break2;
1.48      paf       735:                        case '"':
                    736:                                push_LS(PC, LS_EXPRESSION_STRING);
                    737:                                RC;
1.50      paf       738:                        case 'l': case 'g': case 'e': case 'n':
1.51      paf       739:                                if(end==begin) // right after whitespace
1.58      paf       740:                                        switch(*PC->source) {
1.51      paf       741: //                                     case '?': // ok [and bad cases, yacc would bark at them]
                    742:                                        case 't': // lt gt [et nt]
1.62      paf       743:                                                result=c=='l'?SLT:c=='g'?SGT:BAD_STRING_COMPARISON_OPERATOR;
1.67      paf       744:                                                skip_analized=1;
1.58      paf       745:                                                goto break2;
1.51      paf       746:                                        case 'e': // le ge ne [ee]
1.58      paf       747:                                                result=c=='l'?SLE:c=='g'?SGE:c=='n'?SNE:BAD_STRING_COMPARISON_OPERATOR;
1.67      paf       748:                                                skip_analized=1;
1.58      paf       749:                                                goto break2;
1.51      paf       750:                                        case 'q': // eq [lq gq nq]
1.58      paf       751:                                                result=c=='e'?SEQ:BAD_STRING_COMPARISON_OPERATOR;
1.67      paf       752:                                                skip_analized=1;
                    753:                                                goto break2;
                    754:                                        }
                    755:                                break;
                    756:                        case 'i':
                    757:                                if(end==begin) // right after whitespace
1.95      paf       758:                                        switch(PC->source[0]) {
                    759:                                        case 'n': 
                    760:                                                { // in
                    761:                                                        skip_analized=1;
                    762:                                                        result=IN;
                    763:                                                        goto break2;
                    764:                                                }
                    765:                                        case 's': 
                    766:                                                { // is
                    767:                                                        skip_analized=1;
                    768:                                                        result=IS;
                    769:                                                        goto break2;
                    770:                                                }
1.67      paf       771:                                        }
                    772:                                break;
                    773:                        case 'd':
                    774:                                if(end==begin) // right after whitespace
                    775:                                        if(PC->source[0]=='e' && PC->source[1]=='f') { // def
                    776:                                                skip_analized=2;
                    777:                                                result=DEF;
1.58      paf       778:                                                goto break2;
1.50      paf       779:                                        }
1.48      paf       780:                                break;
                    781:                        case ' ': case '\t': case '\n':
1.63      paf       782:                                if(end!=begin) { // there were a string after previous operator?
                    783:                                        result=0; // return that string
                    784:                                        goto break2;
1.48      paf       785:                                }
1.63      paf       786:                                // that's a leading|traling space or after-operator-space
                    787:                                // ignoring it
                    788:                                // reset piece 'begin' position & line
1.58      paf       789:                                begin=PC->source; // after whitespace char
1.48      paf       790:                                begin_line=PC->line;
                    791:                                continue;
1.1       paf       792:                        }
                    793:                        break;
                    794: 
1.10      paf       795:                // VARIABLE GET/PUT/WITH
1.1       paf       796:                case LS_VAR_NAME_SIMPLE:
1.69      paf       797:                case LS_EXPRESSION_VAR_NAME:
                    798:                        if(PC->ls==LS_EXPRESSION_VAR_NAME) {
1.56      paf       799:                                // name in expr ends also before binary operators 
1.48      paf       800:                                switch(c) {
1.92      paf       801:                                case '-': 
1.48      paf       802:                                        pop_LS(PC);
                    803:                                        PC->source--;  if(--PC->col<0) { PC->line--;  PC->col=-1; }
                    804:                                        result=EON;
                    805:                                        goto break2;
                    806:                                }
                    807:                        }
                    808:                        switch(c) {
                    809:                        case 0:
                    810:                        case ' ': case '\t': case '\n':
                    811:                        case ';':
1.64      paf       812:                        case ']': case '}': case ')': case '"':
1.83      paf       813:                        case '<': case '>':  // these stand for HTML brackets and expression binary ops
1.92      paf       814:                        case '+': case '*': case '/': case '%': 
                    815:                        case '&': case '|': 
                    816:                        case '=': case '!':
1.99      paf       817:                        // common delimiters
1.101     paf       818:                        case '\'': case ',':
1.1       paf       819:                                pop_LS(PC);
1.32      paf       820:                                PC->source--;  if(--PC->col<0) { PC->line--;  PC->col=-1; }
1.13      paf       821:                                result=EON;
1.1       paf       822:                                goto break2;
1.48      paf       823:                        case '[':
                    824:                                PC->ls=LS_VAR_SQUARE;
1.1       paf       825:                                lexical_brackets_nestage=1;
1.48      paf       826:                                RC;
                    827:                        case '{':
                    828:                                if(begin==end) { // ${name}, no need of EON, switching LS
                    829:                                        PC->ls=LS_VAR_NAME_CURLY; 
                    830:                                } else {
                    831:                                        PC->ls=LS_VAR_CURLY;
                    832:                                        lexical_brackets_nestage=1;
                    833:                                }
1.69      paf       834: 
1.48      paf       835:                                RC;
                    836:                        case '(':
1.69      paf       837:                                PC->ls=LS_VAR_ROUND;
1.1       paf       838:                                lexical_brackets_nestage=1;
1.48      paf       839:                                RC;
                    840:                        case '.': // name part delim
                    841:                        case '$': // name part subvar
                    842:                        case ':': // ':name' or 'class:name'
                    843:                                RC;
1.1       paf       844:                        }
                    845:                        break;
1.48      paf       846: 
1.1       paf       847:                case LS_VAR_NAME_CURLY:
1.48      paf       848:                        switch(c) {
                    849:                        case '}': // ${name} finished, restoring LS
1.1       paf       850:                                pop_LS(PC);
1.48      paf       851:                                RC;
                    852:                        case '.': // name part delim
                    853:                        case '$': // name part subvar
                    854:                        case ':': // ':name' or 'class:name'
                    855:                                RC;
1.1       paf       856:                        }
                    857:                        break;
1.48      paf       858: 
                    859:                case LS_VAR_SQUARE:
                    860:                        switch(c) {
                    861:                        case '$':
1.10      paf       862:                                push_LS(PC, LS_VAR_NAME_SIMPLE);
1.48      paf       863:                                RC;
                    864:                        case '^':
1.10      paf       865:                                push_LS(PC, LS_METHOD_NAME);
1.48      paf       866:                                RC;
                    867:                        case ']':
1.1       paf       868:                                if(--lexical_brackets_nestage==0) {
                    869:                                        pop_LS(PC);
1.48      paf       870:                                        RC;
1.1       paf       871:                                }
1.48      paf       872:                                break;
                    873:                        case ';': // operator_or_fmt;value delim
                    874:                                RC;
                    875:                        case '[':
                    876:                                lexical_brackets_nestage++;
                    877:                                break;
1.1       paf       878:                        }
                    879:                        break;
1.48      paf       880: 
1.1       paf       881:                case LS_VAR_CURLY:
1.48      paf       882:                        switch(c) {
                    883:                        case '$':
1.10      paf       884:                                push_LS(PC, LS_VAR_NAME_SIMPLE);
1.48      paf       885:                                RC;
                    886:                        case '^':
1.10      paf       887:                                push_LS(PC, LS_METHOD_NAME);
1.48      paf       888:                                RC;
                    889:                        case '}':
1.1       paf       890:                                if(--lexical_brackets_nestage==0) {
                    891:                                        pop_LS(PC);
1.48      paf       892:                                        RC;
1.1       paf       893:                                }
1.48      paf       894:                                break;
                    895:                        case '{':
1.1       paf       896:                                lexical_brackets_nestage++;
1.48      paf       897:                                break;
                    898:                        }
1.1       paf       899:                        break;
                    900: 
1.10      paf       901:                // METHOD CALL
1.1       paf       902:                case LS_METHOD_NAME:
1.48      paf       903:                        switch(c) {
                    904:                        case '[':
                    905:                                PC->ls=LS_METHOD_SQUARE;
1.1       paf       906:                                lexical_brackets_nestage=1;
1.48      paf       907:                                RC;
                    908:                        case '{':
1.1       paf       909:                                PC->ls=LS_METHOD_CURLY;
                    910:                                lexical_brackets_nestage=1;
1.48      paf       911:                                RC;
1.69      paf       912:                        case '(':
                    913:                                PC->ls=LS_METHOD_ROUND;
                    914:                                lexical_brackets_nestage=1;
                    915:                                RC;
1.48      paf       916:                        case '.': // name part delim 
                    917:                        case '$': // name part subvar
                    918:                        case ':': // ':name' or 'class:name'
                    919:                                RC;
1.1       paf       920:                        }
                    921:                        break;
1.48      paf       922: 
                    923:                case LS_METHOD_SQUARE:
                    924:                        switch(c) {
                    925:                        case '$':
1.10      paf       926:                                push_LS(PC, LS_VAR_NAME_SIMPLE);
1.48      paf       927:                                RC;
                    928:                        case '^':
1.10      paf       929:                                push_LS(PC, LS_METHOD_NAME);
1.48      paf       930:                                RC;
                    931:                        case ';': // param delim
                    932:                                RC;
                    933:                        case ']':
1.1       paf       934:                                if(--lexical_brackets_nestage==0) {
                    935:                                        PC->ls=LS_METHOD_AFTER;
1.48      paf       936:                                        RC;
1.1       paf       937:                                }
1.48      paf       938:                                break;
                    939:                        case '[':
1.1       paf       940:                                lexical_brackets_nestage++;
1.48      paf       941:                                break;
                    942:                        }
1.1       paf       943:                        break;
1.48      paf       944: 
1.1       paf       945:                case LS_METHOD_CURLY:
1.48      paf       946:                        switch(c) {
                    947:                        case '$':
1.10      paf       948:                                push_LS(PC, LS_VAR_NAME_SIMPLE);
1.48      paf       949:                                RC;
                    950:                        case '^':
1.10      paf       951:                                push_LS(PC, LS_METHOD_NAME);
1.94      paf       952:                                RC;
                    953:                        case ';': // param delim
1.48      paf       954:                                RC;
                    955:                        case '}':
1.1       paf       956:                                if(--lexical_brackets_nestage==0) {
                    957:                                        PC->ls=LS_METHOD_AFTER;
1.48      paf       958:                                        RC;
1.1       paf       959:                                }
1.48      paf       960:                                break;
                    961:                        case '{':
1.1       paf       962:                                lexical_brackets_nestage++;
1.48      paf       963:                                break;
                    964:                        }
1.1       paf       965:                        break;
1.48      paf       966: 
1.1       paf       967:                case LS_METHOD_AFTER:
1.69      paf       968:                        if(c=='[') {/* ][ }[ )[ */
1.48      paf       969:                                PC->ls=LS_METHOD_SQUARE;
1.1       paf       970:                                lexical_brackets_nestage=1;
1.48      paf       971:                                RC;
1.1       paf       972:                        }                                          
1.69      paf       973:                        if(c=='{') {/* ]{ }{ ){ */
1.1       paf       974:                                PC->ls=LS_METHOD_CURLY;
1.69      paf       975:                                lexical_brackets_nestage=1;
                    976:                                RC;
                    977:                        }                                          
                    978:                        if(c=='(') {/* ]( }( )( */
                    979:                                PC->ls=LS_METHOD_ROUND;
1.1       paf       980:                                lexical_brackets_nestage=1;
1.48      paf       981:                                RC;
1.1       paf       982:                        }                                          
                    983:                        pop_LS(PC);
1.32      paf       984:                        PC->source--;  if(--PC->col<0) { PC->line--;  PC->col=-1; }
1.13      paf       985:                        result=EON;
1.1       paf       986:                        goto break2;
                    987:                }
1.9       paf       988:                if(c==0) {
1.1       paf       989:                        result=-1;
                    990:                        break;
                    991:                }
                    992:        }
                    993: 
                    994: break2:
1.59      paf       995:        if(end!=begin) { // there is last piece?
                    996:                if((c=='@' || c==0) && end[-1]=='\n') { // we are before LS_DEF_NAME or EOF?
                    997:                        // strip last \n
1.10      paf       998:                        end--;
1.59      paf       999:                }
                   1000:                if(end!=begin) { // last piece still alive?
                   1001:                        // append it
1.30      paf      1002:                        PC->string->APPEND(begin, end-begin, PC->file, begin_line/*, start_col*/);
                   1003:                }
1.59      paf      1004:        }
                   1005:        if(PC->string->size()) { // something accumulated?
1.17      paf      1006:                // create STRING value: array of OP_VALUE+vstring
1.55      paf      1007:                *lvalp=VL(NEW VString(*PC->string));
1.10      paf      1008:                // new pieces storage
1.25      paf      1009:                PC->string=NEW String(POOL);
1.58      paf      1010:                // make current result be pending for next call, return STRING for now
                   1011:                PC->pending_state=result;  result=STRING;
                   1012:        }
1.67      paf      1013:        if(skip_analized) {
                   1014:                PC->source+=skip_analized;  PC->col+=skip_analized;
1.1       paf      1015:        }
1.58      paf      1016:        return result;
1.1       paf      1017: }
                   1018: 
1.110     paf      1019: static int real_yyerror(parse_control *pc, char *s) {  // Called by yyparse on error
                   1020:           strncpy(pc->error, s, MAX_STRING);
1.1       paf      1021:           return 1;
1.110     paf      1022: }
1.1       paf      1023: 
1.110     paf      1024: static void yyprint(FILE *file, int type, YYSTYPE value) {
                   1025:        if(type==STRING)
                   1026:                fprintf(file, " \"%s\"", SLA2S(value)->cstr());
                   1027: }

E-mail: