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

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

E-mail: