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

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

E-mail: