--- parser3/src/main/compile.tab.C 2005/12/21 13:54:43 1.112 +++ parser3/src/main/compile.tab.C 2009/04/29 07:12:55 1.128 @@ -1,7 +1,7 @@ -/* A Bison parser, made by GNU Bison 1.875b. */ +/* A Bison parser, made by GNU Bison 1.875d. */ /* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ #define YYBISON 1 /* Skeleton name. */ -#define YYSKELETON_NAME "/../../../cygdrive/y/parser3project/win32/tools/yacc.c" +#define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 @@ -132,7 +132,7 @@ Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: compile.tab.C,v 1.112 2005/12/21 13:54:43 paf Exp $ + $Id: compile.tab.C,v 1.128 2009/04/29 07:12:55 misha Exp $ */ /** @@ -168,6 +168,9 @@ // defines #define USE_CONTROL_METHOD_NAME "USE" +#define OPTIONS_CONTROL_METHOD_NAME "OPTIONS" +#define OPTION_ALL_VARS_LOCAL_NAME "locals" +#define OPTION_PARTIAL_CLASS "partial" // forwards @@ -213,22 +216,29 @@ typedef int YYSTYPE; /* Line 214 of yacc.c. */ -#line 217 "compile.tab.C" +#line 220 "compile.tab.C" #if ! defined (yyoverflow) || YYERROR_VERBOSE +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + /* The parser invokes alloca or malloc; define the necessary symbols. */ -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif # else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca # endif # endif # endif @@ -241,20 +251,20 @@ typedef int YYSTYPE; # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE # endif #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ #if (! defined (yyoverflow) \ && (! defined (__cplusplus) \ - || (YYSTYPE_IS_TRIVIAL))) + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short yyss; + short int yyss; YYSTYPE yyvs; }; @@ -264,13 +274,13 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if 1 < __GNUC__ +# if defined (__GNUC__) && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else @@ -306,7 +316,7 @@ union yyalloc #if defined (__STDC__) || defined (__cplusplus) typedef signed char yysigned_char; #else - typedef short yysigned_char; + typedef short int yysigned_char; #endif /* YYFINAL -- State number of the termination state. */ @@ -367,7 +377,7 @@ static const unsigned char yytranslate[] #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const unsigned short yyprhs[] = +static const unsigned short int yyprhs[] = { 0, 0, 3, 5, 7, 9, 12, 14, 16, 18, 23, 25, 27, 29, 32, 35, 37, 39, 40, 49, @@ -390,7 +400,7 @@ static const unsigned short yyprhs[] = }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short yyrhs[] = +static const short int yyrhs[] = { 63, 0, -1, 65, -1, 64, -1, 66, -1, 64, 66, -1, 79, -1, 67, -1, 72, -1, 47, 4, @@ -443,26 +453,26 @@ static const short yyrhs[] = }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short yyrline[] = +static const unsigned short int yyrline[] = { - 0, 128, 128, 135, 137, 137, 138, 140, 140, 142, - 214, 214, 215, 215, 216, 217, 217, 219, 219, 259, - 259, 260, 261, 261, 262, 262, 264, 264, 268, 268, - 270, 270, 271, 271, 272, 272, 272, 276, 283, 284, - 284, 285, 287, 288, 289, 311, 312, 312, 316, 321, - 322, 323, 324, 341, 346, 349, 350, 351, 353, 356, - 353, 364, 372, 379, 380, 381, 383, 389, 390, 390, - 394, 400, 403, 400, 419, 421, 421, 423, 424, 425, - 427, 430, 427, 433, 434, 436, 437, 440, 441, 444, - 445, 447, 451, 466, 471, 472, 473, 478, 478, 480, - 480, 481, 482, 490, 495, 498, 499, 500, 501, 503, - 507, 516, 519, 516, 527, 532, 532, 533, 539, 540, - 542, 554, 566, 568, 569, 570, 571, 572, 573, 574, - 575, 577, 578, 579, 580, 581, 582, 583, 584, 586, - 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, - 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, - 607, 608, 609, 610, 611, 612, 615, 620, 629, 634, - 635, 636, 638 + 0, 131, 131, 138, 140, 140, 141, 143, 143, 145, + 246, 246, 247, 247, 248, 249, 249, 251, 251, 301, + 301, 302, 303, 303, 304, 304, 306, 306, 310, 310, + 312, 312, 313, 313, 314, 314, 314, 318, 328, 329, + 329, 330, 332, 333, 334, 370, 371, 371, 375, 380, + 381, 382, 383, 400, 405, 408, 409, 410, 412, 415, + 412, 423, 431, 438, 439, 440, 442, 448, 449, 449, + 453, 459, 462, 459, 478, 480, 480, 482, 483, 484, + 486, 489, 486, 492, 493, 495, 496, 499, 500, 503, + 504, 506, 509, 523, 528, 529, 530, 535, 535, 537, + 537, 538, 539, 547, 552, 555, 556, 557, 558, 560, + 564, 573, 576, 573, 584, 589, 589, 590, 596, 597, + 599, 616, 628, 630, 631, 632, 633, 634, 635, 636, + 637, 639, 640, 641, 642, 643, 644, 645, 646, 648, + 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, + 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, + 669, 670, 671, 672, 673, 674, 677, 682, 691, 696, + 697, 698, 700 }; #endif @@ -471,40 +481,40 @@ static const unsigned short yyrline[] = First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "$end", "error", "$undefined", "EON", "STRING", "BOGUS", - "BAD_STRING_COMPARISON_OPERATOR", "BAD_HEX_LITERAL", - "BAD_METHOD_DECL_START", "BAD_METHOD_PARAMETER_NAME_CHARACTER", - "BAD_NONWHITESPACE_CHARACTER_IN_EXPLICIT_RESULT_MODE", "\"&&\"", - "\"||\"", "\"!||\"", "\"!|\"", "\"<=\"", "\">=\"", "\"==\"", "\"!=\"", - "\"<<\"", "\">>\"", "\"lt\"", "\"gt\"", "\"le\"", "\"ge\"", "\"eq\"", - "\"ne\"", "\"def\"", "\"in\"", "\"-f\"", "\"-d\"", "\"is\"", "\"true\"", - "\"false\"", "'<'", "'>'", "'|'", "'&'", "'+'", "'-'", "'*'", "'/'", - "'\\\\'", "'%'", "NUNARY", "'~'", "'!'", "'@'", "'\\n'", "'['", "']'", - "';'", "'$'", "'{'", "'}'", "'.'", "'('", "')'", "'^'", "':'", "'\"'", - "'''", "$accept", "all", "methods", "one_big_piece", "method", - "control_method", "maybe_control_strings", "control_strings", - "control_string", "maybe_string", "code_method", "@1", - "maybe_bracketed_strings", "bracketed_maybe_strings", "maybe_strings", - "strings", "maybe_comment", "maybe_codes", "codes", "code", "action", - "get", "get_value", "get_name_value", "name_in_curly_rdive", - "name_without_curly_rdive", "name_without_curly_rdive_read", - "name_without_curly_rdive_class", "name_without_curly_rdive_code", - "put", "name_expr_wdive", "name_expr_wdive_root", - "name_expr_wdive_write", "name_expr_wdive_class", "construct", - "construct_square", "@2", "@3", "construct_round", "construct_curly", - "any_constructor_code_value", "constructor_code_value", - "constructor_code", "codes__excluding_sole_str_literal", "call", - "call_value", "@4", "@5", "call_name", "store_params", "store_param", - "store_square_param", "@6", "@7", "store_round_param", - "store_curly_param", "store_code_param_parts", "store_expr_param_parts", - "store_curly_param_parts", "store_code_param_part", - "store_expr_param_part", "store_curly_param_part", "code_param_value", - "name_expr_dive_code", "name_path", "name_step", "name_advance1", - "name_advance2", "name_expr_value", "name_expr_subvar_value", - "name_expr_with_subvar_value", "name_square_code_value", "@8", "@9", - "subvar_ref_name_rdive", "subvar_get_writes", "subvar__get_write", - "class_prefix", "class_static_prefix", "class_constructor_prefix", - "expr_value", "expr", "double_or_STRING", "string_inside_quotes_value", + "$end", "error", "$undefined", "EON", "STRING", "BOGUS", + "BAD_STRING_COMPARISON_OPERATOR", "BAD_HEX_LITERAL", + "BAD_METHOD_DECL_START", "BAD_METHOD_PARAMETER_NAME_CHARACTER", + "BAD_NONWHITESPACE_CHARACTER_IN_EXPLICIT_RESULT_MODE", "\"&&\"", + "\"||\"", "\"!||\"", "\"!|\"", "\"<=\"", "\">=\"", "\"==\"", "\"!=\"", + "\"<<\"", "\">>\"", "\"lt\"", "\"gt\"", "\"le\"", "\"ge\"", "\"eq\"", + "\"ne\"", "\"def\"", "\"in\"", "\"-f\"", "\"-d\"", "\"is\"", "\"true\"", + "\"false\"", "'<'", "'>'", "'|'", "'&'", "'+'", "'-'", "'*'", "'/'", + "'\\\\'", "'%'", "NUNARY", "'~'", "'!'", "'@'", "'\\n'", "'['", "']'", + "';'", "'$'", "'{'", "'}'", "'.'", "'('", "')'", "'^'", "':'", "'\"'", + "'''", "$accept", "all", "methods", "one_big_piece", "method", + "control_method", "maybe_control_strings", "control_strings", + "control_string", "maybe_string", "code_method", "@1", + "maybe_bracketed_strings", "bracketed_maybe_strings", "maybe_strings", + "strings", "maybe_comment", "maybe_codes", "codes", "code", "action", + "get", "get_value", "get_name_value", "name_in_curly_rdive", + "name_without_curly_rdive", "name_without_curly_rdive_read", + "name_without_curly_rdive_class", "name_without_curly_rdive_code", "put", + "name_expr_wdive", "name_expr_wdive_root", "name_expr_wdive_write", + "name_expr_wdive_class", "construct", "construct_square", "@2", "@3", + "construct_round", "construct_curly", "any_constructor_code_value", + "constructor_code_value", "constructor_code", + "codes__excluding_sole_str_literal", "call", "call_value", "@4", "@5", + "call_name", "store_params", "store_param", "store_square_param", "@6", + "@7", "store_round_param", "store_curly_param", "store_code_param_parts", + "store_expr_param_parts", "store_curly_param_parts", + "store_code_param_part", "store_expr_param_part", + "store_curly_param_part", "code_param_value", "name_expr_dive_code", + "name_path", "name_step", "name_advance1", "name_advance2", + "name_expr_value", "name_expr_subvar_value", + "name_expr_with_subvar_value", "name_square_code_value", "@8", "@9", + "subvar_ref_name_rdive", "subvar_get_writes", "subvar__get_write", + "class_prefix", "class_static_prefix", "class_constructor_prefix", + "expr_value", "expr", "double_or_STRING", "string_inside_quotes_value", "write_string", "void_value", "true_value", "false_value", "empty", 0 }; #endif @@ -512,7 +522,7 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const unsigned short yytoknum[] = +static const unsigned short int yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -605,7 +615,7 @@ static const unsigned char yydefact[] = }; /* YYDEFGOTO[NTERM-NUM]. */ -static const short yydefgoto[] = +static const short int yydefgoto[] = { -1, 5, 6, 7, 8, 9, 92, 93, 94, 95, 10, 244, 101, 56, 98, 99, 140, 161, 12, 13, @@ -621,7 +631,7 @@ static const short yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -107 -static const short yypact[] = +static const short int yypact[] = { 14, -107, 13, 45, -107, 28, -15, -107, -107, -107, -107, -107, 21, -107, -107, -107, -107, -107, -107, -107, @@ -653,7 +663,7 @@ static const short yypact[] = }; /* YYPGOTO[NTERM-NUM]. */ -static const short yypgoto[] = +static const short int yypgoto[] = { -107, -107, -107, -107, 206, -107, -107, -107, 124, -107, -107, -107, -107, 170, -107, -107, -107, 1, -58, -7, @@ -671,7 +681,7 @@ static const short yypgoto[] = number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -173 -static const short yytable[] = +static const short int yytable[] = { 16, 11, 19, 145, 106, 53, 43, 39, -103, 70, 23, 111, 16, 91, 19, 74, 83, 22, 1, 75, @@ -723,7 +733,7 @@ static const short yytable[] = 191 }; -static const short yycheck[] = +static const short int yycheck[] = { 0, 0, 0, 109, 62, 12, 3, 3, 3, 27, 4, 4, 12, 4, 12, 49, 39, 4, 4, 53, @@ -831,7 +841,7 @@ static const unsigned char yystos[] = #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 +#define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily @@ -866,11 +876,11 @@ while (0) are run). */ #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.first_line = Rhs[1].first_line; \ - Current.first_column = Rhs[1].first_column; \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) #endif /* YYLEX -- calling `yylex' with the right arguments. */ @@ -914,17 +924,17 @@ do { \ /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (cinluded). | +| TOP (included). | `------------------------------------------------------------------*/ #if defined (__STDC__) || defined (__cplusplus) static void -yy_stack_print (short *bottom, short *top) +yy_stack_print (short int *bottom, short int *top) #else static void yy_stack_print (bottom, top) - short *bottom; - short *top; + short int *bottom; + short int *top; #endif { YYFPRINTF (stderr, "Stack now"); @@ -993,7 +1003,7 @@ int yydebug; SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if YYMAXDEPTH == 0 +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 # undef YYMAXDEPTH #endif @@ -1191,9 +1201,9 @@ int yynerrs; to reallocate them elsewhere. */ /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; @@ -1230,6 +1240,7 @@ int yynerrs; yyssp = yyss; yyvsp = yyvs; + goto yysetstate; /*------------------------------------------------------------. @@ -1255,7 +1266,7 @@ int yynerrs; these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; + short int *yyss1 = yyss; /* Each stack pointer address is followed by the size of the @@ -1283,7 +1294,7 @@ int yynerrs; yystacksize = YYMAXDEPTH; { - short *yyss1 = yyss; + short int *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) @@ -1416,7 +1427,7 @@ yyreduce: switch (yyn) { case 2: -#line 128 "compile.y" +#line 131 "compile.y" { Method& method=*new Method(Method::CT_ANY, 0, 0, /*min, max numbered_params_count*/ @@ -1427,7 +1438,7 @@ yyreduce: break; case 9: -#line 143 "compile.y" +#line 146 "compile.y" { const String& command=*LA2S(*yyvsp[-2]); YYSTYPE strings_code=yyvsp[0]; @@ -1438,21 +1449,13 @@ yyreduce: YYERROR; } if(command==CLASS_NAME) { - if(PC.cclass->base_class()) { // already changed from default? - strcpy(PC.error, "class already have a name '"); - strncat(PC.error, PC.cclass->name().cstr(), 100); - strcat(PC.error, "'"); - YYERROR; - } if(strings_code->count()==1*OPERATIONS_PER_OPVALUE) { // new class' name const String& name=*LA2S(*strings_code); // creating the class VStateless_class* cclass=new VClass; - PC.cclass=cclass; - PC.cclass->set_name(name); - // append to request's classes - PC.request.classes().put(name, cclass); + PC.cclass_new=cclass; + PC.cclass_new->set_name(name); } else { strcpy(PC.error, "@"CLASS_NAME" must contain only one line with class name (contains more then one)"); YYERROR; @@ -1461,9 +1464,16 @@ yyreduce: for(size_t i=0; icount(); i+=OPERATIONS_PER_OPVALUE) PC.request.use_file(PC.request.main_class, *LA2S(*strings_code, i)); } else if(command==BASE_NAME) { + if(PC.append){ + strcpy(PC.error, "can't set base while appending methods to class '"); + strncat(PC.error, PC.cclass->name().cstr(), MAX_STRING/2); + strcat(PC.error, "'"); + YYERROR; + } + PC.class_add(); if(PC.cclass->base_class()) { // already changed from default? strcpy(PC.error, "class already have a base '"); - strncat(PC.error, PC.cclass->base_class()->name().cstr(), 100); + strncat(PC.error, PC.cclass->base_class()->name().cstr(), MAX_STRING/2); strcat(PC.error, "'"); YYERROR; } @@ -1491,26 +1501,56 @@ yyreduce: strcpy(PC.error, "@"BASE_NAME" must contain sole name"); YYERROR; } + } else if(command==OPTIONS_CONTROL_METHOD_NAME) { + for(size_t i=0; icount(); i+=OPERATIONS_PER_OPVALUE) { + const String& option=*LA2S(*strings_code, i); + if(option==OPTION_ALL_VARS_LOCAL_NAME){ + PC.set_all_vars_local(); + } else if(option==OPTION_PARTIAL_CLASS){ + if(PC.cclass_new){ + if(VStateless_class* existed=PC.get_existed_class(PC.cclass_new)){ + if(!PC.reuse_existed_class(existed)){ + strcpy(PC.error, "can't append methods to '"); + strncat(PC.error, PC.cclass_new->name().cstr(), MAX_STRING/2); + strcat(PC.error, "' - the class wasn't marked as partial"); + YYERROR; + } + } else { + // mark new class as partial. we can add methods to it later. + PC.cclass_new->set_partial(); + } + } else { + strcpy(PC.error, "'"OPTION_PARTIAL_CLASS"' option should be used straight after @"CLASS_NAME); + YYERROR; + } + } else { + strcpy(PC.error, "'"); + strncat(PC.error, option.cstr(), MAX_STRING/2); + strcat(PC.error, "' invalid option. valid options are " + "'"OPTION_PARTIAL_CLASS"' and '"OPTION_ALL_VARS_LOCAL_NAME"'"); + YYERROR; + } + } } else { strcpy(PC.error, "'"); strncat(PC.error, command.cstr(), MAX_STRING/2); strcat(PC.error, "' invalid special name. valid names are " - "'"CLASS_NAME"', '"USE_CONTROL_METHOD_NAME"' and '"BASE_NAME"'"); + "'"CLASS_NAME"', '"USE_CONTROL_METHOD_NAME"', '"BASE_NAME"' and '"OPTIONS_CONTROL_METHOD_NAME"'."); YYERROR; } ;} break; case 13: -#line 215 "compile.y" +#line 247 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 17: -#line 219 "compile.y" +#line 251 "compile.y" { + PC.class_add(); PC.explicit_result=false; - const String& name=*LA2S(*yyvsp[-4]); YYSTYPE params_names_code=yyvsp[-3]; ArrayString* params_names=0; @@ -1522,24 +1562,29 @@ yyreduce: YYSTYPE locals_names_code=yyvsp[-2]; ArrayString* locals_names=0; + bool all_vars_local=false; if(int size=locals_names_code->count()) { locals_names=new ArrayString; for(int i=0; iis_vars_local()) + all_vars_local=true; Method* method=new Method( //name, Method::CT_ANY, 0, 0/*min,max numbered_params_count*/, params_names, locals_names, - 0/*to be filled later in next {} */, 0); - PC.cclass->add_method(PC.alias_method(name), *method); + 0/*to be filled later in next {} */, 0, all_vars_local); + *reinterpret_cast(&yyval)=method; // todo: check [][;result;] @@ -1547,51 +1592,59 @@ yyreduce: break; case 18: -#line 254 "compile.y" +#line 291 "compile.y" { - // fill in the code - reinterpret_cast(yyvsp[-1])->parser_code=yyvsp[0]; + Method& method=*reinterpret_cast(yyvsp[-1]); + // fill in the code + method.parser_code=yyvsp[0]; + + // register in class + const String& name=*LA2S(*yyvsp[-6]); + PC.cclass->add_method(PC.alias_method(name), method); ;} break; case 21: -#line 260 "compile.y" +#line 302 "compile.y" {yyval=yyvsp[-1];} break; case 25: -#line 262 "compile.y" +#line 304 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 31: -#line 270 "compile.y" +#line 312 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 37: -#line 276 "compile.y" +#line 318 "compile.y" { yyval=yyvsp[0]; /* stack: resulting value */ - changetail_or_append(*yyval, - OP_GET_ELEMENT, false, /*->*/OP_GET_ELEMENT__WRITE, - /*or */OP_WRITE_VALUE - ); /* value=pop; wcontext.write(value) */ +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT + if(!replace_top_opcode(*yyval, OP::OP_VALUE__GET_ELEMENT, OP::OP_VALUE__GET_ELEMENT__WRITE)) +#endif + changetail_or_append(*yyval, + OP::OP_GET_ELEMENT, false, /*->*/OP::OP_GET_ELEMENT__WRITE, + /*or */OP::OP_WRITE_VALUE + ); /* value=pop; wcontext.write(value) */ ;} break; case 38: -#line 283 "compile.y" +#line 328 "compile.y" { yyval=yyvsp[0] ;} break; case 41: -#line 285 "compile.y" +#line 330 "compile.y" { yyval=yyvsp[-1] ;} break; case 44: -#line 289 "compile.y" +#line 334 "compile.y" { yyval=N(); ArrayOperation* diving_code=yyvsp[0]; @@ -1599,35 +1652,49 @@ yyreduce: // self.xxx... -> xxx... // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... if(first_name && *first_name==SELF_ELEMENT_NAME) { - O(*yyval, OP_WITH_SELF); /* stack: starting context */ + O(*yyval, OP::OP_WITH_SELF); /* stack: starting context */ P(*yyval, *diving_code, /* skip over... */ - diving_code->count()>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP_+origin+string*/); + diving_code->count()>=4?4/*OP::OP_VALUE+origin+string+OP::OP_GET_ELEMENTx*/:3/*OP::OP_+origin+string*/); } else { - O(*yyval, OP_WITH_READ); /* stack: starting context */ +#ifdef OPTIMIZE_BYTECODE_GET_ELEMENT + if(diving_code->count()==4){ // optimisations for simple (but very popular) cases + O(*yyval, + (PC.in_call_value) // ^call + ? OP::OP_VALUE__GET_ELEMENT_OR_OPERATOR // OP_VALUE+origin+string+OP_GET_ELEMENT -> OP_VALUE__GET_ELEMENT_OR_OPERATOR+origin+string + : OP::OP_VALUE__GET_ELEMENT // OP_VALUE+origin+string+OP_GET_ELEMENT -> OP_VALUE__GET_ELEMENT+origin+string + ); + P(*yyval, *diving_code, 1/*offset==1: skip leading OP_VALUE*/, 2/*limit==2: skip trailing OP_GET_ELEMENT*/); + } else { + O(*yyval, OP::OP_WITH_READ); /* stack: starting context */ + P(*yyval, *diving_code); + } +#else + O(*yyval, OP::OP_WITH_READ); /* stack: starting context */ // ^if ELEMENT -> ^if ELEMENT_OR_OPERATOR // OP_VALUE+origin+string+OP_GET_ELEMENT. -> OP_VALUE+origin+string+OP_GET_ELEMENT_OR_OPERATOR. if(PC.in_call_value && diving_code->count()==4) - diving_code->put(4-1, OP_GET_ELEMENT_OR_OPERATOR); + diving_code->put(4-1, OP::OP_GET_ELEMENT_OR_OPERATOR); P(*yyval, *diving_code); +#endif } /* diving code; stack: current context */ ;} break; case 45: -#line 311 "compile.y" +#line 370 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 47: -#line 312 "compile.y" +#line 371 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 48: -#line 316 "compile.y" +#line 375 "compile.y" { yyval=yyvsp[-1]; /* stack: context,name */ P(*yyval, *yyvsp[0]); /* stack: context,name,constructor_value */ @@ -1635,7 +1702,7 @@ yyreduce: break; case 52: -#line 324 "compile.y" +#line 383 "compile.y" { yyval=N(); ArrayOperation* diving_code=yyvsp[0]; @@ -1643,12 +1710,12 @@ yyreduce: // $self.xxx... -> $xxx... // OP_VALUE+origin+string+OP_GET_ELEMENT+... -> OP_WITH_SELF+... if(first_name && *first_name==SELF_ELEMENT_NAME) { - O(*yyval, OP_WITH_SELF); /* stack: starting context */ + O(*yyval, OP::OP_WITH_SELF); /* stack: starting context */ P(*yyval, *diving_code, /* skip over... */ - diving_code->count()>=4?4/*OP_VALUE+origin+string+OP_GET_ELEMENTx*/:3/*OP_+origin+string*/); + diving_code->count()>=4?4/*OP::OP_VALUE+origin+string+OP::OP_GET_ELEMENTx*/:3/*OP::OP_+origin+string*/); } else { - O(*yyval, OP_WITH_ROOT); /* stack: starting context */ + O(*yyval, OP::OP_WITH_ROOT); /* stack: starting context */ P(*yyval, *diving_code); } /* diving code; stack: current context */ @@ -1656,21 +1723,21 @@ yyreduce: break; case 53: -#line 341 "compile.y" +#line 400 "compile.y" { yyval=N(); - O(*yyval, OP_WITH_WRITE); /* stack: starting context */ + O(*yyval, OP::OP_WITH_WRITE); /* stack: starting context */ P(*yyval, *yyvsp[0]); /* diving code; stack: context,name */ ;} break; case 54: -#line 346 "compile.y" +#line 405 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 58: -#line 353 "compile.y" +#line 412 "compile.y" { // allow $result_or_other_variable[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1678,103 +1745,103 @@ yyreduce: break; case 59: -#line 356 "compile.y" +#line 415 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 60: -#line 358 "compile.y" +#line 417 "compile.y" { // stack: context, name yyval=yyvsp[-2]; // stack: context, name, value - O(*yyval, OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */ + O(*yyval, OP::OP_CONSTRUCT_VALUE); /* value=pop; name=pop; context=pop; construct(context,name,value) */ ;} break; case 61: -#line 364 "compile.y" +#line 423 "compile.y" { yyval=N(); - O(*yyval, OP_PREPARE_TO_EXPRESSION); + O(*yyval, OP::OP_PREPARE_TO_EXPRESSION); // stack: context, name P(*yyval, *yyvsp[-1]); // stack: context, name, value - O(*yyval, OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ + O(*yyval, OP::OP_CONSTRUCT_EXPR); /* value=pop->as_expr_result; name=pop; context=pop; construct(context,name,value) */ ;} break; case 62: -#line 372 "compile.y" +#line 431 "compile.y" { // stack: context, name yyval=N(); - OA(*yyval, OP_CURLY_CODE__CONSTRUCT, yyvsp[-1]); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */ + OA(*yyval, OP::OP_CURLY_CODE__CONSTRUCT, yyvsp[-1]); /* code=pop; name=pop; context=pop; construct(context,name,junction(code)) */ ;} break; case 66: -#line 383 "compile.y" +#line 442 "compile.y" { yyval=N(); - OA(*yyval, OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ + OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[0]); /* stack: empty write context */ /* some code that writes to that context */ /* context=pop; stack: context.value() */ ;} break; case 69: -#line 390 "compile.y" +#line 449 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 70: -#line 394 "compile.y" +#line 453 "compile.y" { yyval=yyvsp[0]; /* stack: value */ changetail_or_append(*yyval, - OP_CALL, true, /*->*/ OP_CALL__WRITE, - /*or */OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ + OP::OP_CALL, true, /*->*/ OP::OP_CALL__WRITE, + /*or */OP::OP_WRITE_VALUE); /* value=pop; wcontext.write(value) */ ;} break; case 71: -#line 400 "compile.y" +#line 459 "compile.y" { PC.in_call_value=true; ;} break; case 72: -#line 403 "compile.y" +#line 462 "compile.y" { PC.in_call_value=false; ;} break; case 73: -#line 406 "compile.y" +#line 465 "compile.y" { /* ^field.$method{vasya} */ yyval=yyvsp[-3]; /* with_xxx,diving code; stack: context,method_junction */ YYSTYPE params_code=yyvsp[-1]; - if(params_code->count()==4) { // probably [] case. [OP_VALUE+origin+Void+STORE_PARAM] + if(params_code->count()==3) { // probably [] case. [OP::OP_VALUE+origin+Void] if(Value* value=LA2V(*params_code)) // it is OP_VALUE+origin+value? if(value->is_void()) // value is VVoid? params_code=0; // ^zzz[] case. don't append lone empty param. } /* stack: context, method_junction */ - OA(*yyval, OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value + OA(*yyval, OP::OP_CALL, params_code); // method_frame=make frame(pop junction); ncontext=pop; call(ncontext,method_frame) stack: value ;} break; case 76: -#line 421 "compile.y" +#line 480 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 80: -#line 427 "compile.y" +#line 486 "compile.y" { // allow ^call[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1782,118 +1849,116 @@ yyreduce: break; case 81: -#line 430 "compile.y" +#line 489 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 82: -#line 432 "compile.y" +#line 491 "compile.y" {yyval=yyvsp[-2];} break; case 83: -#line 433 "compile.y" +#line 492 "compile.y" {yyval=yyvsp[-1];} break; case 84: -#line 434 "compile.y" +#line 493 "compile.y" {yyval=yyvsp[-1];} break; case 86: -#line 437 "compile.y" +#line 496 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 88: -#line 441 "compile.y" +#line 500 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 90: -#line 445 "compile.y" +#line 504 "compile.y" { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]) ;} break; case 91: -#line 447 "compile.y" +#line 506 "compile.y" { yyval=yyvsp[0]; - O(*yyval, OP_STORE_PARAM); ;} break; case 92: -#line 451 "compile.y" +#line 509 "compile.y" { YYSTYPE expr_code=yyvsp[0]; if(expr_code->count()==3 - && (*expr_code)[0].code==OP_VALUE) { // optimizing (double/bool/incidently 'string' too) case. [OP_VALUE+origin+Double] + && (*expr_code)[0].code==OP::OP_VALUE) { // optimizing (double/bool/incidently 'string' too) case. [OP::OP_VALUE+origin+Double]. no evaluating yyval=expr_code; - O(*yyval, OP_STORE_PARAM); // no evaluating } else { ArrayOperation* code=N(); - O(*code, OP_PREPARE_TO_EXPRESSION); + O(*code, OP::OP_PREPARE_TO_EXPRESSION); P(*code, *expr_code); - O(*code, OP_WRITE_EXPR_RESULT); + O(*code, OP::OP_WRITE_EXPR_RESULT); yyval=N(); - OA(*yyval, OP_EXPR_CODE__STORE_PARAM, code); + OA(*yyval, OP::OP_EXPR_CODE__STORE_PARAM, code); } ;} break; case 93: -#line 466 "compile.y" +#line 523 "compile.y" { yyval=N(); - OA(*yyval, OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); + OA(*yyval, OP::OP_CURLY_CODE__STORE_PARAM, yyvsp[0]); ;} break; case 98: -#line 478 "compile.y" +#line 535 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 100: -#line 480 "compile.y" +#line 537 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 102: -#line 482 "compile.y" +#line 539 "compile.y" { // we know that name_advance1 not called from ^xxx context // so we'll not check for operator call possibility as we do in name_advance2 /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ - O(*yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ + O(*yyval, OP::OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ ;} break; case 103: -#line 490 "compile.y" +#line 547 "compile.y" { /* stack: context */ yyval=yyvsp[0]; /* stack: context,name */ - O(*yyval, OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ + O(*yyval, OP::OP_GET_ELEMENT); /* name=pop; context=pop; stack: context.get_element(name) */ ;} break; case 109: -#line 503 "compile.y" +#line 560 "compile.y" { yyval=yyvsp[0]; - O(*yyval, OP_GET_ELEMENT); + O(*yyval, OP::OP_GET_ELEMENT); ;} break; case 110: -#line 507 "compile.y" +#line 564 "compile.y" { ArrayOperation* code; { @@ -1901,12 +1966,12 @@ yyreduce: P(*code, *yyvsp[0]); } yyval=N(); - OA(*yyval, OP_STRING_POOL, code); + OA(*yyval, OP::OP_STRING_POOL, code); ;} break; case 111: -#line 516 "compile.y" +#line 573 "compile.y" { // allow $result_or_other_variable[ letters here any time ] *reinterpret_cast(&yyval)=PC.explicit_result; PC.explicit_result=false; @@ -1914,46 +1979,46 @@ yyreduce: break; case 112: -#line 519 "compile.y" +#line 576 "compile.y" { PC.explicit_result=*reinterpret_cast(&yyvsp[-1]); ;} break; case 113: -#line 521 "compile.y" +#line 578 "compile.y" { yyval=N(); - OA(*yyval, OP_OBJECT_POOL, yyvsp[-2]); /* stack: empty write context */ + OA(*yyval, OP::OP_OBJECT_POOL, yyvsp[-2]); /* stack: empty write context */ /* some code that writes to that context */ /* context=pop; stack: context.value() */ ;} break; case 114: -#line 527 "compile.y" +#line 584 "compile.y" { yyval=N(); - O(*yyval, OP_WITH_READ); + O(*yyval, OP::OP_WITH_READ); P(*yyval, *yyvsp[0]); ;} break; case 116: -#line 532 "compile.y" +#line 589 "compile.y" { yyval=yyvsp[-1]; P(*yyval, *yyvsp[0]) ;} break; case 117: -#line 533 "compile.y" +#line 590 "compile.y" { yyval=yyvsp[0]; - O(*yyval, OP_GET_ELEMENT__WRITE); + O(*yyval, OP::OP_GET_ELEMENT__WRITE); ;} break; case 120: -#line 542 "compile.y" +#line 599 "compile.y" { yyval=yyvsp[-1]; // stack: class name string if(*LA2S(*yyval) == BASE_NAME) { // pseudo BASE class @@ -1964,214 +2029,219 @@ yyreduce: YYERROR; } } - O(*yyval, OP_GET_CLASS); +#ifdef OPTIMIZE_BYTECODE_GET_CLASS + // OP_VALUE+origin+string+OP_GET_CLASS -> OP_VALUE__GET_CLASS+origin+string + replace_top_opcode(*yyval, OP::OP_VALUE, OP::OP_VALUE__GET_CLASS, true/*assert if top opcode != OP_VALUE*/) +#else + O(*yyval, OP::OP_GET_CLASS); +#endif ;} break; case 121: -#line 554 "compile.y" +#line 616 "compile.y" { yyval=yyvsp[-1]; if(!PC.in_call_value) { strcpy(PC.error, ":: not allowed here"); YYERROR; } - O(*yyval, OP_PREPARE_TO_CONSTRUCT_OBJECT); + O(*yyval, OP::OP_PREPARE_TO_CONSTRUCT_OBJECT); ;} break; case 128: -#line 573 "compile.y" +#line 635 "compile.y" { yyval = yyvsp[-1] ;} break; case 129: -#line 574 "compile.y" +#line 636 "compile.y" { yyval = yyvsp[-1] ;} break; case 130: -#line 575 "compile.y" +#line 637 "compile.y" { yyval = yyvsp[-1]; ;} break; case 131: -#line 577 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_NEG) ;} +#line 639 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_NEG) ;} break; case 132: -#line 578 "compile.y" +#line 640 "compile.y" { yyval=yyvsp[0] ;} break; case 133: -#line 579 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_INV) ;} +#line 641 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_INV) ;} break; case 134: -#line 580 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_NOT) ;} +#line 642 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_NOT) ;} break; case 135: -#line 581 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_DEF) ;} +#line 643 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_DEF) ;} break; case 136: -#line 582 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_IN) ;} +#line 644 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_IN) ;} break; case 137: -#line 583 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_FEXISTS) ;} +#line 645 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_FEXISTS) ;} break; case 138: -#line 584 "compile.y" - { yyval=yyvsp[0]; O(*yyval, OP_DEXISTS) ;} +#line 646 "compile.y" + { yyval=yyvsp[0]; O(*yyval, OP::OP_DEXISTS) ;} break; case 139: -#line 586 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_SUB) ;} +#line 648 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_SUB) ;} break; case 140: -#line 587 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_ADD) ;} +#line 649 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_ADD) ;} break; case 141: -#line 588 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MUL) ;} +#line 650 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MUL) ;} break; case 142: -#line 589 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_DIV) ;} +#line 651 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_DIV) ;} break; case 143: -#line 590 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_MOD) ;} +#line 652 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_MOD) ;} break; case 144: -#line 591 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_INTDIV) ;} +#line 653 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_INTDIV) ;} break; case 145: -#line 592 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SL) ;} +#line 654 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SL) ;} break; case 146: -#line 593 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_SR) ;} +#line 655 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_SR) ;} break; case 147: -#line 594 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_AND) ;} +#line 656 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_AND) ;} break; case 148: -#line 595 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_OR) ;} +#line 657 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_OR) ;} break; case 149: -#line 596 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_BIN_XOR) ;} +#line 658 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_BIN_XOR) ;} break; case 150: -#line 597 "compile.y" - { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_AND) ;} +#line 659 "compile.y" + { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_AND) ;} break; case 151: -#line 598 "compile.y" - { yyval=yyvsp[-2]; OA(*yyval, OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP_LOG_OR) ;} +#line 660 "compile.y" + { yyval=yyvsp[-2]; OA(*yyval, OP::OP_NESTED_CODE, yyvsp[0]); O(*yyval, OP::OP_LOG_OR) ;} break; case 152: -#line 599 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_LOG_XOR) ;} +#line 661 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_LOG_XOR) ;} break; case 153: -#line 600 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LT) ;} +#line 662 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LT) ;} break; case 154: -#line 601 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GT) ;} +#line 663 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GT) ;} break; case 155: -#line 602 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_LE) ;} +#line 664 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_LE) ;} break; case 156: -#line 603 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_GE) ;} +#line 665 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_GE) ;} break; case 157: -#line 604 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_EQ) ;} +#line 666 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_EQ) ;} break; case 158: -#line 605 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_NUM_NE) ;} +#line 667 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_NUM_NE) ;} break; case 159: -#line 606 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LT) ;} +#line 668 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LT) ;} break; case 160: -#line 607 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GT) ;} +#line 669 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GT) ;} break; case 161: -#line 608 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_LE) ;} +#line 670 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_LE) ;} break; case 162: -#line 609 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_GE) ;} +#line 671 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_GE) ;} break; case 163: -#line 610 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_EQ) ;} +#line 672 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_EQ) ;} break; case 164: -#line 611 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_STR_NE) ;} +#line 673 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_STR_NE) ;} break; case 165: -#line 612 "compile.y" - { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP_IS) ;} +#line 674 "compile.y" + { yyval=yyvsp[-2]; P(*yyval, *yyvsp[0]); O(*yyval, OP::OP_IS) ;} break; case 166: -#line 615 "compile.y" +#line 677 "compile.y" { // optimized from OP_STRING->OP_VALUE for doubles maybe_change_string_literal_to_double_literal(*(yyval=yyvsp[0])); @@ -2179,17 +2249,17 @@ yyreduce: break; case 167: -#line 620 "compile.y" +#line 682 "compile.y" { yyval=N(); - OA(*yyval, OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ + OA(*yyval, OP::OP_STRING_POOL, yyvsp[0]); /* stack: empty write context */ /* some code that writes to that context */ /* context=pop; stack: context.get_string() */ ;} break; case 168: -#line 629 "compile.y" +#line 691 "compile.y" { // optimized from OP_STRING+OP_WRITE_VALUE to OP_STRING__WRITE change_string_literal_to_write_string_literal(*(yyval=yyvsp[0])) @@ -2197,30 +2267,30 @@ yyreduce: break; case 169: -#line 634 "compile.y" +#line 696 "compile.y" { yyval=VL(/*we know that we will not change it*/const_cast(&vvoid), 0, 0, 0) ;} break; case 170: -#line 635 "compile.y" +#line 697 "compile.y" { yyval = VL(/*we know that we will not change it*/const_cast(&vtrue), 0, 0, 0) ;} break; case 171: -#line 636 "compile.y" +#line 698 "compile.y" { yyval = VL(/*we know that we will not change it*/const_cast(&vfalse), 0, 0, 0) ;} break; case 172: -#line 638 "compile.y" +#line 700 "compile.y" { yyval=N() ;} break; } -/* Line 999 of yacc.c. */ -#line 2224 "compile.tab.C" +/* Line 1010 of yacc.c. */ +#line 2294 "compile.tab.C" yyvsp -= yylen; yyssp -= yylen; @@ -2323,25 +2393,27 @@ yyerrlab: /* If just tried and failed to reuse lookahead token after an error, discard it. */ - /* Return failure if at end of input. */ - if (yychar == YYEOF) + if (yychar <= YYEOF) { - /* Pop the error token. */ - YYPOPSTACK; - /* Pop the rest of the stack. */ - while (yyss < yyssp) - { - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - YYPOPSTACK; - } - YYABORT; + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); - yychar = YYEMPTY; - + } } /* Else will try to reuse lookahead token after shifting the error @@ -2349,9 +2421,27 @@ yyerrlab: goto yyerrlab1; -/*----------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action. | -`----------------------------------------------------*/ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ @@ -2375,9 +2465,8 @@ yyerrlab1: YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); yydestruct (yystos[yystate], yyvsp); - yyvsp--; - yystate = *--yyssp; - + YYPOPSTACK; + yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } @@ -2426,7 +2515,7 @@ yyreturn: } -#line 640 "compile.y" +#line 702 "compile.y" #endif @@ -2519,7 +2608,7 @@ case LS_DEF_COMMENT: default: switch(*pc.source) { // ^escaping some punctuators - case '^': case '$': case ';': + case '^': case '$': case ';': case '@': case '(': case ')': case '[': case ']': case '{': case '}': @@ -2547,7 +2636,7 @@ default: pc.string.append_strdup_know_length(begin, end-begin); } // #HH ? - if(pc.source[0]=='#' && pc.source[1] && pc.source[2]) { + if(pc.source[1] && isxdigit(pc.source[1]) && pc.source[2] && isxdigit(pc.source[2])) { char c=(char)( hex_value[(unsigned char)pc.source[1]]*0x10+ hex_value[(unsigned char)pc.source[2]]); @@ -2566,7 +2655,14 @@ default: // skip analysis = forced literal continue; } - break; + // just escaped char + // reset piece 'begin' position & line + begin=pc.source; + begin_pos=pc.pos; + // skip over _ after ^ + pc.source++; pc.pos.col++; + // skip analysis = forced literal + continue; } break; } @@ -2863,14 +2959,18 @@ default: case 'd': if(end==begin) // right after whitespace if(pc.source[0]=='e' && pc.source[1]=='f') { // def - skip_analized=2; - result=DEF; - goto break2; + switch(pc.source[2]){ + case ' ': case '\t': case '\n': case '"': case '\'': case '^': case '$': // non-quoted string without whitespace after 'def' is not allowed + skip_analized=2; + result=DEF; + goto break2; + } + // error: incorrect char after 'def' } break; case 't': if(end==begin) // right after whitespace - if(pc.source[0]=='r' && pc.source[1]=='u' && pc.source[2]=='e') { // def + if(pc.source[0]=='r' && pc.source[1]=='u' && pc.source[2]=='e') { // true skip_analized=3; result=LITERAL_TRUE; goto break2; @@ -2878,7 +2978,7 @@ default: break; case 'f': if(end==begin) // right after whitespace - if(pc.source[0]=='a' && pc.source[1]=='l' && pc.source[2]=='s' && pc.source[3]=='e') { // def + if(pc.source[0]=='a' && pc.source[1]=='l' && pc.source[2]=='s' && pc.source[3]=='e') { // false skip_analized=4; result=LITERAL_FALSE; goto break2; @@ -2960,6 +3060,8 @@ default: case '=': case '!': // common delimiters case ',': case '?': case '#': + // mysql column separators + case '`': // before call case '^': pop_LS(pc);