From a8c70f9519d6669a3ce6c2b88a5b851e0e1a71f5 Mon Sep 17 00:00:00 2001 From: zccrs Date: Sat, 1 Feb 2020 17:32:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86flex=20bison=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0=E5=88=B0=E4=BB=93?= =?UTF-8?q?=E5=BA=93=EF=BC=8C=E6=96=B9=E4=BE=BF=E9=9D=9Elinux=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E7=9A=84=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 - lexical/lex.yy.cpp | 2097 ++++++++++++++++++++++++++++++ syntax/zScript.tab.cpp | 2780 ++++++++++++++++++++++++++++++++++++++++ syntax/zScript.tab.hpp | 533 ++++++++ 4 files changed, 5410 insertions(+), 4 deletions(-) create mode 100644 lexical/lex.yy.cpp create mode 100644 syntax/zScript.tab.cpp create mode 100644 syntax/zScript.tab.hpp diff --git a/.gitignore b/.gitignore index 92f7bb1..875ee3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,6 @@ # bison tmp file syntax/zScript.output -lexical/FlexLexer.h -lexical/lex.yy.cpp -syntax/zScript.tab.cpp -syntax/zScript.tab.hpp # C++ objects and libs diff --git a/lexical/lex.yy.cpp b/lexical/lex.yy.cpp new file mode 100644 index 0000000..8342565 --- /dev/null +++ b/lexical/lex.yy.cpp @@ -0,0 +1,2097 @@ +#line 2 "lex.yy.cpp" + +#line 4 "lex.yy.cpp" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 1 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + + /* The c++ scanner is a mess. The FlexLexer.h header file relies on the + * following macro. This is required in order to pass the c++-multiple-scanners + * test in the regression suite. We get reports that it breaks inheritance. + * We will address this in a future release of flex, or omit the C++ scanner + * altogether. + */ + #define yyFlexLexer yyFlexLexer + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ +#include +#include +#include +#include +#include +/* end standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern int yyleng; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + + std::streambuf* yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +typedef unsigned char YY_CHAR; + +#define yytext_ptr yytext +#define YY_INTERACTIVE + +#include + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 53 +#define YY_END_OF_BUFFER 54 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[151] = + { 0, + 0, 0, 54, 53, 1, 2, 44, 47, 44, 44, + 44, 44, 44, 44, 44, 50, 44, 44, 44, 45, + 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 44, 53, 45, 22, 29, + 36, 26, 32, 34, 30, 35, 31, 49, 48, 33, + 0, 50, 40, 24, 20, 25, 41, 45, 28, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 8, 45, + 46, 45, 45, 45, 45, 45, 45, 45, 27, 37, + 52, 0, 0, 45, 23, 38, 51, 21, 45, 45, + 45, 45, 45, 45, 45, 11, 45, 45, 5, 45, + + 45, 45, 45, 45, 3, 45, 39, 52, 45, 18, + 45, 45, 45, 9, 45, 45, 13, 45, 45, 45, + 42, 45, 45, 15, 45, 45, 45, 43, 45, 45, + 45, 7, 45, 10, 45, 45, 6, 45, 14, 17, + 45, 45, 19, 45, 45, 16, 4, 45, 12, 0 + } ; + +static yyconst YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 6, 1, 7, 8, 9, 10, + 10, 11, 12, 10, 13, 14, 15, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 10, 10, 17, + 18, 19, 10, 10, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 10, 1, 10, 21, 22, 1, 23, 24, 25, 26, + + 27, 28, 29, 30, 31, 20, 32, 33, 20, 34, + 35, 20, 20, 36, 37, 38, 39, 40, 41, 20, + 20, 20, 10, 42, 10, 10, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst YY_CHAR yy_meta[43] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 1 + } ; + +static yyconst flex_uint16_t yy_base[153] = + { 0, + 0, 37, 168, 169, 169, 169, 149, 169, 148, 36, + 169, 147, 33, 34, 35, 41, 31, 146, 40, 0, + 145, 126, 33, 134, 127, 37, 124, 130, 130, 56, + 115, 33, 121, 131, 123, 44, 60, 61, 134, 169, + 133, 169, 169, 169, 169, 169, 169, 169, 169, 169, + 134, 57, 169, 169, 131, 169, 169, 0, 169, 121, + 110, 112, 42, 108, 111, 107, 108, 103, 0, 99, + 169, 101, 107, 101, 97, 109, 98, 102, 169, 114, + 0, 62, 73, 72, 169, 169, 115, 169, 107, 102, + 90, 104, 99, 98, 87, 0, 98, 87, 0, 82, + + 82, 84, 91, 90, 0, 83, 169, 0, 83, 0, + 83, 73, 70, 0, 80, 68, 0, 69, 79, 62, + 0, 73, 73, 0, 62, 62, 67, 0, 62, 58, + 61, 0, 59, 0, 50, 50, 0, 52, 0, 0, + 51, 57, 0, 48, 54, 0, 0, 54, 0, 169, + 76, 110 + } ; + +static yyconst flex_int16_t yy_def[153] = + { 0, + 150, 1, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 151, + 150, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 150, 150, 151, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 151, 150, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 150, 151, 151, 151, 151, 151, 151, 151, 150, 150, + 152, 150, 150, 151, 150, 150, 150, 150, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + + 151, 151, 151, 151, 151, 151, 150, 152, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 151, 151, 151, 151, 0, + 150, 150 + } ; + +static yyconst flex_uint16_t yy_nxt[212] = + { 0, + 4, 5, 6, 7, 8, 4, 9, 10, 8, 11, + 12, 13, 14, 11, 15, 16, 17, 18, 19, 20, + 21, 11, 20, 22, 23, 24, 25, 26, 27, 20, + 28, 20, 20, 29, 20, 30, 31, 32, 33, 34, + 35, 36, 37, 41, 44, 48, 46, 53, 54, 49, + 45, 47, 50, 42, 51, 61, 52, 56, 57, 65, + 71, 79, 74, 81, 71, 81, 83, 62, 75, 92, + 51, 66, 52, 38, 93, 67, 81, 83, 58, 149, + 148, 147, 72, 146, 145, 80, 144, 143, 142, 141, + 140, 139, 138, 137, 136, 135, 82, 84, 82, 134, + + 133, 73, 132, 131, 130, 129, 128, 127, 84, 82, + 108, 126, 108, 125, 124, 123, 122, 121, 120, 119, + 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, + 87, 107, 106, 105, 104, 103, 102, 101, 100, 99, + 98, 97, 96, 95, 94, 91, 90, 89, 88, 87, + 86, 85, 78, 77, 76, 73, 70, 69, 68, 64, + 63, 60, 59, 55, 43, 40, 39, 150, 3, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150 + } ; + +static yyconst flex_int16_t yy_chk[212] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 2, 10, 13, 15, 14, 17, 17, 15, + 13, 14, 15, 10, 16, 23, 16, 19, 19, 26, + 30, 36, 32, 37, 30, 82, 38, 23, 32, 63, + 52, 26, 52, 2, 63, 26, 83, 84, 151, 148, + 145, 144, 30, 142, 141, 36, 138, 136, 135, 133, + 131, 130, 129, 127, 126, 125, 37, 38, 82, 123, + + 122, 38, 120, 119, 118, 116, 115, 113, 84, 83, + 152, 112, 152, 111, 109, 106, 104, 103, 102, 101, + 100, 98, 97, 95, 94, 93, 92, 91, 90, 89, + 87, 80, 78, 77, 76, 75, 74, 73, 72, 70, + 68, 67, 66, 65, 64, 62, 61, 60, 55, 51, + 41, 39, 35, 34, 33, 31, 29, 28, 27, 25, + 24, 22, 21, 18, 12, 9, 7, 3, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + + 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, + 150 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +#line 2 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +#include "zScript.tab.hpp" +#include "zglobal.h" +#include "ztool.h" + +#include +#include +#include + +#include + +yy::parser::semantic_type *yylval = Q_NULLPTR; +yy::parser::location_type *yyloc = Q_NULLPTR; + +int lineCount = 1; +int currentColumn = 0; + +QQueue tokenQueue; +QQueue tokenValQueue; +QQueue tokenLocQueue; + +#define TOKEN_PREFIX yy::parser::token +#define RECORD_TOKEN_LOC \ + yyloc->begin.line = lineCount;\ + yyloc->begin.column = currentColumn;\ + yyloc->end.line = lineCount;\ + yyloc->end.column = strlen(yytext) + currentColumn;\ + currentColumn = yyloc->end.column; +#line 528 "lex.yy.cpp" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +#define ECHO LexerOutput( yytext, yyleng ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +\ + if ( (int)(result = LexerInput( (char *) buf, max_size )) < 0 ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) LexerError( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +#define YY_DECL int yyFlexLexer::yylex() +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin.rdbuf(std::cin.rdbuf()); + + if ( ! yyout ) + yyout.rdbuf(std::cout.rdbuf()); + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 38 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" + +#line 665 "lex.yy.cpp" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 151 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 169 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 39 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" + + YY_BREAK +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 41 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + ++lineCount; + currentColumn = 0; +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 46 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::VAR;} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 47 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::FUNCTION;} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 48 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::NEW;} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 49 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::DELETE;} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 50 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::THROW;} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 51 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::IF;} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 52 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::ELSE;} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 53 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::WHILE;} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 54 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::FOR;} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 55 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::UNDEFINED;} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 56 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::GOTO;} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 57 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::RETURN;} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 58 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::BREAK;} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 59 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::CONTINUE;} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 60 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::SWITCH;} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 61 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::CASE;} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 62 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::DEFAULT;} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 63 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::EQ;} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 64 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::STEQ;} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 65 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::NEQ;} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 66 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::STNEQ;} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 67 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::LE;} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 68 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::GE;} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 69 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::ANDASSIGN;} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 70 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::ORASSIGN;} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 71 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::XORASSIGN;} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 72 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::MODASSIGN;} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 73 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::ADDASSIGN;} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 74 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::SUBASSIGN;} + YY_BREAK +case 32: +YY_RULE_SETUP +#line 75 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::MULASSIGN;} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 76 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::DIVASSIGN;} + YY_BREAK +case 34: +YY_RULE_SETUP +#line 77 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::ADDSELF;} + YY_BREAK +case 35: +YY_RULE_SETUP +#line 78 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::SUBSELF;} + YY_BREAK +case 36: +YY_RULE_SETUP +#line 79 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::LAND;} + YY_BREAK +case 37: +YY_RULE_SETUP +#line 80 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::LOR;} + YY_BREAK +case 38: +YY_RULE_SETUP +#line 81 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::LANDASSIGN;} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 82 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::LORASSIGN;} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 83 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::LL;} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 84 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ RECORD_TOKEN_LOC; return TOKEN_PREFIX::GG;} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 86 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray("true"); + + return TOKEN_PREFIX::BOOL; +} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 94 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray("false"); + + return TOKEN_PREFIX::BOOL; +} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 102 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + char ch = yytext[0]; + + if (ch == '{') { + int token = yylex(); + + tokenQueue << token; + tokenValQueue << *yylval; + tokenLocQueue << *yyloc; + + if (token == '}') + return TOKEN_PREFIX::NEW_OBJ_BEGIN; + + if (token != TOKEN_PREFIX::IDENTIFIER) + return ch; + + token = yylex(); + + tokenQueue << token; + tokenValQueue << *yylval; + tokenLocQueue << *yyloc; + + if (token == ':') + return TOKEN_PREFIX::NEW_OBJ_BEGIN; + } + + return ch; +} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 133 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray(yytext); + + return TOKEN_PREFIX::IDENTIFIER; +} + YY_BREAK +case 46: +YY_RULE_SETUP +#line 141 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray(); + + QByteArray &str = *yylval->identifier; + + while(!yyin.eof() && !yyin.fail()) { + char ch = yyin.get(); + + if(ch == yytext[1]) + break; + + str.append(ch); + } + + return TOKEN_PREFIX::STRING; +} + YY_BREAK +case 47: +YY_RULE_SETUP +#line 160 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray(); + + QByteArray &str = *yylval->identifier; + char ch = 0; + + while(!yyin.eof() && !yyin.fail()) { + if (ch == '\\') { + str.append(yyin.get()); + + if (yyin.eof() || yyin.fail()) + break; + } + + ch = yyin.get(); + + if(ch == yytext[0]) + break; + + str.append(ch); + } + + str = ZTool::stringEscapeHandler(str); + + return TOKEN_PREFIX::STRING; +} + YY_BREAK +case 48: +YY_RULE_SETUP +#line 189 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + while(!yyin.eof() && !yyin.fail()) { + char ch = yyin.get(); + + if(ch == '\n' || ch == '\r') + break; + + if(ch == '\\') { + if(yyin.eof() || yyin.fail()) + break; + + yyin.get(); + } + } + + ++lineCount; +} + YY_BREAK +case 49: +YY_RULE_SETUP +#line 207 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + while (!yyin.eof() && !yyin.fail()) { + char ch = yyin.get(); + + if (ch == '*') { + if(yyin.eof() || yyin.fail()) + break; + + char ch_next = yyin.get(); + + if (ch_next == '/') + break; + else if (ch_next == '\n') + ++lineCount; + } else if (ch == '\n') { + ++lineCount; + } + } +} + YY_BREAK +case 50: +YY_RULE_SETUP +#line 227 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray(yytext); + + return TOKEN_PREFIX::INT; +} + YY_BREAK +case 51: +YY_RULE_SETUP +#line 235 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + RECORD_TOKEN_LOC; + + yylval->identifier = new QByteArray(yytext); + + return TOKEN_PREFIX::DOUBLE; +} + YY_BREAK +case 52: +YY_RULE_SETUP +#line 243 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +{ + if(lineCount > 1) { + RECORD_TOKEN_LOC; + + yylval->msg = new std::string("Only at the beginning of the file"); + + return TOKEN_PREFIX::ERROR; + } +} + YY_BREAK +case 53: +YY_RULE_SETUP +#line 253 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" +ECHO; + YY_BREAK +#line 1137 "lex.yy.cpp" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin.rdbuf(); + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* The contents of this function are C++ specific, so the () macro is not used. + * This constructor simply maintains backward compatibility. + * DEPRECATED + */ +yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout ): + yyin(arg_yyin ? arg_yyin->rdbuf() : std::cin.rdbuf()), + yyout(arg_yyout ? arg_yyout->rdbuf() : std::cout.rdbuf()) +{ + ctor_common(); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout ): + yyin(arg_yyin.rdbuf()), + yyout(arg_yyout.rdbuf()) +{ + ctor_common(); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::ctor_common() +{ + yy_c_buf_p = 0; + yy_init = 0; + yy_start = 0; + yy_flex_debug = 0; + yylineno = 1; // this will only get updated if %option yylineno + + yy_did_buffer_switch_on_eof = 0; + + yy_looking_for_trail_begin = 0; + yy_more_flag = 0; + yy_more_len = 0; + yy_more_offset = yy_prev_more_offset = 0; + + yy_start_stack_ptr = yy_start_stack_depth = 0; + yy_start_stack = NULL; + + yy_buffer_stack = NULL; + yy_buffer_stack_top = 0; + yy_buffer_stack_max = 0; + + yy_state_buf = 0; + +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +yyFlexLexer::~yyFlexLexer() +{ + delete [] yy_state_buf; + yyfree(yy_start_stack ); + yy_delete_buffer( YY_CURRENT_BUFFER ); + yyfree(yy_buffer_stack ); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream& new_in, std::ostream& new_out ) +{ + // was if( new_in ) + yy_delete_buffer( YY_CURRENT_BUFFER ); + yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); + + // was if( new_out ) + yyout.rdbuf(new_out.rdbuf()); +} + +/* The contents of this function are C++ specific, so the () macro is not used. + */ +void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out ) +{ + if( ! new_in ) { + new_in = &yyin; + } + + if ( ! new_out ) { + new_out = &yyout; + } + + switch_streams(*new_in, *new_out); +} + +#ifdef YY_INTERACTIVE +int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) +#else +int yyFlexLexer::LexerInput( char* buf, int max_size ) +#endif +{ + if ( yyin.eof() || yyin.fail() ) + return 0; + +#ifdef YY_INTERACTIVE + yyin.get( buf[0] ); + + if ( yyin.eof() ) + return 0; + + if ( yyin.bad() ) + return -1; + + return 1; + +#else + (void) yyin.read( buf, max_size ); + + if ( yyin.bad() ) + return -1; + else + return yyin.gcount(); +#endif +} + +void yyFlexLexer::LexerOutput( const char* buf, int size ) +{ + (void) yyout.write( buf, size ); +} + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +int yyFlexLexer::yy_get_next_buffer() +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + yy_state_type yyFlexLexer::yy_get_previous_state() +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 151 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 151 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c]; + yy_is_jam = (yy_current_state == 150); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + void yyFlexLexer::yyunput( int c, char* yy_bp) +{ + char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} +#endif + + int yyFlexLexer::yyinput() +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + + return c; +} + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyFlexLexer::yyrestart( std::istream& input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Delegate to the new version that takes an istream reference. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ +void yyFlexLexer::yyrestart( std::istream* input_file ) +{ + yyrestart( *input_file ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + + void yyFlexLexer::yy_load_buffer_state() +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin.rdbuf(YY_CURRENT_BUFFER_LVALUE->yy_input_file); + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream& file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = (yy_size_t)size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Delegate creation of buffers to the new version that takes an istream reference. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size ) +{ + return yy_create_buffer( *file, size ); +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree((void *) b->yy_ch_buf ); + + yyfree((void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream& file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file.rdbuf(); + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yyFlexLexer::yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +void yyFlexLexer::yyensure_buffer_stack(void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + + void yyFlexLexer::yy_push_state( int _new_state ) +{ + if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) ) + { + yy_size_t new_size; + + (yy_start_stack_depth) += YY_START_STACK_INCR; + new_size = (yy_size_t) (yy_start_stack_depth) * sizeof( int ); + + if ( ! (yy_start_stack) ) + (yy_start_stack) = (int *) yyalloc(new_size ); + + else + (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size ); + + if ( ! (yy_start_stack) ) + YY_FATAL_ERROR( "out of memory expanding start-condition stack" ); + } + + (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START; + + BEGIN(_new_state); +} + + void yyFlexLexer::yy_pop_state() +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + int yyFlexLexer::yy_top_state() +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +void yyFlexLexer::LexerError( yyconst char* msg ) +{ + std::cerr << msg << std::endl; + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 253 "/mnt/c/Users/zccrs/projects/zScript/lexical/zScript.ll" + + + diff --git a/syntax/zScript.tab.cpp b/syntax/zScript.tab.cpp new file mode 100644 index 0000000..f5d96d6 --- /dev/null +++ b/syntax/zScript.tab.cpp @@ -0,0 +1,2780 @@ +// A Bison parser, made by GNU Bison 3.0.4. + +// Skeleton implementation for Bison LALR(1) parsers in C++ + +// Copyright (C) 2002-2015 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// As a special exception, you may create a larger work that contains +// part or all of the Bison parser skeleton and distribute that work +// under terms of your choice, so long as that work isn't itself a +// parser generator using the skeleton or a modified version thereof +// as a parser skeleton. Alternatively, if you modify or redistribute +// the parser skeleton itself, you may (at your option) remove this +// special exception, which will cause the skeleton and the resulting +// Bison output files to be licensed under the GNU General Public +// License without this special exception. + +// This special exception was added by the Free Software Foundation in +// version 2.2 of Bison. + + +// First part of user declarations. +#line 1 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:404 + +#include "zcode.h" +#define protected public +#include "lex.yy.cpp" +#undef protected + +/// enable debug +#define YYDEBUG 1 + +int yylex(yy::parser::semantic_type *lval, yy::parser::location_type *location); + +enum ValueType { + Variant, + Constant +}; + +Z_USE_NAMESPACE + + +#line 56 "zScript.tab.cpp" // lalr1.cc:404 + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +#include "zScript.tab.hpp" + +// User implementation prologue. + +#line 70 "zScript.tab.cpp" // lalr1.cc:412 + + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include // FIXME: INFRINGES ON USER NAME SPACE. +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +#define YYRHSLOC(Rhs, K) ((Rhs)[K].location) +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +# ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).begin = YYRHSLOC (Rhs, 1).begin; \ + (Current).end = YYRHSLOC (Rhs, N).end; \ + } \ + else \ + { \ + (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \ + } \ + while (/*CONSTCOND*/ false) +# endif + + +// Suppress unused-variable warnings by "using" E. +#define YYUSE(E) ((void) (E)) + +// Enable debugging if requested. +#if YYDEBUG + +// A pseudo ostream that takes yydebug_ into account. +# define YYCDEBUG if (yydebug_) (*yycdebug_) + +# define YY_SYMBOL_PRINT(Title, Symbol) \ + do { \ + if (yydebug_) \ + { \ + *yycdebug_ << Title << ' '; \ + yy_print_ (*yycdebug_, Symbol); \ + *yycdebug_ << std::endl; \ + } \ + } while (false) + +# define YY_REDUCE_PRINT(Rule) \ + do { \ + if (yydebug_) \ + yy_reduce_print_ (Rule); \ + } while (false) + +# define YY_STACK_PRINT() \ + do { \ + if (yydebug_) \ + yystack_print_ (); \ + } while (false) + +#else // !YYDEBUG + +# define YYCDEBUG if (false) std::cerr +# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol) +# define YY_REDUCE_PRINT(Rule) static_cast(0) +# define YY_STACK_PRINT() static_cast(0) + +#endif // !YYDEBUG + +#define yyerrok (yyerrstatus_ = 0) +#define yyclearin (yyla.clear ()) + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab +#define YYRECOVERING() (!!yyerrstatus_) + + +namespace yy { +#line 156 "zScript.tab.cpp" // lalr1.cc:479 + + /* Return YYSTR after stripping away unnecessary quotes and + backslashes, so that it's suitable for yyerror. The heuristic is + that double-quoting is unnecessary unless the string contains an + apostrophe, a comma, or backslash (other than backslash-backslash). + YYSTR is taken from yytname. */ + std::string + parser::yytnamerr_ (const char *yystr) + { + if (*yystr == '"') + { + std::string yyr = ""; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + // Fall through. + default: + yyr += *yyp; + break; + + case '"': + return yyr; + } + do_not_strip_quotes: ; + } + + return yystr; + } + + + /// Build a parser object. + parser::parser () +#if YYDEBUG + :yydebug_ (false), + yycdebug_ (&std::cerr) +#endif + {} + + parser::~parser () + {} + + + /*---------------. + | Symbol types. | + `---------------*/ + + inline + parser::syntax_error::syntax_error (const location_type& l, const std::string& m) + : std::runtime_error (m) + , location (l) + {} + + // basic_symbol. + template + inline + parser::basic_symbol::basic_symbol () + : value () + {} + + template + inline + parser::basic_symbol::basic_symbol (const basic_symbol& other) + : Base (other) + , value () + , location (other.location) + { + value = other.value; + } + + + template + inline + parser::basic_symbol::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l) + : Base (t) + , value (v) + , location (l) + {} + + + /// Constructor for valueless symbols. + template + inline + parser::basic_symbol::basic_symbol (typename Base::kind_type t, const location_type& l) + : Base (t) + , value () + , location (l) + {} + + template + inline + parser::basic_symbol::~basic_symbol () + { + clear (); + } + + template + inline + void + parser::basic_symbol::clear () + { + Base::clear (); + } + + template + inline + bool + parser::basic_symbol::empty () const + { + return Base::type_get () == empty_symbol; + } + + template + inline + void + parser::basic_symbol::move (basic_symbol& s) + { + super_type::move(s); + value = s.value; + location = s.location; + } + + // by_type. + inline + parser::by_type::by_type () + : type (empty_symbol) + {} + + inline + parser::by_type::by_type (const by_type& other) + : type (other.type) + {} + + inline + parser::by_type::by_type (token_type t) + : type (yytranslate_ (t)) + {} + + inline + void + parser::by_type::clear () + { + type = empty_symbol; + } + + inline + void + parser::by_type::move (by_type& that) + { + type = that.type; + that.clear (); + } + + inline + int + parser::by_type::type_get () const + { + return type; + } + + + // by_state. + inline + parser::by_state::by_state () + : state (empty_state) + {} + + inline + parser::by_state::by_state (const by_state& other) + : state (other.state) + {} + + inline + void + parser::by_state::clear () + { + state = empty_state; + } + + inline + void + parser::by_state::move (by_state& that) + { + state = that.state; + that.clear (); + } + + inline + parser::by_state::by_state (state_type s) + : state (s) + {} + + inline + parser::symbol_number_type + parser::by_state::type_get () const + { + if (state == empty_state) + return empty_symbol; + else + return yystos_[state]; + } + + inline + parser::stack_symbol_type::stack_symbol_type () + {} + + + inline + parser::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) + : super_type (s, that.location) + { + value = that.value; + // that is emptied. + that.type = empty_symbol; + } + + inline + parser::stack_symbol_type& + parser::stack_symbol_type::operator= (const stack_symbol_type& that) + { + state = that.state; + value = that.value; + location = that.location; + return *this; + } + + + template + inline + void + parser::yy_destroy_ (const char* yymsg, basic_symbol& yysym) const + { + if (yymsg) + YY_SYMBOL_PRINT (yymsg, yysym); + + // User destructor. + YYUSE (yysym.type_get ()); + } + +#if YYDEBUG + template + void + parser::yy_print_ (std::ostream& yyo, + const basic_symbol& yysym) const + { + std::ostream& yyoutput = yyo; + YYUSE (yyoutput); + symbol_number_type yytype = yysym.type_get (); + // Avoid a (spurious) G++ 4.8 warning about "array subscript is + // below array bounds". + if (yysym.empty ()) + std::abort (); + yyo << (yytype < yyntokens_ ? "token" : "nterm") + << ' ' << yytname_[yytype] << " (" + << yysym.location << ": "; + YYUSE (yytype); + yyo << ')'; + } +#endif + + inline + void + parser::yypush_ (const char* m, state_type s, symbol_type& sym) + { + stack_symbol_type t (s, sym); + yypush_ (m, t); + } + + inline + void + parser::yypush_ (const char* m, stack_symbol_type& s) + { + if (m) + YY_SYMBOL_PRINT (m, s); + yystack_.push (s); + } + + inline + void + parser::yypop_ (unsigned int n) + { + yystack_.pop (n); + } + +#if YYDEBUG + std::ostream& + parser::debug_stream () const + { + return *yycdebug_; + } + + void + parser::set_debug_stream (std::ostream& o) + { + yycdebug_ = &o; + } + + + parser::debug_level_type + parser::debug_level () const + { + return yydebug_; + } + + void + parser::set_debug_level (debug_level_type l) + { + yydebug_ = l; + } +#endif // YYDEBUG + + inline parser::state_type + parser::yy_lr_goto_state_ (state_type yystate, int yysym) + { + int yyr = yypgoto_[yysym - yyntokens_] + yystate; + if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate) + return yytable_[yyr]; + else + return yydefgoto_[yysym - yyntokens_]; + } + + inline bool + parser::yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + inline bool + parser::yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == yytable_ninf_; + } + + int + parser::parse () + { + // State. + int yyn; + /// Length of the RHS of the rule being reduced. + int yylen = 0; + + // Error handling. + int yynerrs_ = 0; + int yyerrstatus_ = 0; + + /// The lookahead symbol. + symbol_type yyla; + + /// The locations where the error started and ended. + stack_symbol_type yyerror_range[3]; + + /// The return value of parse (). + int yyresult; + + // FIXME: This shoud be completely indented. It is not yet to + // avoid gratuitous conflicts when merging into the master branch. + try + { + YYCDEBUG << "Starting parse" << std::endl; + + + /* Initialize the stack. The initial state will be set in + yynewstate, since the latter expects the semantical and the + location values to have been already stored, initialize these + stacks with a primary value. */ + yystack_.clear (); + yypush_ (YY_NULLPTR, 0, yyla); + + // A new symbol was pushed on the stack. + yynewstate: + YYCDEBUG << "Entering state " << yystack_[0].state << std::endl; + + // Accept? + if (yystack_[0].state == yyfinal_) + goto yyacceptlab; + + goto yybackup; + + // Backup. + yybackup: + + // Try to take a decision without lookahead. + yyn = yypact_[yystack_[0].state]; + if (yy_pact_value_is_default_ (yyn)) + goto yydefault; + + // Read a lookahead token. + if (yyla.empty ()) + { + YYCDEBUG << "Reading a token: "; + try + { + yyla.type = yytranslate_ (yylex (&yyla.value, &yyla.location)); + } + catch (const syntax_error& yyexc) + { + error (yyexc); + goto yyerrlab1; + } + } + YY_SYMBOL_PRINT ("Next token is", yyla); + + /* If the proper action on seeing token YYLA.TYPE is to reduce or + to detect an error, take that action. */ + yyn += yyla.type_get (); + if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ()) + goto yydefault; + + // Reduce or error. + yyn = yytable_[yyn]; + if (yyn <= 0) + { + if (yy_table_value_is_error_ (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + // Count tokens shifted since error; after three, turn off error status. + if (yyerrstatus_) + --yyerrstatus_; + + // Shift the lookahead token. + yypush_ ("Shifting", yyn, yyla); + goto yynewstate; + + /*-----------------------------------------------------------. + | yydefault -- do the default action for the current state. | + `-----------------------------------------------------------*/ + yydefault: + yyn = yydefact_[yystack_[0].state]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + /*-----------------------------. + | yyreduce -- Do a reduction. | + `-----------------------------*/ + yyreduce: + yylen = yyr2_[yyn]; + { + stack_symbol_type yylhs; + yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]); + /* If YYLEN is nonzero, implement the default value of the + action: '$$ = $1'. Otherwise, use the top of the stack. + + Otherwise, the following line sets YYLHS.VALUE to garbage. + This behavior is undocumented and Bison users should not rely + upon it. */ + if (yylen) + yylhs.value = yystack_[yylen - 1].value; + else + yylhs.value = yystack_[0].value; + + // Compute the default @$. + { + slice slice (yystack_, yylen); + YYLLOC_DEFAULT (yylhs.location, slice, yylen); + } + + // Perform the reduction. + YY_REDUCE_PRINT (yyn); + try + { + switch (yyn) + { + case 4: +#line 83 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + error(yystack_[0].location, *(yystack_[0].value.msg)); + delete (yystack_[0].value.msg); + YYABORT; + } +#line 638 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 5: +#line 90 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Goto, ZCodeExecuter::currentCodeExecuter->getGotoLabel(*(yystack_[1].value.identifier))); + + delete (yystack_[1].value.identifier); + } +#line 648 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 8: +#line 97 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if(ZCodeExecuter::currentCodeExecuter->getCodeList().count() > 1 + && ZCodeExecuter::currentCodeExecuter->getCodeList().last()->action != ZCode::PopAll) + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PopAll); + } +#line 658 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 9: +#line 102 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Goto, ZCodeExecuter::currentCodeExecuter->createConstantByValue(ZVariant(INT32_MAX))); + } +#line 666 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 10: +#line 105 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant(QByteArray::number((yystack_[0].value.count)), ZVariant::Int)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::JoinToTuple); + } +#line 675 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 11: +#line 109 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LeftAssign); + + if(ZCodeExecuter::currentCodeExecuter->getCodeList().count() > 1 + && ZCodeExecuter::currentCodeExecuter->getCodeList().last()->action != ZCode::PopAll) + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PopAll); + } +#line 687 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 12: +#line 116 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + /// 判断是否是以break结尾 + bool isBreak = !((yystack_[1].value.count) & 0x8000); + auto type = ZCodeExecuter::CodeBlock::Type(ZCodeExecuter::CodeBlock::LoopStructure | ZCodeExecuter::CodeBlock::Switch | ZCodeExecuter::CodeBlock::Normal); + ZCodeExecuter::CodeBlock *block_while = ZCodeExecuter::currentCodeExecuter->getCodeBlockByType(type, ZCodeExecuter::currentCodeExecuter->getCodeBlock()); + /// break的个数 + qint16 break_count = ((yystack_[1].value.count) & 0x7fff) - !isBreak; + + while ((--break_count) > 0) { + if (!block_while) { + error(yystack_[1].location, ("\"break\" Can't be used here")); + YYABORT; + } + + block_while = ZCodeExecuter::currentCodeExecuter->getCodeBlockByType(type, block_while->parent); + } + + if (!block_while) { + error(yystack_[1].location, ("Can't be used here")); + YYABORT; + } + + if (isBreak) { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Goto, block_while->breakIndex); + } else { + /// break_count小于0时说明只存在coutinue语句,因此需要从当前code block查找 + block_while = ZCodeExecuter::currentCodeExecuter->getCodeBlockByType(ZCodeExecuter::CodeBlock::LoopStructure, + break_count < 0 ? ZCodeExecuter::currentCodeExecuter->getCodeBlock() + : block_while->parent); + + if (!block_while) { + error(yystack_[1].location, "\"continue\" Can't be used here"); + YYABORT; + } + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Goto, block_while->toLoopStructureCodeBlock()->continueIndex); + } + } +#line 730 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 13: +#line 154 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {} +#line 736 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 15: +#line 156 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + /// For While If Switch-case 语句本身已经添加了对应的CodeBlock,此处的CodeBlock应当不做任何实际作用,也不应该占用break语句 + if (ZCodeExecuter::currentCodeExecuter->getCodeBlock()->type == ZCodeExecuter::CodeBlock::Normal + || ZCodeExecuter::currentCodeExecuter->getCodeBlock()->type == ZCodeExecuter::CodeBlock::Function) { + ZCodeExecuter::currentCodeExecuter->beginCodeBlock(); + } else { + ZCodeExecuter::currentCodeExecuter->beginCodeBlock(); + ZCodeExecuter::currentCodeExecuter->getCodeBlock()->breakIndex.reset(); + } + } +#line 751 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 16: +#line 165 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if (auto break_index = ZCodeExecuter::currentCodeExecuter->getCodeBlock()->breakIndex.data()) { + *break_index = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + } + + ZCodeExecuter::currentCodeExecuter->endCodeBlock(); + } +#line 763 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 19: +#line 176 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = 1;} +#line 769 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 20: +#line 177 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = (yystack_[2].value.count) + 1;} +#line 775 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 21: +#line 181 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = 0x8001;} +#line 781 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 22: +#line 182 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = (0x8000 | ((yystack_[2].value.count) + 1));} +#line 787 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 23: +#line 183 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = (yystack_[0].value.count);} +#line 793 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 24: +#line 186 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Switch, ZSharedVariantPointer(new ZSharedVariant())); + (yylhs.value.value) = &ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode()->value; + + ZCodeExecuter::currentCodeExecuter->beginCodeBlock(ZCodeExecuter::CodeBlock::Switch); + } +#line 804 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 25: +#line 194 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + *ZCodeExecuter::currentCodeExecuter->getCodeBlock()->breakIndex.data() = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + + QHash hashSwitch; + + hashSwitch.reserve((yystack_[1].value.cases)->size()); + + bool existDefault = false; + + for(const QPair &c : *(yystack_[1].value.cases)) { + if(c.first) { + hashSwitch[*c.first->constData()] = c.second; + } else { + hashSwitch[ZVariant()] = c.second; + existDefault = true; + } + } + + if(!existDefault) + hashSwitch[ZVariant()] = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + + *(yystack_[3].value.value)->data() = QVariant::fromValue(hashSwitch); + + ZCodeExecuter::currentCodeExecuter->endCodeBlock(); + } +#line 834 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 26: +#line 221 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.caseKey) = new QPair((yystack_[1].value.value), ZCodeExecuter::currentCodeExecuter->getCodeList().count()); + } +#line 842 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 27: +#line 226 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.cases) = new QVector>(); + (yylhs.value.cases)->append(*(yystack_[1].value.caseKey)); + + delete (yystack_[1].value.caseKey); + } +#line 853 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 28: +#line 232 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + /// 储存code的开始index + (yystack_[1].value.count) = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + } +#line 862 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 29: +#line 235 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.cases) = (yystack_[4].value.cases); + (yylhs.value.cases)->append(QPair(Q_NULLPTR, (yystack_[3].value.count))); + } +#line 871 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 30: +#line 239 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.cases) = (yystack_[2].value.cases); + (yylhs.value.cases)->append(*(yystack_[1].value.caseKey)); + + delete (yystack_[1].value.caseKey); + } +#line 882 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 31: +#line 247 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + *ZCodeExecuter::currentCodeExecuter->getGotoLabel(*(yystack_[1].value.identifier)) = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + + delete (yystack_[1].value.identifier); + } +#line 892 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 32: +#line 262 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::beginCodeExecuter()->beginCodeBlock(ZCodeExecuter::CodeBlock::Function); + + if((yystack_[1].value.parameterList)) { + for(QByteArray *id : *(yystack_[1].value.parameterList)) { + ZCodeExecuter::currentCodeExecuter->getParameterList() << ZCodeExecuter::currentCodeExecuter->addIdentifier(*id); + delete id; + } + + delete (yystack_[1].value.parameterList); + } + } +#line 909 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 33: +#line 273 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->endCodeBlock(); + ZCodeExecuter *executer = ZCodeExecuter::endCodeExecuter(); + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createFunction(executer)); + } +#line 920 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 34: +#line 281 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant("", ZVariant::Undefined)); + } +#line 928 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 36: +#line 285 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant(QByteArray::number((yystack_[0].value.count)), ZVariant::Int)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::JoinToTuple); + } +#line 937 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 37: +#line 291 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.parameterList) = Q_NULLPTR;} +#line 943 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 38: +#line 292 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.parameterList) = new QVarLengthArray(); + (yylhs.value.parameterList)->append((yystack_[0].value.identifier)); + } +#line 952 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 39: +#line 296 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.parameterList) = (yystack_[2].value.parameterList); + (yylhs.value.parameterList)->append((yystack_[0].value.identifier)); + } +#line 961 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 40: +#line 302 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->addIdentifier(*(yystack_[0].value.identifier)); + delete (yystack_[0].value.identifier); + } +#line 970 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 41: +#line 306 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->addIdentifier(*(yystack_[2].value.identifier)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::currentCodeExecuter->getIdentifier(*(yystack_[2].value.identifier))); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::RightAssign); + + delete (yystack_[2].value.identifier); + } +#line 982 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 43: +#line 317 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = 2;} +#line 988 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 44: +#line 318 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = (yystack_[2].value.count) + 1;} +#line 994 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 45: +#line 321 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = 2;} +#line 1000 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 46: +#line 322 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = (yystack_[2].value.count) + 1;} +#line 1006 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 49: +#line 327 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + } +#line 1014 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 50: +#line 330 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::currentCodeExecuter->getIdentifier(*(yystack_[0].value.identifier))); + + delete (yystack_[0].value.identifier); + } +#line 1026 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 51: +#line 337 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Constant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZSharedVariantPointer(new ZSharedVariant())); + } +#line 1036 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 52: +#line 342 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant(*(yystack_[0].value.identifier), ZVariant::String)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Get); + } +#line 1047 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 53: +#line 348 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LeftAssign); + } +#line 1057 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 54: +#line 353 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Children); + } +#line 1067 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 55: +#line 358 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::AddAssign); + } +#line 1077 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 56: +#line 363 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::SubAssign); + } +#line 1087 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 57: +#line 368 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::MulAssign); + } +#line 1097 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 58: +#line 373 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::DivAssign); + } +#line 1107 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 59: +#line 378 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::AndAssign); + } +#line 1117 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 60: +#line 383 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::OrAssign); + } +#line 1127 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 61: +#line 388 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::XorAssign); + } +#line 1137 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 62: +#line 393 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::ModAssign); + } +#line 1147 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 63: +#line 398 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LOrAssign); + } +#line 1157 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 64: +#line 403 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LAndAssign); + } +#line 1167 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 65: +#line 408 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PrefixAddSelf); + } +#line 1177 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 66: +#line 413 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PrefixSubSelf); + } +#line 1187 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 67: +#line 420 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.value) = new ZSharedVariantPointer(ZCodeExecuter::createConstant(QByteArray(), ZVariant::Undefined)); + } +#line 1195 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 68: +#line 423 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.value) = new ZSharedVariantPointer(ZCodeExecuter::createConstant(*(yystack_[0].value.identifier), ZVariant::Int)); + + delete (yystack_[0].value.identifier); + } +#line 1205 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 69: +#line 428 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.value) = new ZSharedVariantPointer(ZCodeExecuter::createConstant(*(yystack_[0].value.identifier), ZVariant::String)); + + delete (yystack_[0].value.identifier); + } +#line 1215 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 70: +#line 433 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.value) = new ZSharedVariantPointer(ZCodeExecuter::createConstant(*(yystack_[0].value.identifier), ZVariant::Double)); + + delete (yystack_[0].value.identifier); + } +#line 1225 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 71: +#line 438 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.value) = new ZSharedVariantPointer(ZCodeExecuter::createConstant(*(yystack_[0].value.identifier), ZVariant::Bool)); + + delete (yystack_[0].value.identifier); + } +#line 1235 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 72: +#line 444 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Constant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, *(yystack_[0].value.value)); + + delete (yystack_[0].value.value); + } +#line 1247 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 73: +#line 451 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant(QByteArray::number((yystack_[1].value.count)), ZVariant::Int)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::JoinToList); + } +#line 1258 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 74: +#line 457 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant("1", ZVariant::Int)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::JoinToList); + } +#line 1269 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 75: +#line 463 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant("0", ZVariant::Int)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::JoinToList); + } +#line 1280 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 76: +#line 469 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + /// TODO + (yylhs.value.valueType) = ValueType::Constant; + } +#line 1289 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 77: +#line 473 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, ZCodeExecuter::createConstant(QByteArray::number((yystack_[1].value.count)), ZVariant::Int)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Call); + } +#line 1300 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 78: +#line 479 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value + *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Add); + } + } +#line 1321 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 79: +#line 495 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value - *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Sub); + } + } +#line 1342 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 80: +#line 511 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value * *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Mul); + } + } +#line 1363 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 81: +#line 527 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value / *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Div); + } + } +#line 1384 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 82: +#line 543 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value & *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::And); + } + } +#line 1405 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 83: +#line 559 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value | *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Or); + } + } +#line 1426 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 84: +#line 575 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value ^ *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Xor); + } + } +#line 1447 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 85: +#line 591 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value % *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Mod); + } + } +#line 1468 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 86: +#line 607 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value > *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Greater); + } + } +#line 1489 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 87: +#line 623 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value < *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Less); + } + } +#line 1510 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 88: +#line 639 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value == *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::EQ); + } + } +#line 1531 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 89: +#line 655 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value != *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::NEQ); + } + } +#line 1552 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 90: +#line 671 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(last_code->value->type() == pre_code->value->type() + && *last_code->value == *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::STEQ); + } + } +#line 1574 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 91: +#line 688 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(last_code->value->type() == pre_code->value->type() + && *last_code->value != *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::STNEQ); + } + } +#line 1596 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 92: +#line 705 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value <= *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LE); + } + } +#line 1617 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 93: +#line 721 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value >= *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::GE); + } + } +#line 1638 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 94: +#line 737 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value && *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LAnd); + } + } +#line 1659 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 95: +#line 753 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[2].value.valueType) == ValueType::Constant && (yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[2].value.valueType); + + ValueCode *pre_code = ZCodeExecuter::currentCodeExecuter->getCodeList().takeLast()->toValueCode(); + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(*last_code->value || *pre_code->value); + + delete pre_code; + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::LOr); + } + } +#line 1680 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 96: +#line 769 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[0].value.valueType); + + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(~ *last_code->value); + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Contrary); + } + } +#line 1698 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 97: +#line 782 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[0].value.valueType); + + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(! *last_code->value); + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Not); + } + } +#line 1716 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 98: +#line 795 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[0].value.valueType); + + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(- *last_code->value); + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Minus); + } + } +#line 1734 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 99: +#line 808 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if((yystack_[0].value.valueType) == ValueType::Constant) { + (yylhs.value.valueType) = (yystack_[0].value.valueType); + + ValueCode *last_code = ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode(); + + last_code->value = ZCodeExecuter::createConstantByValue(+ *last_code->value); + } else { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Abs); + } + } +#line 1752 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 100: +#line 821 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PostfixAddSelf); + } +#line 1762 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 101: +#line 826 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PostfixSubSelf); + } +#line 1772 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 102: +#line 831 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Append); + } +#line 1782 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 103: +#line 836 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + } +#line 1790 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 104: +#line 839 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { (yylhs.value.valueType) = (yystack_[1].value.valueType);} +#line 1796 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 105: +#line 840 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.valueType) = ValueType::Variant; + } +#line 1804 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 106: +#line 845 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = 0;} +#line 1810 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 107: +#line 846 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + {(yylhs.value.count) = 1;} +#line 1816 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 109: +#line 850 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, new ZSharedVariant(QString(*(yystack_[2].value.identifier)))); + + delete (yystack_[2].value.identifier); + + (yylhs.value.count) = 1; + } +#line 1828 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 110: +#line 857 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, new ZSharedVariant(QString(*(yystack_[2].value.identifier)))); + + delete (yystack_[2].value.identifier); + + (yylhs.value.count) = (yystack_[4].value.count) + 1; + } +#line 1840 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 111: +#line 866 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, new ZSharedVariant(0)); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::InitObjectProperty); + } +#line 1849 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 112: +#line 870 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Push, new ZSharedVariant((yystack_[1].value.count))); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::InitObjectProperty); + } +#line 1858 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 113: +#line 876 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + (yylhs.value.value) = Q_NULLPTR; + + ZCodeExecuter::currentCodeExecuter->beginCodeBlock(ZCodeExecuter::CodeBlock::If); + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::If, ZCodeExecuter::currentCodeExecuter->createConstant("", ZVariant::Undefined)); + + /// 存储if语句判断为假时要跳转到的指令位置 + (yylhs.value.value) = &ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode()->value; + } +#line 1872 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 114: +#line 885 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->beginCodeBlock(ZCodeExecuter::CodeBlock::While); + } +#line 1880 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 115: +#line 887 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::If, ZCodeExecuter::currentCodeExecuter->createConstant("", ZVariant::Undefined)); + + /// 存储if语句判断为假时要跳转到的指令位置 + (yylhs.value.value) = &ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode()->value; + } +#line 1891 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 116: +#line 893 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if(ZCodeExecuter::currentCodeExecuter->getCodeList().count() > 1 + && ZCodeExecuter::currentCodeExecuter->getCodeList().last()->action != ZCode::PopAll) + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PopAll); + + ZCodeExecuter::currentCodeExecuter->beginCodeBlock(ZCodeExecuter::CodeBlock::NormalFor); + } +#line 1903 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 117: +#line 899 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::If, ZCodeExecuter::currentCodeExecuter->createConstant("", ZVariant::Undefined)); + + /// 记录for循环的if指令在codeList中的index,方便修改if指令为假时要跳转到的指令位置 + ZCodeExecuter::currentCodeExecuter->getCodeBlock()->toLoopStructureCodeBlock()->ifInstructionIndex = ZCodeExecuter::currentCodeExecuter->getCodeList().count() - 1; + + /// 开启使用临时列表储存code + ZCodeExecuter::currentCodeExecuter->setEnableTmpCodeList(true); + } +#line 1917 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 118: +#line 907 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + /// 关闭使用临时列表储存code + ZCodeExecuter::currentCodeExecuter->setEnableTmpCodeList(false); + + int ifInstructionIndex = ZCodeExecuter::currentCodeExecuter->getCodeBlock()->toLoopStructureCodeBlock()->ifInstructionIndex; + + /// 将if语句的ValueCode的值传递到下一层,方便更改if语句判断为假时的跳转位置 + (yylhs.value.value) = &ZCodeExecuter::currentCodeExecuter->getCodeList().value(ifInstructionIndex)->toValueCode()->value; + } +#line 1931 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 123: +#line 926 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + if(ZCodeExecuter::currentCodeExecuter->getCodeBlock()->isLoopStructure()) { + QList &codeList = ZCodeExecuter::currentCodeExecuter->getCodeList(); + + /// 如果是普通的for循环结构 + if(ZCodeExecuter::currentCodeExecuter->getCodeBlock()->type == ZCodeExecuter::CodeBlock::NormalFor) { + QList &tmpCodeList = ZCodeExecuter::currentCodeExecuter->getTmpCodeList(); + + /// 记录在for循环中执行continue语句时要跳转到的目标位置 + *ZCodeExecuter::currentCodeExecuter->getCodeBlock()->toLoopStructureCodeBlock()->continueIndex.data() = codeList.count(); + + /// 将for循环的第三个表达式的指令从临时列表添加到codeList + while(!tmpCodeList.isEmpty()) { + codeList << tmpCodeList.takeAt(0); + } + + /// 清空栈 + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::PopAll); + } + + int index = ZCodeExecuter::currentCodeExecuter->getCodeBlock()->beginCodeIndex; + + /// 产生循环 + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Goto, ZCodeExecuter::currentCodeExecuter->createConstant(QByteArray::number(index), ZVariant::Int)); + + /// 保存执行break语句时跳转到的位置 + *ZCodeExecuter::currentCodeExecuter->getCodeBlock()->breakIndex.data() = codeList.count(); + } + + int index = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + + /// index为if判断结果为假时要跳转到的位置 + *(yystack_[1].value.value) = ZCodeExecuter::createConstant(QByteArray::number(index), ZVariant::Int); + (yylhs.value.value) = (yystack_[1].value.value); + + ZCodeExecuter::currentCodeExecuter->endCodeBlock(); + } +#line 1973 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 126: +#line 968 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + /// 如果if判断为真时会执行此goto指令,让其跳转到else代码块后面的语句 + ZCodeExecuter::currentCodeExecuter->appendCode(ZCode::Action::Goto, + ZCodeExecuter::createConstant("", ZVariant::Undefined)); + + int index = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + + /// 更改if判断为假时跳转到的位置 + *(yystack_[0].value.value) = ZCodeExecuter::createConstant(QByteArray::number(index), ZVariant::Int); + + (yystack_[0].value.value) = &ZCodeExecuter::currentCodeExecuter->getCodeList().last()->toValueCode()->value; + } +#line 1990 "zScript.tab.cpp" // lalr1.cc:859 + break; + + case 127: +#line 979 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:859 + { + int index = ZCodeExecuter::currentCodeExecuter->getCodeList().count(); + + /// index为if为真时跳转到的位置 + *(yystack_[2].value.value) = ZCodeExecuter::createConstant(QByteArray::number(index), ZVariant::Int); + } +#line 2001 "zScript.tab.cpp" // lalr1.cc:859 + break; + + +#line 2005 "zScript.tab.cpp" // lalr1.cc:859 + default: + break; + } + } + catch (const syntax_error& yyexc) + { + error (yyexc); + YYERROR; + } + YY_SYMBOL_PRINT ("-> $$ =", yylhs); + yypop_ (yylen); + yylen = 0; + YY_STACK_PRINT (); + + // Shift the result of the reduction. + yypush_ (YY_NULLPTR, yylhs); + } + goto yynewstate; + + /*--------------------------------------. + | yyerrlab -- here on detecting error. | + `--------------------------------------*/ + yyerrlab: + // If not already recovering from an error, report this error. + if (!yyerrstatus_) + { + ++yynerrs_; + error (yyla.location, yysyntax_error_ (yystack_[0].state, yyla)); + } + + + yyerror_range[1].location = yyla.location; + if (yyerrstatus_ == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + // Return failure if at end of input. + if (yyla.type_get () == yyeof_) + YYABORT; + else if (!yyla.empty ()) + { + yy_destroy_ ("Error: discarding", yyla); + yyla.clear (); + } + } + + // Else will try to reuse lookahead token after shifting the error token. + goto yyerrlab1; + + + /*---------------------------------------------------. + | yyerrorlab -- error raised explicitly by YYERROR. | + `---------------------------------------------------*/ + yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (false) + goto yyerrorlab; + yyerror_range[1].location = yystack_[yylen - 1].location; + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + yypop_ (yylen); + yylen = 0; + goto yyerrlab1; + + /*-------------------------------------------------------------. + | yyerrlab1 -- common code for both syntax error and YYERROR. | + `-------------------------------------------------------------*/ + yyerrlab1: + yyerrstatus_ = 3; // Each real token shifted decrements this. + { + stack_symbol_type error_token; + for (;;) + { + yyn = yypact_[yystack_[0].state]; + if (!yy_pact_value_is_default_ (yyn)) + { + yyn += yyterror_; + if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) + { + yyn = yytable_[yyn]; + if (0 < yyn) + break; + } + } + + // Pop the current state because it cannot handle the error token. + if (yystack_.size () == 1) + YYABORT; + + yyerror_range[1].location = yystack_[0].location; + yy_destroy_ ("Error: popping", yystack_[0]); + yypop_ (); + YY_STACK_PRINT (); + } + + yyerror_range[2].location = yyla.location; + YYLLOC_DEFAULT (error_token.location, yyerror_range, 2); + + // Shift the error token. + error_token.state = yyn; + yypush_ ("Shifting", error_token); + } + goto yynewstate; + + // Accept. + yyacceptlab: + yyresult = 0; + goto yyreturn; + + // Abort. + yyabortlab: + yyresult = 1; + goto yyreturn; + + yyreturn: + if (!yyla.empty ()) + yy_destroy_ ("Cleanup: discarding lookahead", yyla); + + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + yypop_ (yylen); + while (1 < yystack_.size ()) + { + yy_destroy_ ("Cleanup: popping", yystack_[0]); + yypop_ (); + } + + return yyresult; + } + catch (...) + { + YYCDEBUG << "Exception caught: cleaning lookahead and stack" + << std::endl; + // Do not try to display the values of the reclaimed symbols, + // as their printer might throw an exception. + if (!yyla.empty ()) + yy_destroy_ (YY_NULLPTR, yyla); + + while (1 < yystack_.size ()) + { + yy_destroy_ (YY_NULLPTR, yystack_[0]); + yypop_ (); + } + throw; + } + } + + void + parser::error (const syntax_error& yyexc) + { + error (yyexc.location, yyexc.what()); + } + + // Generate an error message. + std::string + parser::yysyntax_error_ (state_type yystate, const symbol_type& yyla) const + { + // Number of reported tokens (one for the "unexpected", one per + // "expected"). + size_t yycount = 0; + // Its maximum. + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + // Arguments of yyformat. + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yyla) is + if this state is a consistent state with a default action. + Thus, detecting the absence of a lookahead is sufficient to + determine that there is no unexpected or expected token to + report. In that case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is + a consistent state with a default action. There might have + been a previous inconsistent state, consistent state with a + non-default action, or user semantic action that manipulated + yyla. (However, yyla is currently not documented for users.) + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state + merging (from LALR or IELR) and default reductions corrupt the + expected token list. However, the list is correct for + canonical LR with one exception: it will still contain any + token that will not be accepted due to an error action in a + later state. + */ + if (!yyla.empty ()) + { + int yytoken = yyla.type_get (); + yyarg[yycount++] = yytname_[yytoken]; + int yyn = yypact_[yystate]; + if (!yy_pact_value_is_default_ (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + // Stay within bounds of both yycheck and yytname. + int yychecklim = yylast_ - yyn + 1; + int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; + for (int yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ + && !yy_table_value_is_error_ (yytable_[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + break; + } + else + yyarg[yycount++] = yytname_[yyx]; + } + } + } + + char const* yyformat = YY_NULLPTR; + switch (yycount) + { +#define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +#undef YYCASE_ + } + + std::string yyres; + // Argument number. + size_t yyi = 0; + for (char const* yyp = yyformat; *yyp; ++yyp) + if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) + { + yyres += yytnamerr_ (yyarg[yyi++]); + ++yyp; + } + else + yyres += *yyp; + return yyres; + } + + + const signed char parser::yypact_ninf_ = -122; + + const signed char parser::yytable_ninf_ = -67; + + const short int + parser::yypact_[] = + { + -30, -122, 228, -122, 2, 4, -52, -122, -47, -122, + 7, 46, -122, -122, -44, -25, -122, -122, -122, -122, + 46, 46, -14, -122, 46, 46, 46, 46, 395, 456, + -122, -122, -122, -19, -3, -39, -122, -122, -122, -3, + 3, 666, 667, -122, -122, -122, 372, 43, -122, -122, + 8, 12, -122, 46, -9, 46, -3, -122, 14, 714, + 916, 46, -122, 780, 830, 873, 11, -122, -45, -58, + -58, -58, -58, -122, -37, 618, -41, -40, 480, -30, + 0, -122, -122, 53, -122, 46, 21, 46, 46, 46, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, 46, 54, 46, 46, -122, -122, + -122, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 46, 46, 46, 46, -122, -122, 372, 46, 2, 529, + 46, 780, 23, -3, -122, 46, 46, 548, 46, 56, + -122, -122, -122, 57, -122, -122, 372, -122, -122, 33, + 372, -15, 715, 46, -22, -22, -22, -22, 149, 149, + 828, 828, 73, 73, 73, 149, 149, 200, 200, -58, + -58, -58, -122, 762, 14, 714, 5, 780, 780, 780, + 780, 780, 780, 780, 780, 780, 780, 780, 892, 780, + -122, 780, -122, -122, 597, 46, -122, 780, 780, -122, + 780, 28, -122, 13, 20, 32, -122, 42, -122, 372, + 666, -122, -122, -122, 780, 46, 46, -30, -122, -122, + -122, -122, -122, 666, 780, 298, 372, -122, -122, -122, + 46, 24, -122 + }; + + const unsigned char + parser::yydefact_[] = + { + 2, 4, 0, 1, 0, 0, 0, 114, 0, 67, + 0, 34, 19, 21, 0, 50, 68, 69, 71, 70, + 0, 0, 0, 14, 0, 0, 0, 0, 0, 37, + 15, 51, 3, 23, 0, 0, 13, 7, 103, 0, + 10, 0, 47, 72, 48, 105, 0, 125, 126, 6, + 40, 49, 76, 0, 0, 121, 0, 50, 36, 35, + 47, 0, 31, 0, 47, 47, 0, 111, 0, 98, + 99, 97, 96, 75, 0, 0, 50, 0, 0, 2, + 0, 18, 12, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 106, 8, 100, + 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 123, 124, 0, 0, 0, 0, + 0, 119, 122, 0, 5, 0, 0, 0, 0, 0, + 112, 73, 74, 0, 32, 104, 16, 20, 22, 0, + 0, 0, 47, 0, 88, 90, 89, 91, 92, 93, + 94, 95, 82, 83, 84, 86, 87, 79, 78, 80, + 81, 85, 52, 0, 108, 107, 0, 102, 58, 57, + 55, 56, 62, 59, 60, 61, 64, 63, 47, 53, + 127, 41, 42, 113, 0, 0, 116, 46, 45, 24, + 109, 0, 39, 0, 0, 0, 27, 0, 25, 0, + 0, 54, 77, 115, 120, 0, 0, 2, 17, 26, + 28, 30, 11, 0, 110, 0, 0, 117, 33, 29, + 121, 0, 118 + }; + + const signed char + parser::yypgoto_[] = + { + -122, -78, -20, -122, -122, -122, -18, -122, -122, -122, + -122, -46, -122, -122, -122, -122, -122, -122, -122, -24, + -122, -26, 64, -2, -38, -122, -122, -122, -122, -122, + -122, -122, -122, -122, -121, -122, -122, -122, -122 + }; + + const short int + parser::yydefgoto_[] = + { + -1, 2, 32, 86, 79, 204, 82, 33, 34, 35, + 36, 150, 151, 226, 37, 38, 203, 39, 77, 51, + 40, 58, 41, 60, 43, 44, 176, 68, 45, 46, + 54, 215, 230, 132, 133, 47, 48, 49, 126 + }; + + const short int + parser::yytable_[] = + { + 42, 146, 74, 149, 207, 139, 66, 91, 92, -38, + 143, 105, 106, 135, 107, 147, 148, 1, 64, 65, + 53, 84, 50, 108, 52, 55, 124, 56, 61, 62, + 140, 80, -38, 144, 141, 83, 98, 99, 134, 100, + 101, 102, 103, 104, 42, 9, 81, 105, 106, 4, + 107, 5, 125, 85, 16, 17, 18, 19, 9, 127, + 208, 67, 128, 130, 135, 138, 57, 16, 17, 18, + 19, 149, 153, 195, 172, 59, 201, 202, 212, 20, + 21, 174, 216, 152, 63, 63, 219, 217, 69, 70, + 71, 72, 75, 78, 22, 218, 220, 232, 87, 88, + 89, 90, 91, 92, 192, 209, 190, 24, 25, 231, + 0, 205, 0, 26, 27, 196, 28, 129, 29, 131, + 188, 0, 31, 0, 42, 137, 0, 0, 0, 0, + 206, 98, 99, 0, 100, 101, 102, 103, 104, 225, + 0, 0, 105, 106, 42, 107, 0, 0, 42, 63, + 0, 154, 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, 171, 0, + 173, 175, 0, 0, 0, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 63, 189, 0, 221, + 0, 191, 222, 0, 194, 0, 0, 0, 0, 197, + 198, 0, 200, 0, 0, 227, 229, 42, 0, 0, + 100, 101, 102, 103, 104, 0, 0, 210, 105, 106, + 0, 107, 0, 42, 42, 0, 0, 0, 3, 0, + 0, 4, 0, 5, 0, 0, 6, 0, 7, 8, + 9, 10, 11, 12, 13, 14, 0, 0, 15, 16, + 17, 18, 19, 0, 0, 0, 0, 0, 0, 214, + 0, 20, 21, 102, 103, 104, 0, 0, 0, 105, + 106, 0, 107, 0, 0, 0, 22, 23, 0, 223, + 224, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 25, 0, 0, 0, 131, 26, 27, 0, 28, 0, + 29, 4, 30, 5, 31, 0, 6, 0, 7, 8, + 9, 10, 11, 12, 13, 14, 0, 0, 15, 16, + 17, 18, 19, 0, 0, 0, 0, 0, 0, 0, + 0, 20, 21, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 22, 23, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 25, 0, 0, 0, 0, 26, 27, 0, 28, 0, + 29, 0, 30, 228, 31, 4, 0, 5, 0, 0, + 6, 0, 7, 8, 9, 10, 11, 12, 13, 14, + 0, 0, 15, 16, 17, 18, 19, 0, 4, 0, + 5, 0, 0, 0, 0, 20, 21, 9, 0, 0, + 0, 0, 0, 0, 0, 57, 16, 17, 18, 19, + 22, 23, 0, 0, 0, 0, 0, 0, 20, 21, + 0, 0, 0, 24, 25, 0, 0, 0, 0, 26, + 27, 0, 28, 22, 29, 0, 30, 0, 31, 0, + 0, 0, 0, 0, 0, 0, 24, 25, 0, 4, + 0, 5, 26, 27, 0, 28, 73, 29, 9, 0, + 0, 31, 0, 0, 0, 0, 76, 16, 17, 18, + 19, 0, 0, 0, 0, 0, 0, 0, 0, 20, + 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 22, 87, 88, 89, 90, 91, + 92, 93, 94, 0, 0, 0, 0, 24, 25, 0, + 0, 0, 0, 26, 27, 0, 28, 0, 29, 0, + 0, 0, 31, 0, 0, 95, 96, 97, 98, 99, + 0, 100, 101, 102, 103, 104, 0, 0, 0, 105, + 106, 0, 107, 145, 87, 88, 89, 90, 91, 92, + 93, 94, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 87, 88, 89, 90, 91, 92, 93, + 94, 0, 0, 0, 95, 96, 97, 98, 99, 0, + 100, 101, 102, 103, 104, 0, 0, 0, 105, 106, + 0, 107, 193, 95, 96, 97, 98, 99, 0, 100, + 101, 102, 103, 104, 0, 0, 0, 105, 106, 0, + 107, 199, 87, 88, 89, 90, 91, 92, 93, 94, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 87, 88, 89, 90, 91, 92, 93, + 94, 0, 95, 96, 97, 98, 99, 0, 100, 101, + 102, 103, 104, 0, 0, 0, 105, 106, 136, 107, + 213, 0, 0, 95, 96, 97, 98, 99, 0, 100, + 101, 102, 103, 104, 0, 0, 0, 105, 106, 142, + 107, 87, 88, 89, 90, 91, 92, 93, 94, 0, + 109, 110, 111, 0, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 0, 81, 0, 122, 123, 0, + 0, 95, 96, 97, 98, 99, 0, 100, 101, 102, + 103, 104, 0, 0, 0, 105, 106, 0, 107, 87, + 88, 89, 90, 91, 92, 93, 94, 0, 109, 110, + 111, 0, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 0, 0, 136, -44, -44, 0, 0, 95, + 96, 97, 98, 99, 0, 100, 101, 102, 103, 104, + 0, 0, 0, 105, 106, 0, 107, 87, 88, 89, + 90, 91, 92, 93, 94, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 87, 88, 89, 90, 91, + 92, 93, 94, 0, 0, 0, 0, 95, 96, 97, + 98, 99, 0, 100, 101, 102, 103, 104, 0, 0, + 0, 105, 106, 211, 107, 95, 96, 97, 98, 99, + 0, 100, 101, 102, 103, 104, 0, 0, 0, 105, + 106, 0, 107, 87, 88, 89, 90, 91, 92, 0, + 0, 0, 0, -65, -65, 111, 0, -65, -65, -65, + -65, -65, -65, -65, -65, -65, -65, 0, 0, -65, + -65, -65, 0, 95, 96, 97, 98, 99, 0, 100, + 101, 102, 103, 104, 0, 0, 0, 105, 106, 0, + 107, -65, 0, -65, 0, -65, -66, -66, 111, 0, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + 0, 0, -66, -66, -66, 109, 110, 111, 0, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 0, + 0, 0, -43, -43, -66, 0, -66, 0, -66, 109, + 110, 111, 0, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 0, 0, 0, 0, 123 + }; + + const short int + parser::yycheck_[] = + { + 2, 79, 28, 18, 19, 50, 20, 29, 30, 50, + 50, 69, 70, 50, 72, 15, 16, 47, 20, 21, + 72, 39, 20, 41, 20, 72, 46, 20, 72, 54, + 75, 50, 73, 73, 71, 74, 58, 59, 56, 61, + 62, 63, 64, 65, 46, 12, 49, 69, 70, 3, + 72, 5, 9, 50, 21, 22, 23, 24, 12, 51, + 75, 75, 50, 72, 50, 54, 20, 21, 22, 23, + 24, 18, 51, 50, 20, 11, 20, 20, 73, 33, + 34, 107, 54, 85, 20, 21, 54, 74, 24, 25, + 26, 27, 28, 29, 48, 75, 54, 73, 25, 26, + 27, 28, 29, 30, 128, 151, 126, 61, 62, 230, + -1, 149, -1, 67, 68, 133, 70, 53, 72, 55, + 122, -1, 76, -1, 126, 61, -1, -1, -1, -1, + 150, 58, 59, -1, 61, 62, 63, 64, 65, 217, + -1, -1, 69, 70, 146, 72, -1, -1, 150, 85, + -1, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, -1, + 106, 107, -1, -1, -1, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 120, 121, 122, 123, -1, 209, + -1, 127, 210, -1, 130, -1, -1, -1, -1, 135, + 136, -1, 138, -1, -1, 223, 226, 209, -1, -1, + 61, 62, 63, 64, 65, -1, -1, 153, 69, 70, + -1, 72, -1, 225, 226, -1, -1, -1, 0, -1, + -1, 3, -1, 5, -1, -1, 8, -1, 10, 11, + 12, 13, 14, 15, 16, 17, -1, -1, 20, 21, + 22, 23, 24, -1, -1, -1, -1, -1, -1, 195, + -1, 33, 34, 63, 64, 65, -1, -1, -1, 69, + 70, -1, 72, -1, -1, -1, 48, 49, -1, 215, + 216, -1, -1, -1, -1, -1, -1, -1, -1, 61, + 62, -1, -1, -1, 230, 67, 68, -1, 70, -1, + 72, 3, 74, 5, 76, -1, 8, -1, 10, 11, + 12, 13, 14, 15, 16, 17, -1, -1, 20, 21, + 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, + -1, 33, 34, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 48, 49, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 61, + 62, -1, -1, -1, -1, 67, 68, -1, 70, -1, + 72, -1, 74, 75, 76, 3, -1, 5, -1, -1, + 8, -1, 10, 11, 12, 13, 14, 15, 16, 17, + -1, -1, 20, 21, 22, 23, 24, -1, 3, -1, + 5, -1, -1, -1, -1, 33, 34, 12, -1, -1, + -1, -1, -1, -1, -1, 20, 21, 22, 23, 24, + 48, 49, -1, -1, -1, -1, -1, -1, 33, 34, + -1, -1, -1, 61, 62, -1, -1, -1, -1, 67, + 68, -1, 70, 48, 72, -1, 74, -1, 76, -1, + -1, -1, -1, -1, -1, -1, 61, 62, -1, 3, + -1, 5, 67, 68, -1, 70, 71, 72, 12, -1, + -1, 76, -1, -1, -1, -1, 20, 21, 22, 23, + 24, -1, -1, -1, -1, -1, -1, -1, -1, 33, + 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 48, 25, 26, 27, 28, 29, + 30, 31, 32, -1, -1, -1, -1, 61, 62, -1, + -1, -1, -1, 67, 68, -1, 70, -1, 72, -1, + -1, -1, 76, -1, -1, 55, 56, 57, 58, 59, + -1, 61, 62, 63, 64, 65, -1, -1, -1, 69, + 70, -1, 72, 73, 25, 26, 27, 28, 29, 30, + 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, + 32, -1, -1, -1, 55, 56, 57, 58, 59, -1, + 61, 62, 63, 64, 65, -1, -1, -1, 69, 70, + -1, 72, 73, 55, 56, 57, 58, 59, -1, 61, + 62, 63, 64, 65, -1, -1, -1, 69, 70, -1, + 72, 73, 25, 26, 27, 28, 29, 30, 31, 32, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 25, 26, 27, 28, 29, 30, 31, + 32, -1, 55, 56, 57, 58, 59, -1, 61, 62, + 63, 64, 65, -1, -1, -1, 69, 70, 50, 72, + 73, -1, -1, 55, 56, 57, 58, 59, -1, 61, + 62, 63, 64, 65, -1, -1, -1, 69, 70, 71, + 72, 25, 26, 27, 28, 29, 30, 31, 32, -1, + 33, 34, 35, -1, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, -1, 49, -1, 50, 51, -1, + -1, 55, 56, 57, 58, 59, -1, 61, 62, 63, + 64, 65, -1, -1, -1, 69, 70, -1, 72, 25, + 26, 27, 28, 29, 30, 31, 32, -1, 33, 34, + 35, -1, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, -1, -1, 50, 50, 51, -1, -1, 55, + 56, 57, 58, 59, -1, 61, 62, 63, 64, 65, + -1, -1, -1, 69, 70, -1, 72, 25, 26, 27, + 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 25, 26, 27, 28, 29, + 30, 31, 32, -1, -1, -1, -1, 55, 56, 57, + 58, 59, -1, 61, 62, 63, 64, 65, -1, -1, + -1, 69, 70, 71, 72, 55, 56, 57, 58, 59, + -1, 61, 62, 63, 64, 65, -1, -1, -1, 69, + 70, -1, 72, 25, 26, 27, 28, 29, 30, -1, + -1, -1, -1, 33, 34, 35, -1, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, -1, -1, 49, + 50, 51, -1, 55, 56, 57, 58, 59, -1, 61, + 62, 63, 64, 65, -1, -1, -1, 69, 70, -1, + 72, 71, -1, 73, -1, 75, 33, 34, 35, -1, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + -1, -1, 49, 50, 51, 33, 34, 35, -1, 37, + 38, 39, 40, 41, 42, 43, 44, 45, 46, -1, + -1, -1, 50, 51, 71, -1, 73, -1, 75, 33, + 34, 35, -1, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, -1, -1, -1, -1, 51 + }; + + const unsigned char + parser::yystos_[] = + { + 0, 47, 78, 0, 3, 5, 8, 10, 11, 12, + 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, + 33, 34, 48, 49, 61, 62, 67, 68, 70, 72, + 74, 76, 79, 84, 85, 86, 87, 91, 92, 94, + 97, 99, 100, 101, 102, 105, 106, 112, 113, 114, + 20, 96, 20, 72, 107, 72, 20, 20, 98, 99, + 100, 72, 54, 99, 100, 100, 20, 75, 104, 99, + 99, 99, 99, 71, 98, 99, 20, 95, 99, 81, + 50, 49, 83, 74, 83, 50, 80, 25, 26, 27, + 28, 29, 30, 31, 32, 55, 56, 57, 58, 59, + 61, 62, 63, 64, 65, 69, 70, 72, 83, 33, + 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 50, 51, 79, 9, 115, 51, 50, 99, + 72, 99, 110, 111, 83, 50, 50, 99, 54, 50, + 75, 71, 71, 50, 73, 73, 78, 15, 16, 18, + 88, 89, 100, 51, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 20, 99, 98, 99, 103, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 100, 99, + 79, 99, 96, 73, 99, 50, 83, 99, 99, 73, + 99, 20, 20, 93, 82, 101, 79, 19, 75, 88, + 99, 71, 73, 73, 99, 108, 54, 74, 75, 54, + 54, 79, 83, 99, 99, 78, 90, 83, 75, 79, + 109, 111, 73 + }; + + const unsigned char + parser::yyr1_[] = + { + 0, 77, 78, 78, 78, 79, 79, 79, 79, 79, + 80, 79, 79, 79, 79, 81, 82, 79, 83, 84, + 84, 85, 85, 85, 86, 87, 88, 89, 90, 89, + 89, 91, 93, 92, 94, 94, 94, 95, 95, 95, + 96, 96, 96, 97, 97, 98, 98, 99, 99, 100, + 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 100, 101, 101, 101, + 101, 101, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 103, 103, 103, 104, + 104, 105, 105, 106, 107, 106, 108, 109, 106, 110, + 110, 111, 111, 112, 113, 114, 115, 114 + }; + + const unsigned char + parser::yyr2_[] = + { + 0, 2, 0, 2, 1, 3, 1, 1, 2, 2, + 0, 5, 2, 1, 1, 0, 0, 5, 1, 1, + 3, 1, 3, 1, 4, 4, 3, 2, 0, 5, + 3, 2, 0, 7, 1, 2, 2, 0, 1, 3, + 1, 3, 3, 3, 3, 3, 3, 1, 1, 2, + 1, 1, 3, 3, 4, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 2, 2, 1, 1, 1, + 1, 1, 1, 3, 3, 2, 2, 4, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, + 2, 2, 3, 1, 3, 1, 0, 1, 1, 3, + 5, 2, 3, 4, 0, 5, 0, 0, 10, 1, + 3, 0, 1, 2, 2, 1, 0, 3 + }; + + + + // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + // First, the terminals, then, starting at \a yyntokens_, nonterminals. + const char* + const parser::yytname_[] = + { + "$end", "error", "$undefined", "VAR", "FUNCTION", "NEW", "DELETE", + "THROW", "IF", "ELSE", "WHILE", "FOR", "UNDEFINED", "GOTO", "RETURN", + "BREAK", "CONTINUE", "SWITCH", "CASE", "DEFAULT", "IDENTIFIER", "INT", + "STRING", "BOOL", "DOUBLE", "EQ", "STEQ", "NEQ", "STNEQ", "LE", "GE", + "LAND", "LOR", "ADDSELF", "SUBSELF", "LL", "GG", "DIVASSIGN", + "MULASSIGN", "ADDASSIGN", "SUBASSIGN", "MODASSIGN", "ANDASSIGN", + "ORASSIGN", "XORASSIGN", "LANDASSIGN", "LORASSIGN", "ERROR", + "NEW_OBJ_BEGIN", "';'", "','", "'='", "COMMA", "'?'", "':'", "'&'", + "'|'", "'^'", "'>'", "'<'", "LTGT", "'-'", "'+'", "'*'", "'/'", "'%'", + "UMINUS", "'!'", "'~'", "'.'", "'['", "']'", "'('", "')'", "'{'", "'}'", + "'_'", "$accept", "start", "code", "$@1", "$@2", "$@3", "ends", "break", + "loopEnds", "switch_head", "switch", "case", "cases", "$@4", + "goto_label", "function", "$@5", "return", "parameter", "define", + "tuple_lval", "tuple_exp", "expression", "lvalue", "const", "rvalue", + "arguments", "object_pro", "object", "branch_head", "$@6", "$@7", "$@8", + "for_exps", "for_exp", "branch_body", "branch_else", "conditional", + "$@9", YY_NULLPTR + }; + +#if YYDEBUG + const unsigned short int + parser::yyrline_[] = + { + 0, 82, 82, 82, 83, 90, 95, 96, 97, 102, + 105, 105, 116, 154, 155, 156, 165, 156, 174, 176, + 177, 181, 182, 183, 186, 194, 221, 226, 232, 232, + 239, 247, 262, 262, 281, 284, 285, 291, 292, 296, + 302, 306, 313, 317, 318, 321, 322, 325, 325, 327, + 330, 337, 342, 348, 353, 358, 363, 368, 373, 378, + 383, 388, 393, 398, 403, 408, 413, 420, 423, 428, + 433, 438, 444, 451, 457, 463, 469, 473, 479, 495, + 511, 527, 543, 559, 575, 591, 607, 623, 639, 655, + 671, 688, 705, 721, 737, 753, 769, 782, 795, 808, + 821, 826, 831, 836, 839, 840, 845, 846, 847, 850, + 857, 866, 870, 876, 885, 885, 893, 899, 893, 923, + 923, 924, 924, 926, 965, 967, 968, 968 + }; + + // Print the state stack on the debug stream. + void + parser::yystack_print_ () + { + *yycdebug_ << "Stack now"; + for (stack_type::const_iterator + i = yystack_.begin (), + i_end = yystack_.end (); + i != i_end; ++i) + *yycdebug_ << ' ' << i->state; + *yycdebug_ << std::endl; + } + + // Report on the debug stream that the rule \a yyrule is going to be reduced. + void + parser::yy_reduce_print_ (int yyrule) + { + unsigned int yylno = yyrline_[yyrule]; + int yynrhs = yyr2_[yyrule]; + // Print the symbols being reduced, and their result. + *yycdebug_ << "Reducing stack by rule " << yyrule - 1 + << " (line " << yylno << "):" << std::endl; + // The symbols being reduced. + for (int yyi = 0; yyi < yynrhs; yyi++) + YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", + yystack_[(yynrhs) - (yyi + 1)]); + } +#endif // YYDEBUG + + // Symbol number corresponding to token number t. + inline + parser::token_number_type + parser::yytranslate_ (int t) + { + static + const token_number_type + translate_table[] = + { + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 67, 2, 2, 2, 65, 55, 2, + 72, 73, 63, 62, 50, 61, 69, 64, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 54, 49, + 59, 51, 58, 53, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 70, 2, 71, 57, 76, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 74, 56, 75, 68, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 52, 60, 66 + }; + const unsigned int user_token_number_max_ = 306; + const token_number_type undef_token_ = 2; + + if (static_cast(t) <= yyeof_) + return yyeof_; + else if (static_cast (t) <= user_token_number_max_) + return translate_table[t]; + else + return undef_token_; + } + + +} // yy +#line 2737 "zScript.tab.cpp" // lalr1.cc:1167 +#line 985 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:1168 + + +int yyFlexLexer::yywrap() +{ + return 1; +} + +#undef yyFlexLexer + +void yy::parser::error(const location_type& loc, const std::string& msg) +{ + char lineStr[1000]; + + ZCodeExecuter::yyFlexLexer->yyin.seekg(-(int)loc.end.column - 1, std::ios::cur); + ZCodeExecuter::yyFlexLexer->yyin.getline(lineStr, 1000); + + std::cerr << lineStr << std::endl; + + for (uint i = 0; i < loc.begin.column; ++i) + std::cerr << " "; + + for (uint i = loc.begin.column; i < loc.end.column ; ++i) + std::cerr << "^"; + + std::cerr << std::endl; + std::cerr << "from " << loc.begin.line << " line " << loc.begin.column << " column, " + << "to " << loc.end.line << " line " << loc.end.column << " column, " << msg << std::endl; +} + +int yylex(yy::parser::semantic_type *lval, yy::parser::location_type *location) +{ + if (tokenQueue.isEmpty()) { + yylval = lval; + yyloc = location; + + return ZCodeExecuter::yyFlexLexer->yylex(); + } else { + *lval = tokenValQueue.dequeue(); + *location = tokenLocQueue.dequeue(); + + return tokenQueue.dequeue(); + } +} diff --git a/syntax/zScript.tab.hpp b/syntax/zScript.tab.hpp new file mode 100644 index 0000000..d28ecf6 --- /dev/null +++ b/syntax/zScript.tab.hpp @@ -0,0 +1,533 @@ +// A Bison parser, made by GNU Bison 3.0.4. + +// Skeleton interface for Bison LALR(1) parsers in C++ + +// Copyright (C) 2002-2015 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// As a special exception, you may create a larger work that contains +// part or all of the Bison parser skeleton and distribute that work +// under terms of your choice, so long as that work isn't itself a +// parser generator using the skeleton or a modified version thereof +// as a parser skeleton. Alternatively, if you modify or redistribute +// the parser skeleton itself, you may (at your option) remove this +// special exception, which will cause the skeleton and the resulting +// Bison output files to be licensed under the GNU General Public +// License without this special exception. + +// This special exception was added by the Free Software Foundation in +// version 2.2 of Bison. + +/** + ** \file zScript.tab.hpp + ** Define the yy::parser class. + */ + +// C++ LALR(1) parser skeleton written by Akim Demaille. + +#ifndef YY_YY_ZSCRIPT_TAB_HPP_INCLUDED +# define YY_YY_ZSCRIPT_TAB_HPP_INCLUDED + + +# include // std::abort +# include +# include +# include +# include +# include "stack.hh" +# include "location.hh" + + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif + + +namespace yy { +#line 114 "zScript.tab.hpp" // lalr1.cc:377 + + + + + + /// A Bison parser. + class parser + { + public: +#ifndef YYSTYPE + /// Symbol semantic values. + union semantic_type + { + #line 28 "/mnt/c/Users/zccrs/projects/zScript/syntax/zScript.yy" // lalr1.cc:377 + + int valueType; + quint16 count; + QByteArray *identifier; + ZSharedVariantPointer *value; + QVarLengthArray *parameterList; + QPair *caseKey; + QVector> *cases; + std::string *msg; + +#line 139 "zScript.tab.hpp" // lalr1.cc:377 + }; +#else + typedef YYSTYPE semantic_type; +#endif + /// Symbol locations. + typedef location location_type; + + /// Syntax errors thrown from user actions. + struct syntax_error : std::runtime_error + { + syntax_error (const location_type& l, const std::string& m); + location_type location; + }; + + /// Tokens. + struct token + { + enum yytokentype + { + VAR = 258, + FUNCTION = 259, + NEW = 260, + DELETE = 261, + THROW = 262, + IF = 263, + ELSE = 264, + WHILE = 265, + FOR = 266, + UNDEFINED = 267, + GOTO = 268, + RETURN = 269, + BREAK = 270, + CONTINUE = 271, + SWITCH = 272, + CASE = 273, + DEFAULT = 274, + IDENTIFIER = 275, + INT = 276, + STRING = 277, + BOOL = 278, + DOUBLE = 279, + EQ = 280, + STEQ = 281, + NEQ = 282, + STNEQ = 283, + LE = 284, + GE = 285, + LAND = 286, + LOR = 287, + ADDSELF = 288, + SUBSELF = 289, + LL = 290, + GG = 291, + DIVASSIGN = 292, + MULASSIGN = 293, + ADDASSIGN = 294, + SUBASSIGN = 295, + MODASSIGN = 296, + ANDASSIGN = 297, + ORASSIGN = 298, + XORASSIGN = 299, + LANDASSIGN = 300, + LORASSIGN = 301, + ERROR = 302, + NEW_OBJ_BEGIN = 303, + COMMA = 304, + LTGT = 305, + UMINUS = 306 + }; + }; + + /// (External) token type, as returned by yylex. + typedef token::yytokentype token_type; + + /// Symbol type: an internal symbol number. + typedef int symbol_number_type; + + /// The symbol type number to denote an empty symbol. + enum { empty_symbol = -2 }; + + /// Internal symbol number for tokens (subsumed by symbol_number_type). + typedef unsigned char token_number_type; + + /// A complete symbol. + /// + /// Expects its Base type to provide access to the symbol type + /// via type_get(). + /// + /// Provide access to semantic value and location. + template + struct basic_symbol : Base + { + /// Alias to Base. + typedef Base super_type; + + /// Default constructor. + basic_symbol (); + + /// Copy constructor. + basic_symbol (const basic_symbol& other); + + /// Constructor for valueless symbols. + basic_symbol (typename Base::kind_type t, + const location_type& l); + + /// Constructor for symbols with semantic value. + basic_symbol (typename Base::kind_type t, + const semantic_type& v, + const location_type& l); + + /// Destroy the symbol. + ~basic_symbol (); + + /// Destroy contents, and record that is empty. + void clear (); + + /// Whether empty. + bool empty () const; + + /// Destructive move, \a s is emptied into this. + void move (basic_symbol& s); + + /// The semantic value. + semantic_type value; + + /// The location. + location_type location; + + private: + /// Assignment operator. + basic_symbol& operator= (const basic_symbol& other); + }; + + /// Type access provider for token (enum) based symbols. + struct by_type + { + /// Default constructor. + by_type (); + + /// Copy constructor. + by_type (const by_type& other); + + /// The symbol type as needed by the constructor. + typedef token_type kind_type; + + /// Constructor from (external) token numbers. + by_type (kind_type t); + + /// Record that this symbol is empty. + void clear (); + + /// Steal the symbol type from \a that. + void move (by_type& that); + + /// The (internal) type number (corresponding to \a type). + /// \a empty when empty. + symbol_number_type type_get () const; + + /// The token. + token_type token () const; + + /// The symbol type. + /// \a empty_symbol when empty. + /// An int, not token_number_type, to be able to store empty_symbol. + int type; + }; + + /// "External" symbols: returned by the scanner. + typedef basic_symbol symbol_type; + + + /// Build a parser object. + parser (); + virtual ~parser (); + + /// Parse. + /// \returns 0 iff parsing succeeded. + virtual int parse (); + +#if YYDEBUG + /// The current debugging stream. + std::ostream& debug_stream () const YY_ATTRIBUTE_PURE; + /// Set the current debugging stream. + void set_debug_stream (std::ostream &); + + /// Type for debugging levels. + typedef int debug_level_type; + /// The current debugging level. + debug_level_type debug_level () const YY_ATTRIBUTE_PURE; + /// Set the current debugging level. + void set_debug_level (debug_level_type l); +#endif + + /// Report a syntax error. + /// \param loc where the syntax error is found. + /// \param msg a description of the syntax error. + virtual void error (const location_type& loc, const std::string& msg); + + /// Report a syntax error. + void error (const syntax_error& err); + + private: + /// This class is not copyable. + parser (const parser&); + parser& operator= (const parser&); + + /// State numbers. + typedef int state_type; + + /// Generate an error message. + /// \param yystate the state where the error occurred. + /// \param yyla the lookahead token. + virtual std::string yysyntax_error_ (state_type yystate, + const symbol_type& yyla) const; + + /// Compute post-reduction state. + /// \param yystate the current state + /// \param yysym the nonterminal to push on the stack + state_type yy_lr_goto_state_ (state_type yystate, int yysym); + + /// Whether the given \c yypact_ value indicates a defaulted state. + /// \param yyvalue the value to check + static bool yy_pact_value_is_default_ (int yyvalue); + + /// Whether the given \c yytable_ value indicates a syntax error. + /// \param yyvalue the value to check + static bool yy_table_value_is_error_ (int yyvalue); + + static const signed char yypact_ninf_; + static const signed char yytable_ninf_; + + /// Convert a scanner token number \a t to a symbol number. + static token_number_type yytranslate_ (int t); + + // Tables. + // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + // STATE-NUM. + static const short int yypact_[]; + + // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + // Performed when YYTABLE does not specify something else to do. Zero + // means the default is an error. + static const unsigned char yydefact_[]; + + // YYPGOTO[NTERM-NUM]. + static const signed char yypgoto_[]; + + // YYDEFGOTO[NTERM-NUM]. + static const short int yydefgoto_[]; + + // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + // positive, shift that token. If negative, reduce the rule whose + // number is the opposite. If YYTABLE_NINF, syntax error. + static const short int yytable_[]; + + static const short int yycheck_[]; + + // YYSTOS[STATE-NUM] -- The (internal number of the) accessing + // symbol of state STATE-NUM. + static const unsigned char yystos_[]; + + // YYR1[YYN] -- Symbol number of symbol that rule YYN derives. + static const unsigned char yyr1_[]; + + // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. + static const unsigned char yyr2_[]; + + + /// Convert the symbol name \a n to a form suitable for a diagnostic. + static std::string yytnamerr_ (const char *n); + + + /// For a symbol, its name in clear. + static const char* const yytname_[]; +#if YYDEBUG + // YYRLINE[YYN] -- Source line where rule number YYN was defined. + static const unsigned short int yyrline_[]; + /// Report on the debug stream that the rule \a r is going to be reduced. + virtual void yy_reduce_print_ (int r); + /// Print the state stack on the debug stream. + virtual void yystack_print_ (); + + // Debugging. + int yydebug_; + std::ostream* yycdebug_; + + /// \brief Display a symbol type, value and location. + /// \param yyo The output stream. + /// \param yysym The symbol. + template + void yy_print_ (std::ostream& yyo, const basic_symbol& yysym) const; +#endif + + /// \brief Reclaim the memory associated to a symbol. + /// \param yymsg Why this token is reclaimed. + /// If null, print nothing. + /// \param yysym The symbol. + template + void yy_destroy_ (const char* yymsg, basic_symbol& yysym) const; + + private: + /// Type access provider for state based symbols. + struct by_state + { + /// Default constructor. + by_state (); + + /// The symbol type as needed by the constructor. + typedef state_type kind_type; + + /// Constructor. + by_state (kind_type s); + + /// Copy constructor. + by_state (const by_state& other); + + /// Record that this symbol is empty. + void clear (); + + /// Steal the symbol type from \a that. + void move (by_state& that); + + /// The (internal) type number (corresponding to \a state). + /// \a empty_symbol when empty. + symbol_number_type type_get () const; + + /// The state number used to denote an empty symbol. + enum { empty_state = -1 }; + + /// The state. + /// \a empty when empty. + state_type state; + }; + + /// "Internal" symbol: element of the stack. + struct stack_symbol_type : basic_symbol + { + /// Superclass. + typedef basic_symbol super_type; + /// Construct an empty symbol. + stack_symbol_type (); + /// Steal the contents from \a sym to build this. + stack_symbol_type (state_type s, symbol_type& sym); + /// Assignment, needed by push_back. + stack_symbol_type& operator= (const stack_symbol_type& that); + }; + + /// Stack type. + typedef stack stack_type; + + /// The stack. + stack_type yystack_; + + /// Push a new state on the stack. + /// \param m a debug message to display + /// if null, no trace is output. + /// \param s the symbol + /// \warning the contents of \a s.value is stolen. + void yypush_ (const char* m, stack_symbol_type& s); + + /// Push a new look ahead token on the state on the stack. + /// \param m a debug message to display + /// if null, no trace is output. + /// \param s the state + /// \param sym the symbol (for its value and location). + /// \warning the contents of \a s.value is stolen. + void yypush_ (const char* m, state_type s, symbol_type& sym); + + /// Pop \a n symbols the three stacks. + void yypop_ (unsigned int n = 1); + + /// Constants. + enum + { + yyeof_ = 0, + yylast_ = 967, ///< Last index in yytable_. + yynnts_ = 39, ///< Number of nonterminal symbols. + yyfinal_ = 3, ///< Termination state number. + yyterror_ = 1, + yyerrcode_ = 256, + yyntokens_ = 77 ///< Number of tokens. + }; + + + }; + + + +} // yy +#line 529 "zScript.tab.hpp" // lalr1.cc:377 + + + + +#endif // !YY_YY_ZSCRIPT_TAB_HPP_INCLUDED