Index: configure.ac =================================================================== --- configure.ac.orig +++ configure.ac @@ -19,22 +19,24 @@ AC_PROG_YACC # Check bison version, substitute name for yychar bison_version=`bison -V | grep "^bison" | awk '{print $4}'` -bison_v=`echo $bison_version | awk 'BEGIN { FS="." } {printf "%d", $1*10+$2;}'` AC_MSG_RESULT([checking bison version: $bison_version]) -if test -n "$bison_v" && test "$bison_v" -lt 20 -then +case $bison_version in + 1.*) AC_MSG_ERROR([need a bison version >= 2.0]) -fi - -if test -n "$bison_v" && test "$bison_v" -eq 20 -then + ;; + 2.0|2.0.*) AC_MSG_RESULT([setting bison lalr1 yychar variable name to yylooka_]) AC_DEFINE(YYCHAR_NAME,yylooka_,[name of yychar lookahead var in bison lalr1.cc]) -else + ;; + 2.*) AC_MSG_RESULT([setting bison lalr1 yychar variable name to yylooka]) AC_DEFINE(YYCHAR_NAME,yylooka,[name of yychar lookahead var in bison lalr1.cc]) -fi + ;; + *) + AC_MSG_RESULT([setting bison lalr1 to use symbols]) + ;; +esac # Check for python AM_PATH_PYTHON(2.2,, :) Index: _NscLib/NscCompiler.cpp =================================================================== --- _NscLib/NscCompiler.cpp.orig +++ _NscLib/NscCompiler.cpp @@ -44,6 +44,9 @@ #include "NscSymbolTable.h" #include "NscCodeGenerator.h" +// "Import" token definitions. +typedef yy::parser::token token; + // // Globals // @@ -107,31 +110,31 @@ bool NscCompilerInitialize (CNwnLoader * // Add the reserved words // - NscAddToken ("int", INT_TYPE); - NscAddToken ("float", FLOAT_TYPE); - NscAddToken ("object", OBJECT_TYPE); - NscAddToken ("string", STRING_TYPE); - NscAddToken ("struct", STRUCT_TYPE); - NscAddToken ("void", VOID_TYPE); - NscAddToken ("vector", VECTOR_TYPE); - NscAddToken ("action", ACTION_TYPE); - - NscAddToken ("break", BREAK); - NscAddToken ("case", CASE); - NscAddToken ("continue", CONTINUE); - NscAddToken ("default", DEFAULT); - NscAddToken ("do", DO); - NscAddToken ("else", ELSE); - NscAddToken ("for", FOR); - NscAddToken ("if", IF); - NscAddToken ("return", RETURN); - NscAddToken ("switch", SWITCH); - NscAddToken ("while", WHILE); + NscAddToken ("int", token::INT_TYPE); + NscAddToken ("float", token::FLOAT_TYPE); + NscAddToken ("object", token::OBJECT_TYPE); + NscAddToken ("string", token::STRING_TYPE); + NscAddToken ("struct", token::STRUCT_TYPE); + NscAddToken ("void", token::VOID_TYPE); + NscAddToken ("vector", token::VECTOR_TYPE); + NscAddToken ("action", token::ACTION_TYPE); + + NscAddToken ("break", token::BREAK); + NscAddToken ("case", token::CASE); + NscAddToken ("continue", token::CONTINUE); + NscAddToken ("default", token::DEFAULT); + NscAddToken ("do", token::DO); + NscAddToken ("else", token::ELSE); + NscAddToken ("for", token::FOR); + NscAddToken ("if", token::IF); + NscAddToken ("return", token::RETURN); + NscAddToken ("switch", token::SWITCH); + NscAddToken ("while", token::WHILE); if (fEnableExtensions || nVersion >= 999) - NscAddToken ("const", NWCONST); + NscAddToken ("const", token::NWCONST); - NscAddToken ("OBJECT_SELF", OBJECT_SELF_CONST); - NscAddToken ("OBJECT_INVALID", OBJECT_INVALID_CONST); + NscAddToken ("OBJECT_SELF", token::OBJECT_SELF_CONST); + NscAddToken ("OBJECT_INVALID", token::OBJECT_INVALID_CONST); // // Read NWSCRIPT @@ -373,8 +376,7 @@ const char *NscGetActionName (int nActio // //---------------------------------------------------------------------------- -void yy::parser::error (const yy::parser::location_type& l, - const std::string& m) { +void yy::parser::error (const std::string& m) { context.yyerror(m.c_str()); } Index: _NscLib/NscContext.cpp =================================================================== --- _NscLib/NscContext.cpp.orig +++ _NscLib/NscContext.cpp @@ -43,6 +43,9 @@ #include "NscPStackEntry.h" #include "NscSymbolTable.h" +// "Import" token definitions. +typedef yy::parser::token token; + // // Externals // @@ -230,7 +233,7 @@ read_another_line:; if (pSymbol != NULL) { assert (pSymbol ->nSymType == NscSymType_Token); - if (pSymbol ->nToken == ENGINE_TYPE) + if (pSymbol ->nToken == token::ENGINE_TYPE) { CNscPStackEntry *pEntry = GetPStackEntry (__FILE__, __LINE__); pEntry ->SetType ((NscType) ( @@ -246,7 +249,7 @@ read_another_line:; CNscPStackEntry *pEntry = GetPStackEntry (__FILE__, __LINE__); pEntry ->SetIdentifier (pszStart, nCount); *yylval = pEntry; - return IDENTIFIER; + return token::IDENTIFIER; } } @@ -305,7 +308,7 @@ read_another_line:; pEntry ->SetType (NscType_Integer); pEntry ->PushConstantInteger (nValue); *yylval = pEntry; - return INTEGER_CONST; + return token::INTEGER_CONST; } // @@ -359,13 +362,13 @@ read_another_line:; { pEntry ->SetType (NscType_Float); pEntry ->PushConstantFloat ((float) atof (psz)); - return FLOAT_CONST; + return token::FLOAT_CONST; } else { pEntry ->SetType (NscType_Integer); pEntry ->PushConstantInteger (atol (psz)); - return INTEGER_CONST; + return token::INTEGER_CONST; } } } @@ -414,7 +417,7 @@ read_another_line:; else if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return DIVEQ; + return token::DIVEQ; } else { @@ -441,12 +444,12 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return ADDEQ; + return token::ADDEQ; } else if (c == '+') { m_pStreamTop ->pszNextTokenPos++; - return PLUSPLUS; + return token::PLUSPLUS; } else return '+'; @@ -457,12 +460,12 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return SUBEQ; + return token::SUBEQ; } else if (c == '-') { m_pStreamTop ->pszNextTokenPos++; - return MINUSMINUS; + return token::MINUSMINUS; } else return '-'; @@ -473,7 +476,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return MULEQ; + return token::MULEQ; } else return '*'; @@ -484,7 +487,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return MODEQ; + return token::MODEQ; } else return '%'; @@ -495,7 +498,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return XOREQ; + return token::XOREQ; } else return '^'; @@ -506,12 +509,12 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return ANDEQ; + return token::ANDEQ; } else if (c == '&') { m_pStreamTop ->pszNextTokenPos++; - return ANDAND; + return token::ANDAND; } else return '&'; @@ -522,12 +525,12 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return OREQ; + return token::OREQ; } else if (c == '|') { m_pStreamTop ->pszNextTokenPos++; - return OROR; + return token::OROR; } else return '|'; @@ -538,7 +541,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return NOTEQ; + return token::NOTEQ; } else return '!'; @@ -549,7 +552,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return EQ; + return token::EQ; } else return '='; @@ -560,7 +563,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return LTEQ; + return token::LTEQ; } else if (c == '<') { @@ -569,10 +572,10 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return SLEQ; + return token::SLEQ; } else - return SL; + return token::SL; } else return '<'; @@ -583,7 +586,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return GTEQ; + return token::GTEQ; } else if (c == '>') { @@ -592,7 +595,7 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return SREQ; + return token::SREQ; } else if (c == '>') { @@ -601,13 +604,13 @@ read_another_line:; if (c == '=') { m_pStreamTop ->pszNextTokenPos++; - return USREQ; + return token::USREQ; } else - return USR; + return token::USR; } else - return SR; + return token::SR; } else return '>'; @@ -626,7 +629,7 @@ read_another_line:; pEntry ->SetType (NscType_String); pEntry ->PushConstantString (pszStart, (int) (pszOut - pszStart)); *yylval = pEntry; - return STRING_CONST; + return token::STRING_CONST; } else if (c == '\\') { @@ -646,7 +649,7 @@ read_another_line:; pEntry ->PushConstantString (pszStart, (int) (pszOut - pszStart)); *yylval = pEntry; GenerateError ("Unterminated string"); - return STRING_CONST; + return token::STRING_CONST; } else *pszOut++ = c; @@ -898,7 +901,7 @@ try_again:; { NscSymbol *pSymbol = g_sNscReservedWords .Add ( pszVTmp, NscSymType_Token); - pSymbol ->nToken = ENGINE_TYPE; + pSymbol ->nToken = token::ENGINE_TYPE; pSymbol ->nEngineObject = nIndex; } } Index: _NscLib/NscParser.ypp =================================================================== --- _NscLib/NscParser.ypp.orig +++ _NscLib/NscParser.ypp @@ -273,15 +273,15 @@ shift_expression: } | shift_expression SL additive_expression { - $$ = NscBuildBinaryOp (SL, $1, $3); + $$ = NscBuildBinaryOp (token::SL, $1, $3); } | shift_expression SR additive_expression { - $$ = NscBuildBinaryOp (SR, $1, $3); + $$ = NscBuildBinaryOp (token::SR, $1, $3); } | shift_expression USR additive_expression { - $$ = NscBuildBinaryOp (USR, $1, $3); + $$ = NscBuildBinaryOp (token::USR, $1, $3); } ; @@ -300,11 +300,11 @@ relational_expression: } | relational_expression LTEQ shift_expression { - $$ = NscBuildBinaryOp (LTEQ, $1, $3); + $$ = NscBuildBinaryOp (token::LTEQ, $1, $3); } | relational_expression GTEQ shift_expression { - $$ = NscBuildBinaryOp (GTEQ, $1, $3); + $$ = NscBuildBinaryOp (token::GTEQ, $1, $3); } ; @@ -315,11 +315,11 @@ equality_expression: } | equality_expression EQ relational_expression { - $$ = NscBuildBinaryOp (EQ, $1, $3); + $$ = NscBuildBinaryOp (token::EQ, $1, $3); } | equality_expression NOTEQ relational_expression { - $$ = NscBuildBinaryOp (NOTEQ, $1, $3); + $$ = NscBuildBinaryOp (token::NOTEQ, $1, $3); } ; @@ -363,7 +363,7 @@ logical_and_expression: } | logical_and_expression ANDAND inclusive_or_expression { - $$ = NscBuildLogicalOp (ANDAND, $1, $3); + $$ = NscBuildLogicalOp (token::ANDAND, $1, $3); } ; @@ -374,7 +374,7 @@ logical_or_expression: } | logical_or_expression OROR logical_and_expression { - $$ = NscBuildLogicalOp (OROR, $1, $3); + $$ = NscBuildLogicalOp (token::OROR, $1, $3); } ; @@ -400,47 +400,47 @@ assignment_expression: } | unary_expression MULEQ assignment_expression { - $$ = NscBuildBinaryOp (MULEQ, $1, $3); + $$ = NscBuildBinaryOp (token::MULEQ, $1, $3); } | unary_expression DIVEQ assignment_expression { - $$ = NscBuildBinaryOp (DIVEQ, $1, $3); + $$ = NscBuildBinaryOp (token::DIVEQ, $1, $3); } | unary_expression MODEQ assignment_expression { - $$ = NscBuildBinaryOp (MODEQ, $1, $3); + $$ = NscBuildBinaryOp (token::MODEQ, $1, $3); } | unary_expression ADDEQ assignment_expression { - $$ = NscBuildBinaryOp (ADDEQ, $1, $3); + $$ = NscBuildBinaryOp (token::ADDEQ, $1, $3); } | unary_expression SUBEQ assignment_expression { - $$ = NscBuildBinaryOp (SUBEQ, $1, $3); + $$ = NscBuildBinaryOp (token::SUBEQ, $1, $3); } | unary_expression SLEQ assignment_expression { - $$ = NscBuildBinaryOp (SLEQ, $1, $3); + $$ = NscBuildBinaryOp (token::SLEQ, $1, $3); } | unary_expression SREQ assignment_expression { - $$ = NscBuildBinaryOp (SREQ, $1, $3); + $$ = NscBuildBinaryOp (token::SREQ, $1, $3); } | unary_expression USREQ assignment_expression { - $$ = NscBuildBinaryOp (USREQ, $1, $3); + $$ = NscBuildBinaryOp (token::USREQ, $1, $3); } | unary_expression ANDEQ assignment_expression { - $$ = NscBuildBinaryOp (ANDEQ, $1, $3); + $$ = NscBuildBinaryOp (token::ANDEQ, $1, $3); } | unary_expression XOREQ assignment_expression { - $$ = NscBuildBinaryOp (XOREQ, $1, $3); + $$ = NscBuildBinaryOp (token::XOREQ, $1, $3); } | unary_expression OREQ assignment_expression { - $$ = NscBuildBinaryOp (OREQ, $1, $3); + $$ = NscBuildBinaryOp (token::OREQ, $1, $3); } ; @@ -480,39 +480,39 @@ qualified_type_specifier: type_specifier: VOID_TYPE { - $$ = NscBuildType (VOID_TYPE, NULL); + $$ = NscBuildType (token::VOID_TYPE, NULL); } | INT_TYPE { - $$ = NscBuildType (INT_TYPE, NULL); + $$ = NscBuildType (token::INT_TYPE, NULL); } | FLOAT_TYPE { - $$ = NscBuildType (FLOAT_TYPE, NULL); + $$ = NscBuildType (token::FLOAT_TYPE, NULL); } | OBJECT_TYPE { - $$ = NscBuildType (OBJECT_TYPE, NULL); + $$ = NscBuildType (token::OBJECT_TYPE, NULL); } | STRING_TYPE { - $$ = NscBuildType (STRING_TYPE, NULL); + $$ = NscBuildType (token::STRING_TYPE, NULL); } | ACTION_TYPE { - $$ = NscBuildType (ACTION_TYPE, NULL); + $$ = NscBuildType (token::ACTION_TYPE, NULL); } | VECTOR_TYPE { - $$ = NscBuildType (VECTOR_TYPE, NULL); + $$ = NscBuildType (token::VECTOR_TYPE, NULL); } | struct_type_start IDENTIFIER { - $$ = NscBuildType (STRUCT_TYPE, $2); + $$ = NscBuildType (token::STRUCT_TYPE, $2); } | ENGINE_TYPE { - $$ = NscBuildType (ENGINE_TYPE, $1); + $$ = NscBuildType (token::ENGINE_TYPE, $1); } ; @@ -600,11 +600,11 @@ labeled_statement: case_statement: CASE { NscBuildSaveLine (0); } constant_expression ':' { - $$ = NscBuildCase (CASE, $3); + $$ = NscBuildCase (token::CASE, $3); } | DEFAULT { NscBuildSaveLine (0); } ':' { - $$ = NscBuildCase (DEFAULT, NULL); + $$ = NscBuildCase (token::DEFAULT, NULL); } ; @@ -657,6 +657,7 @@ expression_statement: | error { $$ = NULL; +#ifdef YYCHAR_NAME if (NscBuildSyntaxError (YYCHAR_NAME, yylval)) YYABORT; while (YYCHAR_NAME != EOF && YYCHAR_NAME != ';' && YYCHAR_NAME != '{' && YYCHAR_NAME != '}') @@ -668,6 +669,18 @@ expression_statement: } if (YYCHAR_NAME == ';') YYCHAR_NAME = yyempty_; +#else + if (NscBuildSyntaxError (yyla.type, yyla.value)) + YYABORT; + while (yyla.type != EOF && yyla.type != ';' && yyla.type != '{' && yyla.type != '}') + { + if (yyla.value != NULL) + yyla.value; //FIXME + yyla.type = yytranslate_ (yylex (&yyla.value, context)); + } + if (yyla.type == ';') + yyla.clear (); +#endif // YYCHAR_NAME } ; @@ -680,15 +693,15 @@ expression_statement: selection_statement: if_start statement_blank_error { - $$ = NscBuild5Block (IF, $1, 0, NULL, NULL, NULL, $2, NULL); + $$ = NscBuild5Block (token::IF, $1, 0, NULL, NULL, NULL, $2, NULL); } | if_else_start statement_blank_error { - $$ = NscBuild5Block (IF, $1, 0, NULL, NULL, NULL, NULL, $2); + $$ = NscBuild5Block (token::IF, $1, 0, NULL, NULL, NULL, NULL, $2); } | switch_start statement { - $$ = NscBuild5Block (SWITCH, $1, 0, NULL, NULL, NULL, $2, NULL); + $$ = NscBuild5Block (token::SWITCH, $1, 0, NULL, NULL, NULL, $2, NULL); } ; @@ -696,21 +709,21 @@ if_else_start: if_start statement_blank_error ELSE { NscBuildSaveLine (0); - $$ = NscBuild5Block (IF, $1, 1, NULL, NULL, NULL, $2, NULL); + $$ = NscBuild5Block (token::IF, $1, 1, NULL, NULL, NULL, $2, NULL); } ; if_start: IF '(' { NscBuildSaveLine (0); } expression ')' { - $$ = NscBuild5Block (IF, NULL, 1, NULL, $4, NULL, NULL, NULL); + $$ = NscBuild5Block (token::IF, NULL, 1, NULL, $4, NULL, NULL, NULL); } ; switch_start: SWITCH { NscBuildSaveLine (0); } '(' expression ')' { - $$ = NscBuild5Block (SWITCH, NULL, 1, NULL, $4, NULL, NULL, NULL); + $$ = NscBuild5Block (token::SWITCH, NULL, 1, NULL, $4, NULL, NULL, NULL); } ; @@ -723,50 +736,50 @@ switch_start: iteration_statement: while_start statement { - $$ = NscBuild5Block (WHILE, $1, 0, NULL, NULL, NULL, $2, NULL); + $$ = NscBuild5Block (token::WHILE, $1, 0, NULL, NULL, NULL, $2, NULL); } | do_start statement WHILE { NscBuildSaveLine (0); } '(' expression ')' ';' { - $$ = NscBuild5Block (DO, $1, 0, NULL, $6, NULL, $2, NULL); + $$ = NscBuild5Block (token::DO, $1, 0, NULL, $6, NULL, $2, NULL); } | for_start statement { - $$ = NscBuild5Block (FOR, $1, 0, NULL, NULL, NULL, $2, NULL); + $$ = NscBuild5Block (token::FOR, $1, 0, NULL, NULL, NULL, $2, NULL); } ; for_start: for_start_start ';' ';' ')' { - $$ = NscBuild5Block (FOR, NULL, 1, NULL, NULL, NULL, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, NULL, NULL, NULL, NULL); } | for_start_start expression ';' ';' ')' { - $$ = NscBuild5Block (FOR, NULL, 1, $2, NULL, NULL, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, $2, NULL, NULL, NULL, NULL); } | for_start_start ';' expression ';' ')' { - $$ = NscBuild5Block (FOR, NULL, 1, NULL, $3, NULL, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, $3, NULL, NULL, NULL); } | for_start_start expression ';' expression ';' ')' { - $$ = NscBuild5Block (FOR, NULL, 1, $2, $4, NULL, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, $2, $4, NULL, NULL, NULL); } | for_start_start ';' ';' expression ')' { - $$ = NscBuild5Block (FOR, NULL, 1, NULL, NULL, $4, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, NULL, $4, NULL, NULL); } | for_start_start expression ';' ';' expression ')' { - $$ = NscBuild5Block (FOR, NULL, 1, $2, NULL, $5, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, $2, NULL, $5, NULL, NULL); } | for_start_start ';' expression ';' expression ')' { - $$ = NscBuild5Block (FOR, NULL, 1, NULL, $3, $5, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, $3, $5, NULL, NULL); } | for_start_start expression ';' expression ';' expression ')' { - $$ = NscBuild5Block (FOR, NULL, 1, $2, $4, $6, NULL, NULL); + $$ = NscBuild5Block (token::FOR, NULL, 1, $2, $4, $6, NULL, NULL); } ; @@ -780,14 +793,14 @@ for_start_start: while_start: WHILE '(' { NscBuildSaveLine (0); } expression ')' { - $$ = NscBuild5Block (WHILE, NULL, 1, NULL, $4, NULL, NULL, NULL); + $$ = NscBuild5Block (token::WHILE, NULL, 1, NULL, $4, NULL, NULL, NULL); } ; do_start: DO { - $$ = NscBuild5Block (DO, NULL, 1, NULL, NULL, NULL, NULL, NULL); + $$ = NscBuild5Block (token::DO, NULL, 1, NULL, NULL, NULL, NULL, NULL); } ; @@ -800,11 +813,11 @@ do_start: jump_statement: CONTINUE { NscBuildSaveLine (0); } ';' { - $$ = NscBuildBreakContinue (CONTINUE); + $$ = NscBuildBreakContinue (token::CONTINUE); } | BREAK { NscBuildSaveLine (0); } ';' { - $$ = NscBuildBreakContinue (BREAK); + $$ = NscBuildBreakContinue (token::BREAK); } | return_start ';' { @@ -984,6 +997,7 @@ translation_unit: | error { $$ = NULL; +#ifdef YYCHAR_NAME if (NscBuildSyntaxError (YYCHAR_NAME, yylval)) YYABORT; while (YYCHAR_NAME != EOF && YYCHAR_NAME != ';' && YYCHAR_NAME != '{' && YYCHAR_NAME != '}') @@ -994,6 +1008,17 @@ translation_unit: YYCHAR_NAME = yylex (&yylval, context); } YYCHAR_NAME = yyempty_; +#else + if (NscBuildSyntaxError (yyla.type, yyla.value)) + YYABORT; + while (yyla.type != EOF && yyla.type != ';' && yyla.type != '{' && yyla.type != '}') + { + if (yyla.value != NULL) + yyla.value; //FIXME + yyla.type = yytranslate_ (yylex (&yyla.value, context)); + } + yyla.clear (); +#endif // YYCHAR_NAME } ; Index: _NscLib/NscParserRoutines.cpp =================================================================== --- _NscLib/NscParserRoutines.cpp.orig +++ _NscLib/NscParserRoutines.cpp @@ -43,6 +43,9 @@ #include "NscPStackEntry.h" #include "NscSymbolTable.h" +// "Import" token definitions. +typedef yy::parser::token token; + // // Externals // @@ -396,142 +399,142 @@ bool NscBuildSyntaxError (int nToken, YY switch (nToken) { - case IDENTIFIER: + case token::IDENTIFIER: if (yylval) pszToken = yylval ->GetIdentifier (); else pszToken = "identifier"; break; - case INTEGER_CONST: + case token::INTEGER_CONST: pszToken = "integer constant"; break; - case FLOAT_CONST: + case token::FLOAT_CONST: pszToken = "float constant"; break; - case STRING_CONST: + case token::STRING_CONST: pszToken = "string constant"; break; - case ADDEQ: + case token::ADDEQ: pszToken = "+="; break; - case SUBEQ: + case token::SUBEQ: pszToken = "-="; break; - case MULEQ: + case token::MULEQ: pszToken = "*="; break; - case DIVEQ: + case token::DIVEQ: pszToken = "/="; break; - case MODEQ: + case token::MODEQ: pszToken = "%="; break; - case XOREQ: + case token::XOREQ: pszToken = "^="; break; - case ANDEQ: + case token::ANDEQ: pszToken = "&="; break; - case OREQ: + case token::OREQ: pszToken = "|="; break; - case SL: + case token::SL: pszToken = "<<"; break; - case SR: + case token::SR: pszToken = ">>"; break; - case USR: + case token::USR: pszToken = ">>>"; break; - case SLEQ: + case token::SLEQ: pszToken = "<<="; break; - case SREQ: + case token::SREQ: pszToken = ">>="; break; - case USREQ: + case token::USREQ: pszToken = ">>>="; break; - case EQ: + case token::EQ: pszToken = "=="; break; - case NOTEQ: + case token::NOTEQ: pszToken = "!="; break; - case LTEQ: + case token::LTEQ: pszToken = "<="; break; - case GTEQ: + case token::GTEQ: pszToken = ">="; break; - case ANDAND: + case token::ANDAND: pszToken = "&&"; break; - case OROR: + case token::OROR: pszToken = "||"; break; - case PLUSPLUS: + case token::PLUSPLUS: pszToken = "++"; break; - case MINUSMINUS: + case token::MINUSMINUS: pszToken = "--"; break; - case FLOAT_TYPE: + case token::FLOAT_TYPE: pszToken = "float"; break; - case INT_TYPE: + case token::INT_TYPE: pszToken = "int"; break; - case OBJECT_TYPE: + case token::OBJECT_TYPE: pszToken = "object"; break; - case STRING_TYPE: + case token::STRING_TYPE: pszToken = "string"; break; - case VOID_TYPE: + case token::VOID_TYPE: pszToken = "void"; break; - case STRUCT_TYPE: + case token::STRUCT_TYPE: pszToken = "struct"; break; - case VECTOR_TYPE: + case token::VECTOR_TYPE: pszToken = "vector"; break; - case ENGINE_TYPE: + case token::ENGINE_TYPE: if (yylval) { int nIndex = yylval ->GetType () - NscType_Engine_0; @@ -541,63 +544,63 @@ bool NscBuildSyntaxError (int nToken, YY pszToken = "engine-type"; break; - case ACTION_TYPE: + case token::ACTION_TYPE: pszToken = "action"; break; - case OBJECT_SELF_CONST: + case token::OBJECT_SELF_CONST: pszToken = "OBJECT_SELF"; break; - case OBJECT_INVALID_CONST: + case token::OBJECT_INVALID_CONST: pszToken = "OBJECT_INVALID"; break; - case BREAK: + case token::BREAK: pszToken = "break"; break; - case CASE: + case token::CASE: pszToken = "case"; break; - case CONTINUE: + case token::CONTINUE: pszToken = "continue"; break; - case DEFAULT: + case token::DEFAULT: pszToken = "default"; break; - case DO: + case token::DO: pszToken = "do"; break; - case ELSE: + case token::ELSE: pszToken = "else"; break; - case FOR: + case token::FOR: pszToken = "for"; break; - case IF: + case token::IF: pszToken = "if"; break; - case RETURN: + case token::RETURN: pszToken = "return"; break; - case SWITCH: + case token::SWITCH: pszToken = "switch"; break; - case WHILE: + case token::WHILE: pszToken = "while"; break; - case NWCONST: + case token::NWCONST: pszToken = "const"; break; @@ -657,31 +660,31 @@ YYSTYPE NscBuildType (int nType, YYSTYPE switch (nType) { - case VOID_TYPE: + case token::VOID_TYPE: pOut ->SetType (NscType_Void); break; - case INT_TYPE: + case token::INT_TYPE: pOut ->SetType (NscType_Integer); break; - case FLOAT_TYPE: + case token::FLOAT_TYPE: pOut ->SetType (NscType_Float); break; - case OBJECT_TYPE: + case token::OBJECT_TYPE: pOut ->SetType (NscType_Object); break; - case STRING_TYPE: + case token::STRING_TYPE: pOut ->SetType (NscType_String); break; - case VECTOR_TYPE: + case token::VECTOR_TYPE: pOut ->SetType (NscType_Vector); break; - case ACTION_TYPE: + case token::ACTION_TYPE: if (!g_pCtx ->IsNWScript ()) { g_pCtx ->GenerateError ("\"action\" identifier only " @@ -692,7 +695,7 @@ YYSTYPE NscBuildType (int nType, YYSTYPE pOut ->SetType (NscType_Action); break; - case STRUCT_TYPE: + case token::STRUCT_TYPE: assert (pId != NULL); { if (!g_pCtx ->IsPhase2 () && !g_pCtx ->IsNWScript ()) @@ -723,7 +726,7 @@ YYSTYPE NscBuildType (int nType, YYSTYPE } break; - case ENGINE_TYPE: + case token::ENGINE_TYPE: assert (pId != NULL); { pOut ->SetType (pId ->GetType ()); @@ -2923,7 +2926,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case SL: + case token::SL: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { if (g_pCtx ->GetOptExpression () && @@ -2948,7 +2951,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case SR: + case token::SR: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { #ifdef NOT_ENABLED_YET @@ -2975,7 +2978,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case USR: + case token::USR: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { #ifdef NOT_ENABLED_YET @@ -3086,7 +3089,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case LTEQ: + case token::LTEQ: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { if (g_pCtx ->GetOptExpression () && @@ -3128,7 +3131,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case GTEQ: + case token::GTEQ: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { if (g_pCtx ->GetOptExpression () && @@ -3170,7 +3173,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case EQ: + case token::EQ: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { if (g_pCtx ->GetOptExpression () && @@ -3260,7 +3263,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case NOTEQ: + case token::NOTEQ: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { if (g_pCtx ->GetOptExpression () && @@ -3440,7 +3443,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case MULEQ: + case token::MULEQ: if (nLhsType == NscType_Vector && nRhsType == NscType_Float) { NscPushAssignment (pOut, NscPCode_AsnMultiply, @@ -3468,7 +3471,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case DIVEQ: + case token::DIVEQ: if (nLhsType == NscType_Vector && nRhsType == NscType_Float) { NscPushAssignment (pOut, NscPCode_AsnDivide, @@ -3496,7 +3499,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case MODEQ: + case token::MODEQ: if (nLhsType == NscType_Integer && nRhsType == NscType_Integer) { NscPushAssignment (pOut, NscPCode_AsnModulus, @@ -3509,7 +3512,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case ADDEQ: + case token::ADDEQ: if (nLhsType == NscType_Vector && nRhsType == NscType_Vector) { NscPushAssignment (pOut, NscPCode_AsnAdd, @@ -3542,7 +3545,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case SUBEQ: + case token::SUBEQ: if (nLhsType == NscType_Vector && nRhsType == NscType_Vector) { NscPushAssignment (pOut, NscPCode_AsnSubtract, @@ -3570,7 +3573,7 @@ YYSTYPE NscBuildBinaryOp (int nToken, YY } break; - case SLEQ: + case token::SLEQ: pszOp = "<<="; nOp = NscPCode_AsnShiftLeft; asn_shift_operator:; @@ -3586,17 +3589,17 @@ asn_shift_operator:; } break; - case SREQ: + case token::SREQ: pszOp = ">>="; nOp = NscPCode_AsnShiftRight; goto asn_shift_operator; - case USREQ: + case token::USREQ: pszOp = ">>>="; nOp = NscPCode_AsnUnsignedShiftRight; goto asn_shift_operator; - case ANDEQ: + case token::ANDEQ: pszOp = "&="; nOp = NscPCode_AsnBitwiseAND; asn_bitwise_expression:; @@ -3612,12 +3615,12 @@ asn_bitwise_expression:; } break; - case XOREQ: + case token::XOREQ: pszOp = "^="; nOp = NscPCode_AsnBitwiseXOR; goto asn_bitwise_expression; - case OREQ: + case token::OREQ: pszOp = "|="; nOp = NscPCode_AsnBitwiseOR; goto asn_bitwise_expression; @@ -3696,12 +3699,12 @@ YYSTYPE NscBuildLogicalOp (int nToken, Y const char *pszOp; NscPCode nOp; - if (nToken == ANDAND) + if (nToken == token::ANDAND) { pszOp = "&&"; nOp = NscPCode_LogicalAND; } - else if (nToken == OROR) + else if (nToken == token::OROR) { pszOp = "||"; nOp = NscPCode_LogicalOR; @@ -3750,12 +3753,12 @@ YYSTYPE NscBuildLogicalOp (int nToken, Y // If the operation is known to be true or false by the lhs // - else if (nToken == ANDAND && nLhsConstant == 0) + else if (nToken == token::ANDAND && nLhsConstant == 0) { pOut ->PushConstantInteger (0); pOut ->SetType (NscType_Integer); } - else if (nToken == OROR && nLhsConstant == 1) + else if (nToken == token::OROR && nLhsConstant == 1) { pOut ->PushConstantInteger (1); pOut ->SetType (NscType_Integer); @@ -4706,7 +4709,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST bool fCheckCond; switch (nToken) { - case IF: + case token::IF: nPCode = NscPCode_If; nFenceType = NscFenceType_If; pszToken = "if"; @@ -4714,7 +4717,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST fCheckCond = pPrev == NULL; break; - case WHILE: + case token::WHILE: nPCode = NscPCode_While; nFenceType = NscFenceType_While; pszToken = "while"; @@ -4722,7 +4725,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST fCheckCond = pPrev == NULL; break; - case DO: + case token::DO: nPCode = NscPCode_Do; nFenceType = NscFenceType_Do; pszToken = "do"; @@ -4730,7 +4733,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST fCheckCond = pPrev != NULL; break; - case FOR: + case token::FOR: nPCode = NscPCode_For; nFenceType = NscFenceType_For; pszToken = "for"; @@ -4738,7 +4741,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST fCheckCond = pPrev == NULL; break; - case SWITCH: + case token::SWITCH: nPCode = NscPCode_Switch; nFenceType = NscFenceType_Switch; pszToken = "switch"; @@ -4787,7 +4790,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST // for this // - if (nToken == SWITCH) + if (nToken == token::SWITCH) { NscSymbolFence *pFence = g_pCtx ->GetCurrentFence (); pFence ->nPrevLocals++; @@ -4806,7 +4809,7 @@ YYSTYPE NscBuild5Block (int nToken, YYST // then set return // - if (nToken == IF && pFalse) + if (nToken == token::IF && pFalse) { if (fHadReturn) NscSetFenceReturn (true); @@ -4992,7 +4995,7 @@ YYSTYPE NscBuildCase (int nToken, YYSTYP // If this is a case // - if (nToken == CASE) + if (nToken == token::CASE) { // @@ -5061,7 +5064,7 @@ YYSTYPE NscBuildCase (int nToken, YYSTYP // Test for only one default // - if (nToken == DEFAULT) + if (nToken == token::DEFAULT) { if (pFence ->fHasDefault) { @@ -5086,9 +5089,9 @@ YYSTYPE NscBuildCase (int nToken, YYSTYP // NscPCode nPCode; - if (nToken == CASE) + if (nToken == token::CASE) nPCode = NscPCode_Case; - else if (nToken == DEFAULT) + else if (nToken == token::DEFAULT) nPCode = NscPCode_Default; else { @@ -5262,9 +5265,9 @@ YYSTYPE NscBuildBreakContinue (int nToke // NscPCode nPCode; - if (nToken == BREAK) + if (nToken == token::BREAK) nPCode = NscPCode_Break; - else if (nToken == CONTINUE) + else if (nToken == token::CONTINUE) nPCode = NscPCode_Continue; else { @@ -5279,7 +5282,7 @@ YYSTYPE NscBuildBreakContinue (int nToke NscSymbolFence *pFence = g_pCtx ->GetCurrentFence (); while (pFence) { - if ((pFence ->nFenceType == NscFenceType_Switch && nToken == BREAK) || + if ((pFence ->nFenceType == NscFenceType_Switch && nToken == token::BREAK) || pFence ->nFenceType == NscFenceType_Do || pFence ->nFenceType == NscFenceType_While || pFence ->nFenceType == NscFenceType_For) @@ -5288,12 +5291,12 @@ YYSTYPE NscBuildBreakContinue (int nToke } if (pFence == NULL) { - if (nToken == BREAK) + if (nToken == token::BREAK) { g_pCtx ->GenerateError ("\"break\" statement only allowed in " "\"switch\", \"do\", \"while\", and \"for\" statements"); } - else if (nToken == CONTINUE) + else if (nToken == token::CONTINUE) { g_pCtx ->GenerateError ("\"continue\" statement only allowed in " "\"do\", \"while\", and \"for\" statements");