Ticket #41600: nwntools.2.3.2-bison-3.patch

File nwntools.2.3.2-bison-3.patch, 34.5 KB (added by akimd (Akim Demaille), 9 years ago)

A patch to update to using Bison 3

  • _NscLib/NscCompiler.cpp

    diff nwntools-2.3.2/_NscLib/NscCompiler.cpp nwntools-2.3.2.new/_NscLib/NscCompiler.cpp
    old new  
    6767//
    6868//-----------------------------------------------------------------------------
    6969
    70 inline void NscAddToken (char *pszName, int nToken)
     70inline void NscAddToken (const char *pszName, int nToken)
    7171{
    7272        NscSymbol *pSymbol = g_sNscReservedWords .Add (
    7373                pszName, NscSymType_Token);
     
    106106        //
    107107        // Add the reserved words
    108108        //
     109        // "Import" token definitions.
     110        typedef yy::parser::token token;
    109111
    110         NscAddToken ("int",            INT_TYPE);
    111         NscAddToken ("float",          FLOAT_TYPE);
    112         NscAddToken ("object",         OBJECT_TYPE);
    113         NscAddToken ("string",         STRING_TYPE);
    114         NscAddToken ("struct",         STRUCT_TYPE);
    115         NscAddToken ("void",           VOID_TYPE);
    116         NscAddToken ("vector",         VECTOR_TYPE);
    117         NscAddToken ("action",         ACTION_TYPE);
    118 
    119         NscAddToken ("break",          BREAK);
    120         NscAddToken ("case",           CASE);
    121         NscAddToken ("continue",       CONTINUE);
    122         NscAddToken ("default",        DEFAULT);
    123         NscAddToken ("do",             DO);
    124         NscAddToken ("else",           ELSE);
    125         NscAddToken ("for",            FOR);
    126         NscAddToken ("if",             IF);
    127         NscAddToken ("return",         RETURN);
    128         NscAddToken ("switch",         SWITCH);
    129         NscAddToken ("while",          WHILE);
     112        NscAddToken ("int",            token::INT_TYPE);
     113        NscAddToken ("float",          token::FLOAT_TYPE);
     114        NscAddToken ("object",         token::OBJECT_TYPE);
     115        NscAddToken ("string",         token::STRING_TYPE);
     116        NscAddToken ("struct",         token::STRUCT_TYPE);
     117        NscAddToken ("void",           token::VOID_TYPE);
     118        NscAddToken ("vector",         token::VECTOR_TYPE);
     119        NscAddToken ("action",         token::ACTION_TYPE);
     120
     121        NscAddToken ("break",          token::BREAK);
     122        NscAddToken ("case",           token::CASE);
     123        NscAddToken ("continue",       token::CONTINUE);
     124        NscAddToken ("default",        token::DEFAULT);
     125        NscAddToken ("do",             token::DO);
     126        NscAddToken ("else",           token::ELSE);
     127        NscAddToken ("for",            token::FOR);
     128        NscAddToken ("if",             token::IF);
     129        NscAddToken ("return",         token::RETURN);
     130        NscAddToken ("switch",         token::SWITCH);
     131        NscAddToken ("while",          token::WHILE);
    130132        if (fEnableExtensions || nVersion >= 999)
    131         NscAddToken ("const",      NWCONST);
    132 
    133         NscAddToken ("OBJECT_SELF",    OBJECT_SELF_CONST);
    134         NscAddToken ("OBJECT_INVALID", OBJECT_INVALID_CONST);
     133        NscAddToken ("const",      token::NWCONST);
    135134
     135        NscAddToken ("OBJECT_SELF",    token::OBJECT_SELF_CONST);
     136        NscAddToken ("OBJECT_INVALID", token::OBJECT_INVALID_CONST);
    136137        //
    137138        // Read NWSCRIPT
    138139        //
     
    373374//
    374375//----------------------------------------------------------------------------
    375376
    376 void yy::parser::error (const yy::parser::location_type& l,
    377                         const std::string& m) {
     377void yy::parser::error (const std::string& m) {
    378378    context.yyerror(m.c_str());
    379379}
    380380
  • _NscLib/NscContext.cpp

    diff nwntools-2.3.2/_NscLib/NscContext.cpp nwntools-2.3.2.new/_NscLib/NscContext.cpp
    old new  
    150150
    151151int CNscContext::yylex (YYSTYPE* yylval)
    152152{
     153        // "Import" token definitions.
     154        typedef yy::parser::token token;
    153155
    154156        //
    155157        // Initialize lvalue
     
    230232                if (pSymbol != NULL)
    231233                {
    232234                        assert (pSymbol ->nSymType == NscSymType_Token);
    233                         if (pSymbol ->nToken == ENGINE_TYPE)
     235                        if (pSymbol ->nToken == token::ENGINE_TYPE)
    234236                        {
    235237                                CNscPStackEntry *pEntry = GetPStackEntry (__FILE__, __LINE__);
    236238                                pEntry ->SetType ((NscType) (
     
    246248                        CNscPStackEntry *pEntry = GetPStackEntry (__FILE__, __LINE__);
    247249                        pEntry ->SetIdentifier (pszStart, nCount);
    248250                        *yylval = pEntry;
    249                         return IDENTIFIER;
     251                        return token::IDENTIFIER;
    250252                }
    251253        }
    252254
     
    305307                        pEntry ->SetType (NscType_Integer);
    306308                        pEntry ->PushConstantInteger (nValue);
    307309                        *yylval = pEntry;
    308                         return INTEGER_CONST;
     310                        return token::INTEGER_CONST;
    309311                }
    310312
    311313                //
     
    359361                        {
    360362                                pEntry ->SetType (NscType_Float);
    361363                                pEntry ->PushConstantFloat ((float) atof (psz));
    362                                 return FLOAT_CONST;
     364                                return token::FLOAT_CONST;
    363365                        }
    364366                        else
    365367                        {
    366368                                pEntry ->SetType (NscType_Integer);
    367369                                pEntry ->PushConstantInteger (atol (psz));
    368                                 return INTEGER_CONST;
     370                                return token::INTEGER_CONST;
    369371                        }
    370372                }
    371373        }
     
    414416                                else if (c == '=')
    415417                                {
    416418                                        m_pStreamTop ->pszNextTokenPos++;
    417                                         return DIVEQ;
     419                                        return token::DIVEQ;
    418420                                }
    419421                                else
    420422                                {
     
    441443                                if (c == '=')
    442444                                {
    443445                                        m_pStreamTop ->pszNextTokenPos++;
    444                                         return ADDEQ;
     446                                        return token::ADDEQ;
    445447                                }
    446448                                else if (c == '+')
    447449                                {
    448450                                        m_pStreamTop ->pszNextTokenPos++;
    449                                         return PLUSPLUS;
     451                                        return token::PLUSPLUS;
    450452                                }
    451453                                else
    452454                                        return '+';
     
    457459                                if (c == '=')
    458460                                {
    459461                                        m_pStreamTop ->pszNextTokenPos++;
    460                                         return SUBEQ;
     462                                        return token::SUBEQ;
    461463                                }
    462464                                else if (c == '-')
    463465                                {
    464466                                        m_pStreamTop ->pszNextTokenPos++;
    465                                         return MINUSMINUS;
     467                                        return token::MINUSMINUS;
    466468                                }
    467469                                else
    468470                                        return '-';
     
    473475                                if (c == '=')
    474476                                {
    475477                                        m_pStreamTop ->pszNextTokenPos++;
    476                                         return MULEQ;
     478                                        return token::MULEQ;
    477479                                }
    478480                                else
    479481                                        return '*';
     
    484486                                if (c == '=')
    485487                                {
    486488                                        m_pStreamTop ->pszNextTokenPos++;
    487                                         return MODEQ;
     489                                        return token::MODEQ;
    488490                                }
    489491                                else
    490492                                        return '%';
     
    495497                                if (c == '=')
    496498                                {
    497499                                        m_pStreamTop ->pszNextTokenPos++;
    498                                         return XOREQ;
     500                                        return token::XOREQ;
    499501                                }
    500502                                else
    501503                                        return '^';
     
    506508                                if (c == '=')
    507509                                {
    508510                                        m_pStreamTop ->pszNextTokenPos++;
    509                                         return ANDEQ;
     511                                        return token::ANDEQ;
    510512                                }
    511513                                else if (c == '&')
    512514                                {
    513515                                        m_pStreamTop ->pszNextTokenPos++;
    514                                         return ANDAND;
     516                                        return token::ANDAND;
    515517                                }
    516518                                else
    517519                                        return '&';
     
    522524                                if (c == '=')
    523525                                {
    524526                                        m_pStreamTop ->pszNextTokenPos++;
    525                                         return OREQ;
     527                                        return token::OREQ;
    526528                                }
    527529                                else if (c == '|')
    528530                                {
    529531                                        m_pStreamTop ->pszNextTokenPos++;
    530                                         return OROR;
     532                                        return token::OROR;
    531533                                }
    532534                                else
    533535                                        return '|';
     
    538540                                if (c == '=')
    539541                                {
    540542                                        m_pStreamTop ->pszNextTokenPos++;
    541                                         return NOTEQ;
     543                                        return token::NOTEQ;
    542544                                }
    543545                                else
    544546                                        return '!';
     
    549551                                if (c == '=')
    550552                                {
    551553                                        m_pStreamTop ->pszNextTokenPos++;
    552                                         return EQ;
     554                                        return token::EQ;
    553555                                }
    554556                                else
    555557                                        return '=';
     
    560562                                if (c == '=')
    561563                                {
    562564                                        m_pStreamTop ->pszNextTokenPos++;
    563                                         return LTEQ;
     565                                        return token::LTEQ;
    564566                                }
    565567                                else if (c == '<')
    566568                                {
     
    569571                                        if (c == '=')
    570572                                        {
    571573                                                m_pStreamTop ->pszNextTokenPos++;
    572                                                 return SLEQ;
     574                                                return token::SLEQ;
    573575                                        }
    574576                                        else
    575                                                 return SL;
     577                                                return token::SL;
    576578                                }
    577579                                else
    578580                                        return '<';
     
    583585                                if (c == '=')
    584586                                {
    585587                                        m_pStreamTop ->pszNextTokenPos++;
    586                                         return GTEQ;
     588                                        return token::GTEQ;
    587589                                }
    588590                                else if (c == '>')
    589591                                {
     
    592594                                        if (c == '=')
    593595                                        {
    594596                                                m_pStreamTop ->pszNextTokenPos++;
    595                                                 return SREQ;
     597                                                return token::SREQ;
    596598                                        }
    597599                                        else if (c == '>')
    598600                                        {
     
    601603                                                if (c == '=')
    602604                                                {
    603605                                                        m_pStreamTop ->pszNextTokenPos++;
    604                                                         return USREQ;
     606                                                        return token::USREQ;
    605607                                                }
    606608                                                else
    607                                                         return USR;
     609                                                        return token::USR;
    608610                                        }
    609611                                        else
    610                                                 return SR;
     612                                                return token::SR;
    611613                                }
    612614                                else
    613615                                        return '>';
     
    626628                                                        pEntry ->SetType (NscType_String);
    627629                                                        pEntry ->PushConstantString (pszStart, (int) (pszOut - pszStart));
    628630                                                        *yylval = pEntry;
    629                                                         return STRING_CONST;
     631                                                        return token::STRING_CONST;
    630632                                                }
    631633                                                else if (c == '\\')
    632634                                                {
     
    646648                                                        pEntry ->PushConstantString (pszStart, (int) (pszOut - pszStart));
    647649                                                        *yylval = pEntry;
    648650                                                        GenerateError ("Unterminated string");
    649                                                         return STRING_CONST;
     651                                                        return token::STRING_CONST;
    650652                                                }
    651653                                                else
    652654                                                        *pszOut++ = c;
     
    898900                                        {
    899901                                                NscSymbol *pSymbol = g_sNscReservedWords .Add (
    900902                                                        pszVTmp, NscSymType_Token);
    901                                                 pSymbol ->nToken = ENGINE_TYPE;
     903                                                typedef yy::parser::token token;
     904                                                pSymbol ->nToken = token::ENGINE_TYPE;
    902905                                                pSymbol ->nEngineObject = nIndex;
    903906                                        }
    904907                                }
  • _NscLib/NscDecompiler.cpp

    diff nwntools-2.3.2/_NscLib/NscDecompiler.cpp nwntools-2.3.2.new/_NscLib/NscDecompiler.cpp
    old new  
    225225                char szByteText [128];
    226226                char szOpText [512];
    227227                char szOpType [32];
    228                 char *pszOpRoot;
     228                const char *pszOpRoot;
    229229
    230230                //
    231231                // Switch based on the next opcode
  • _NscLib/NscParser.ypp

    diff nwntools-2.3.2/_NscLib/NscParser.ypp nwntools-2.3.2.new/_NscLib/NscParser.ypp
    old new  
    273273                }
    274274        | shift_expression SL additive_expression
    275275                {
    276                         $$ = NscBuildBinaryOp (SL, $1, $3);
     276                        $$ = NscBuildBinaryOp (token::SL, $1, $3);
    277277                }
    278278        | shift_expression SR additive_expression
    279279                {
    280                         $$ = NscBuildBinaryOp (SR, $1, $3);
     280                        $$ = NscBuildBinaryOp (token::SR, $1, $3);
    281281                }
    282282        | shift_expression USR additive_expression
    283283                {
    284                         $$ = NscBuildBinaryOp (USR, $1, $3);
     284                        $$ = NscBuildBinaryOp (token::USR, $1, $3);
    285285                }
    286286        ;
    287287
     
    300300                }
    301301        | relational_expression LTEQ shift_expression
    302302                {
    303                         $$ = NscBuildBinaryOp (LTEQ, $1, $3);
     303                        $$ = NscBuildBinaryOp (token::LTEQ, $1, $3);
    304304                }
    305305        | relational_expression GTEQ shift_expression
    306306                {
    307                         $$ = NscBuildBinaryOp (GTEQ, $1, $3);
     307                        $$ = NscBuildBinaryOp (token::GTEQ, $1, $3);
    308308                }
    309309        ;
    310310
     
    315315                }
    316316        | equality_expression EQ relational_expression
    317317                {
    318                         $$ = NscBuildBinaryOp (EQ, $1, $3);
     318                        $$ = NscBuildBinaryOp (token::EQ, $1, $3);
    319319                }
    320320        | equality_expression NOTEQ relational_expression
    321321                {
    322                         $$ = NscBuildBinaryOp (NOTEQ, $1, $3);
     322                        $$ = NscBuildBinaryOp (token::NOTEQ, $1, $3);
    323323                }
    324324        ;
    325325
     
    363363                }
    364364        | logical_and_expression ANDAND inclusive_or_expression
    365365                {
    366                         $$ = NscBuildLogicalOp (ANDAND, $1, $3);
     366                        $$ = NscBuildLogicalOp (token::ANDAND, $1, $3);
    367367                }
    368368        ;
    369369
     
    374374                }
    375375        | logical_or_expression OROR logical_and_expression
    376376                {
    377                         $$ = NscBuildLogicalOp (OROR, $1, $3);
     377                        $$ = NscBuildLogicalOp (token::OROR, $1, $3);
    378378                }
    379379        ;
    380380
     
    400400                }
    401401        | unary_expression MULEQ assignment_expression
    402402                {
    403                         $$ = NscBuildBinaryOp (MULEQ, $1, $3);
     403                        $$ = NscBuildBinaryOp (token::MULEQ, $1, $3);
    404404                }
    405405        | unary_expression DIVEQ assignment_expression
    406406                {
    407                         $$ = NscBuildBinaryOp (DIVEQ, $1, $3);
     407                        $$ = NscBuildBinaryOp (token::DIVEQ, $1, $3);
    408408                }
    409409        | unary_expression MODEQ assignment_expression
    410410                {
    411                         $$ = NscBuildBinaryOp (MODEQ, $1, $3);
     411                        $$ = NscBuildBinaryOp (token::MODEQ, $1, $3);
    412412                }
    413413        | unary_expression ADDEQ assignment_expression
    414414                {
    415                         $$ = NscBuildBinaryOp (ADDEQ, $1, $3);
     415                        $$ = NscBuildBinaryOp (token::ADDEQ, $1, $3);
    416416                }
    417417        | unary_expression SUBEQ assignment_expression
    418418                {
    419                         $$ = NscBuildBinaryOp (SUBEQ, $1, $3);
     419                        $$ = NscBuildBinaryOp (token::SUBEQ, $1, $3);
    420420                }
    421421        | unary_expression SLEQ assignment_expression
    422422                {
    423                         $$ = NscBuildBinaryOp (SLEQ, $1, $3);
     423                        $$ = NscBuildBinaryOp (token::SLEQ, $1, $3);
    424424                }
    425425        | unary_expression SREQ assignment_expression
    426426                {
    427                         $$ = NscBuildBinaryOp (SREQ, $1, $3);
     427                        $$ = NscBuildBinaryOp (token::SREQ, $1, $3);
    428428                }
    429429        | unary_expression USREQ assignment_expression
    430430                {
    431                         $$ = NscBuildBinaryOp (USREQ, $1, $3);
     431                        $$ = NscBuildBinaryOp (token::USREQ, $1, $3);
    432432                }
    433433        | unary_expression ANDEQ assignment_expression
    434434                {
    435                         $$ = NscBuildBinaryOp (ANDEQ, $1, $3);
     435                        $$ = NscBuildBinaryOp (token::ANDEQ, $1, $3);
    436436                }
    437437        | unary_expression XOREQ assignment_expression
    438438                {
    439                         $$ = NscBuildBinaryOp (XOREQ, $1, $3);
     439                        $$ = NscBuildBinaryOp (token::XOREQ, $1, $3);
    440440                }
    441441        | unary_expression OREQ assignment_expression
    442442                {
    443                         $$ = NscBuildBinaryOp (OREQ, $1, $3);
     443                        $$ = NscBuildBinaryOp (token::OREQ, $1, $3);
    444444                }
    445445        ;
    446446
     
    480480type_specifier:
    481481        VOID_TYPE
    482482                {
    483                         $$ = NscBuildType (VOID_TYPE, NULL);
     483                        $$ = NscBuildType (token::VOID_TYPE, NULL);
    484484                }
    485485        | INT_TYPE
    486486                {
    487                         $$ = NscBuildType (INT_TYPE, NULL);
     487                        $$ = NscBuildType (token::INT_TYPE, NULL);
    488488                }
    489489        | FLOAT_TYPE
    490490                {
    491                         $$ = NscBuildType (FLOAT_TYPE, NULL);
     491                        $$ = NscBuildType (token::FLOAT_TYPE, NULL);
    492492                }
    493493        | OBJECT_TYPE
    494494                {
    495                         $$ = NscBuildType (OBJECT_TYPE, NULL);
     495                        $$ = NscBuildType (token::OBJECT_TYPE, NULL);
    496496                }
    497497        | STRING_TYPE
    498498                {
    499                         $$ = NscBuildType (STRING_TYPE, NULL);
     499                        $$ = NscBuildType (token::STRING_TYPE, NULL);
    500500                }
    501501        | ACTION_TYPE
    502502                {
    503                         $$ = NscBuildType (ACTION_TYPE, NULL);
     503                        $$ = NscBuildType (token::ACTION_TYPE, NULL);
    504504                }
    505505        | VECTOR_TYPE
    506506                {
    507                         $$ = NscBuildType (VECTOR_TYPE, NULL);
     507                        $$ = NscBuildType (token::VECTOR_TYPE, NULL);
    508508                }
    509509        | struct_type_start IDENTIFIER
    510510                {
    511                         $$ = NscBuildType (STRUCT_TYPE, $2);
     511                        $$ = NscBuildType (token::STRUCT_TYPE, $2);
    512512                }
    513513        | ENGINE_TYPE
    514514                {
    515                         $$ = NscBuildType (ENGINE_TYPE, $1);
     515                        $$ = NscBuildType (token::ENGINE_TYPE, $1);
    516516                }
    517517        ;
    518518       
     
    600600case_statement:
    601601        CASE { NscBuildSaveLine (0); } constant_expression ':'
    602602                {
    603                         $$ = NscBuildCase (CASE, $3);
     603                        $$ = NscBuildCase (token::CASE, $3);
    604604                }
    605605        | DEFAULT { NscBuildSaveLine (0); } ':'
    606606                {
    607                         $$ = NscBuildCase (DEFAULT, NULL);
     607                        $$ = NscBuildCase (token::DEFAULT, NULL);
    608608                }
    609609        ;
    610610       
     
    657657        | error
    658658                {
    659659                        $$ = NULL;
     660# ifdef YYCHAR_NAME
    660661                        if (NscBuildSyntaxError (YYCHAR_NAME, yylval))
    661662                                YYABORT;
    662663                        while (YYCHAR_NAME != EOF && YYCHAR_NAME != ';' && YYCHAR_NAME != '{' && YYCHAR_NAME != '}')
     
    668669                        }
    669670                        if (YYCHAR_NAME == ';')
    670671                                YYCHAR_NAME = yyempty_;
     672# else // !YYCHAR_NAME
     673                        if (NscBuildSyntaxError (yyla.type, yyla.value))
     674                                YYABORT;
     675                        while (yyla.type != EOF && yyla.type != ';' && yyla.type != '{' && yyla.type != '}')
     676                        {
     677                                if (yyla.value != NULL)
     678                                        yyla.value; //FIXME
     679                                yyla.type = yytranslate_ (yylex (&yyla.value, context));
     680                        }
     681                        if (yyla.type == ';')
     682                                yyla.clear ();
     683# endif
    671684                }       
    672685        ;
    673686       
     
    680693selection_statement:
    681694        if_start statement_blank_error
    682695                {
    683                         $$ = NscBuild5Block (IF, $1, 0, NULL, NULL, NULL, $2, NULL);
     696                        $$ = NscBuild5Block (token::IF, $1, 0, NULL, NULL, NULL, $2, NULL);
    684697                }
    685698        | if_else_start statement_blank_error
    686699                {
    687                         $$ = NscBuild5Block (IF, $1, 0, NULL, NULL, NULL, NULL, $2);
     700                        $$ = NscBuild5Block (token::IF, $1, 0, NULL, NULL, NULL, NULL, $2);
    688701                }
    689702        | switch_start statement
    690703                {
    691                         $$ = NscBuild5Block (SWITCH, $1, 0, NULL, NULL, NULL, $2, NULL);
     704                        $$ = NscBuild5Block (token::SWITCH, $1, 0, NULL, NULL, NULL, $2, NULL);
    692705                }
    693706        ;
    694707       
     
    696709        if_start statement_blank_error ELSE
    697710                {
    698711                        NscBuildSaveLine (0);
    699                         $$ = NscBuild5Block (IF, $1, 1, NULL, NULL, NULL, $2, NULL);
     712                        $$ = NscBuild5Block (token::IF, $1, 1, NULL, NULL, NULL, $2, NULL);
    700713                }
    701714        ;
    702715               
    703716if_start:
    704717        IF '(' { NscBuildSaveLine (0); } expression ')'
    705718                {
    706                         $$ = NscBuild5Block (IF, NULL, 1, NULL, $4, NULL, NULL, NULL);
     719                        $$ = NscBuild5Block (token::IF, NULL, 1, NULL, $4, NULL, NULL, NULL);
    707720                }
    708721        ;
    709722       
    710723switch_start:
    711724        SWITCH { NscBuildSaveLine (0); } '(' expression ')'
    712725                {
    713                         $$ = NscBuild5Block (SWITCH, NULL, 1, NULL, $4, NULL, NULL, NULL);
     726                        $$ = NscBuild5Block (token::SWITCH, NULL, 1, NULL, $4, NULL, NULL, NULL);
    714727                }
    715728        ;
    716729       
     
    723736iteration_statement:
    724737        while_start statement
    725738                {
    726                         $$ = NscBuild5Block (WHILE, $1, 0, NULL, NULL, NULL, $2, NULL);
     739                        $$ = NscBuild5Block (token::WHILE, $1, 0, NULL, NULL, NULL, $2, NULL);
    727740                }
    728741        | do_start statement WHILE { NscBuildSaveLine (0); } '(' expression ')' ';'
    729742                {
    730                         $$ = NscBuild5Block (DO, $1, 0, NULL, $6, NULL, $2, NULL);
     743                        $$ = NscBuild5Block (token::DO, $1, 0, NULL, $6, NULL, $2, NULL);
    731744                }
    732745        | for_start statement
    733746                {
    734                         $$ = NscBuild5Block (FOR, $1, 0, NULL, NULL, NULL, $2, NULL);
     747                        $$ = NscBuild5Block (token::FOR, $1, 0, NULL, NULL, NULL, $2, NULL);
    735748                }
    736749        ;
    737750       
    738751for_start:
    739752        for_start_start ';' ';' ')'
    740753                {
    741                         $$ = NscBuild5Block (FOR, NULL, 1, NULL, NULL, NULL, NULL, NULL);
     754                        $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, NULL, NULL, NULL, NULL);
    742755                }
    743756        | for_start_start expression ';' ';' ')'
    744757                {
    745                         $$ = NscBuild5Block (FOR, NULL, 1, $2, NULL, NULL, NULL, NULL);
     758                        $$ = NscBuild5Block (token::FOR, NULL, 1, $2, NULL, NULL, NULL, NULL);
    746759                }
    747760        | for_start_start ';' expression ';' ')'
    748761                {
    749                         $$ = NscBuild5Block (FOR, NULL, 1, NULL, $3, NULL, NULL, NULL);
     762                        $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, $3, NULL, NULL, NULL);
    750763                }
    751764        | for_start_start expression ';' expression ';' ')'
    752765                {
    753                         $$ = NscBuild5Block (FOR, NULL, 1, $2, $4, NULL, NULL, NULL);
     766                        $$ = NscBuild5Block (token::FOR, NULL, 1, $2, $4, NULL, NULL, NULL);
    754767                }
    755768        | for_start_start ';' ';' expression ')'
    756769                {
    757                         $$ = NscBuild5Block (FOR, NULL, 1, NULL, NULL, $4, NULL, NULL);
     770                        $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, NULL, $4, NULL, NULL);
    758771                }
    759772        | for_start_start expression ';' ';' expression ')'
    760773                {
    761                         $$ = NscBuild5Block (FOR, NULL, 1, $2, NULL, $5, NULL, NULL);
     774                        $$ = NscBuild5Block (token::FOR, NULL, 1, $2, NULL, $5, NULL, NULL);
    762775                }
    763776        | for_start_start ';' expression ';' expression ')'
    764777                {
    765                         $$ = NscBuild5Block (FOR, NULL, 1, NULL, $3, $5, NULL, NULL);
     778                        $$ = NscBuild5Block (token::FOR, NULL, 1, NULL, $3, $5, NULL, NULL);
    766779                }
    767780        | for_start_start expression ';' expression ';' expression ')'
    768781                {
    769                         $$ = NscBuild5Block (FOR, NULL, 1, $2, $4, $6, NULL, NULL);
     782                        $$ = NscBuild5Block (token::FOR, NULL, 1, $2, $4, $6, NULL, NULL);
    770783                }
    771784        ;
    772785       
     
    780793while_start:
    781794        WHILE '(' { NscBuildSaveLine (0); } expression ')'
    782795                {
    783                         $$ = NscBuild5Block (WHILE, NULL, 1, NULL, $4, NULL, NULL, NULL);
     796                        $$ = NscBuild5Block (token::WHILE, NULL, 1, NULL, $4, NULL, NULL, NULL);
    784797                }
    785798        ;
    786799       
    787800do_start:
    788801        DO
    789802                {
    790                         $$ = NscBuild5Block (DO, NULL, 1, NULL, NULL, NULL, NULL, NULL);
     803                        $$ = NscBuild5Block (token::DO, NULL, 1, NULL, NULL, NULL, NULL, NULL);
    791804                }
    792805        ;
    793806               
     
    800813jump_statement:
    801814        CONTINUE { NscBuildSaveLine (0); } ';'
    802815                {
    803                         $$ = NscBuildBreakContinue (CONTINUE);
     816                        $$ = NscBuildBreakContinue (token::CONTINUE);
    804817                }
    805818        | BREAK { NscBuildSaveLine (0); } ';'
    806819                {
    807                         $$ = NscBuildBreakContinue (BREAK);
     820                        $$ = NscBuildBreakContinue (token::BREAK);
    808821                }
    809822        | return_start ';'
    810823                {
     
    984997        | error
    985998                {
    986999                        $$ = NULL;
     1000# ifdef YYCHAR_NAME
    9871001                        if (NscBuildSyntaxError (YYCHAR_NAME, yylval))
    9881002                                YYABORT;
    9891003                        while (YYCHAR_NAME != EOF && YYCHAR_NAME != ';' && YYCHAR_NAME != '{' && YYCHAR_NAME != '}')
     
    9941008                                YYCHAR_NAME = yylex (&yylval, context);
    9951009                        }
    9961010                        YYCHAR_NAME = yyempty_;
     1011# else // !YYCHAR_NAME
     1012                        if (NscBuildSyntaxError (yyla.type, yyla.value))
     1013                                YYABORT;
     1014                        while (yyla.type != EOF && yyla.type != ';' && yyla.type != '{' && yyla.type != '}')
     1015                        {
     1016                                if (yyla.value != NULL)
     1017                                        yyla.value; //FIXME
     1018                                yyla.type = yytranslate_ (yylex (&yyla.value, context));
     1019                        }
     1020                        if (yyla.type == ';')
     1021                                yyla.clear ();
     1022# endif
    9971023                }       
    9981024        ;
    9991025
  • _NscLib/NscParserRoutines.cpp

    diff nwntools-2.3.2/_NscLib/NscParserRoutines.cpp nwntools-2.3.2.new/_NscLib/NscParserRoutines.cpp
    old new  
    390390                char szToken [2];
    391391                const char *pszToken;
    392392
     393                // "Import" token definitions.
     394                typedef yy::parser::token token;
     395 
    393396                //
    394397                // Get the token text
    395398                //
    396399
    397400                switch (nToken)
    398401                {
    399                         case IDENTIFIER:
     402                        case token::IDENTIFIER:
    400403                                if (yylval)
    401404                                        pszToken = yylval ->GetIdentifier ();
    402405                                else
    403406                                        pszToken = "identifier";
    404407                                break;
    405408
    406                         case INTEGER_CONST:
     409                        case token::INTEGER_CONST:
    407410                                pszToken = "integer constant";
    408411                                break;
    409412
    410                         case FLOAT_CONST:
     413                        case token::FLOAT_CONST:
    411414                                pszToken = "float constant";
    412415                                break;
    413416
    414                         case STRING_CONST:
     417                        case token::STRING_CONST:
    415418                                pszToken = "string constant";
    416419                                break;
    417420
    418                         case ADDEQ:
     421                        case token::ADDEQ:
    419422                                pszToken = "+=";
    420423                                break;
    421424
    422                         case SUBEQ:
     425                        case token::SUBEQ:
    423426                                pszToken = "-=";
    424427                                break;
    425428
    426                         case MULEQ:
     429                        case token::MULEQ:
    427430                                pszToken = "*=";
    428431                                break;
    429432
    430                         case DIVEQ:
     433                        case token::DIVEQ:
    431434                                pszToken = "/=";
    432435                                break;
    433436
    434                         case MODEQ:
     437                        case token::MODEQ:
    435438                                pszToken = "%=";
    436439                                break;
    437440
    438                         case XOREQ:
     441                        case token::XOREQ:
    439442                                pszToken = "^=";
    440443                                break;
    441444
    442                         case ANDEQ:
     445                        case token::ANDEQ:
    443446                                pszToken = "&=";
    444447                                break;
    445448
    446                         case OREQ:
     449                        case token::OREQ:
    447450                                pszToken = "|=";
    448451                                break;
    449452
    450                         case SL:
     453                        case token::SL:
    451454                                pszToken = "<<";
    452455                                break;
    453456
    454                         case SR:
     457                        case token::SR:
    455458                                pszToken = ">>";
    456459                                break;
    457460
    458                         case USR:
     461                        case token::USR:
    459462                                pszToken = ">>>";
    460463                                break;
    461464
    462                         case SLEQ:
     465                        case token::SLEQ:
    463466                                pszToken = "<<=";
    464467                                break;
    465468
    466                         case SREQ:
     469                        case token::SREQ:
    467470                                pszToken = ">>=";
    468471                                break;
    469472
    470                         case USREQ:
     473                        case token::USREQ:
    471474                                pszToken = ">>>=";
    472475                                break;
    473476
    474                         case EQ:
     477                        case token::EQ:
    475478                                pszToken = "==";
    476479                                break;
    477480
    478                         case NOTEQ:
     481                        case token::NOTEQ:
    479482                                pszToken = "!=";
    480483                                break;
    481484
    482                         case LTEQ:
     485                        case token::LTEQ:
    483486                                pszToken = "<=";
    484487                                break;
    485488
    486                         case GTEQ:
     489                        case token::GTEQ:
    487490                                pszToken = ">=";
    488491                                break;
    489492
    490                         case ANDAND:
     493                        case token::ANDAND:
    491494                                pszToken = "&&";
    492495                                break;
    493496
    494                         case OROR:
     497                        case token::OROR:
    495498                                pszToken = "||";
    496499                                break;
    497500
    498                         case PLUSPLUS:
     501                        case token::PLUSPLUS:
    499502                                pszToken = "++";
    500503                                break;
    501504
    502                         case MINUSMINUS:
     505                        case token::MINUSMINUS:
    503506                                pszToken = "--";
    504507                                break;
    505508
    506                         case FLOAT_TYPE:
     509                        case token::FLOAT_TYPE:
    507510                                pszToken = "float";
    508511                                break;
    509512
    510                         case INT_TYPE:
     513                        case token::INT_TYPE:
    511514                                pszToken = "int";
    512515                                break;
    513516
    514                         case OBJECT_TYPE:
     517                        case token::OBJECT_TYPE:
    515518                                pszToken = "object";
    516519                                break;
    517520
    518                         case STRING_TYPE:
     521                        case token::STRING_TYPE:
    519522                                pszToken = "string";
    520523                                break;
    521524
    522                         case VOID_TYPE:
     525                        case token::VOID_TYPE:
    523526                                pszToken = "void";
    524527                                break;
    525528
    526                         case STRUCT_TYPE:
     529                        case token::STRUCT_TYPE:
    527530                                pszToken = "struct";
    528531                                break;
    529532
    530                         case VECTOR_TYPE:
     533                        case token::VECTOR_TYPE:
    531534                                pszToken = "vector";
    532535                                break;
    533536
    534                         case ENGINE_TYPE:
     537                        case token::ENGINE_TYPE:
    535538                                if (yylval)
    536539                                {
    537540                                        int nIndex = yylval ->GetType () - NscType_Engine_0;
     
    541544                                        pszToken = "engine-type";
    542545                                break;
    543546
    544                         case ACTION_TYPE:
     547                        case token::ACTION_TYPE:
    545548                                pszToken = "action";
    546549                                break;
    547550
    548                         case OBJECT_SELF_CONST:
     551                        case token::OBJECT_SELF_CONST:
    549552                                pszToken = "OBJECT_SELF";
    550553                                break;
    551554
    552                         case OBJECT_INVALID_CONST:
     555                        case token::OBJECT_INVALID_CONST:
    553556                                pszToken = "OBJECT_INVALID";
    554557                                break;
    555558
    556                         case BREAK:
     559                        case token::BREAK:
    557560                                pszToken = "break";
    558561                                break;
    559562
    560                         case CASE:
     563                        case token::CASE:
    561564                                pszToken = "case";
    562565                                break;
    563566
    564                         case CONTINUE:
     567                        case token::CONTINUE:
    565568                                pszToken = "continue";
    566569                                break;
    567570
    568                         case DEFAULT:
     571                        case token::DEFAULT:
    569572                                pszToken = "default";
    570573                                break;
    571574
    572                         case DO:
     575                        case token::DO:
    573576                                pszToken = "do";
    574577                                break;
    575578
    576                         case ELSE:
     579                        case token::ELSE:
    577580                                pszToken = "else";
    578581                                break;
    579582
    580                         case FOR:
     583                        case token::FOR:
    581584                                pszToken = "for";
    582585                                break;
    583586
    584                         case IF:
     587                        case token::IF:
    585588                                pszToken = "if";
    586589                                break;
    587590
    588                         case RETURN:
     591                        case token::RETURN:
    589592                                pszToken = "return";
    590593                                break;
    591594
    592                         case SWITCH:
     595                        case token::SWITCH:
    593596                                pszToken = "switch";
    594597                                break;
    595598
    596                         case WHILE:
     599                        case token::WHILE:
    597600                                pszToken = "while";
    598601                                break;
    599602
    600                         case NWCONST:
     603                        case token::NWCONST:
    601604                                pszToken = "const";
    602605                                break;
    603606
     
    651654{
    652655        CNscPStackEntry *pOut = g_pCtx ->GetPStackEntry (__FILE__, __LINE__);
    653656
     657        // "Import" token definitions.
     658        typedef yy::parser::token token;
     659 
    654660        //
    655661        // Switch based on the type
    656662        //
    657663
    658664        switch (nType)
    659665        {
    660                 case VOID_TYPE:
     666                case token::VOID_TYPE:
    661667                        pOut ->SetType (NscType_Void);
    662668                        break;
    663669
    664                 case INT_TYPE:
     670                case token::INT_TYPE:
    665671                        pOut ->SetType (NscType_Integer);
    666672                        break;
    667673
    668                 case FLOAT_TYPE:
     674                case token::FLOAT_TYPE:
    669675                        pOut ->SetType (NscType_Float);
    670676                        break;
    671677
    672                 case OBJECT_TYPE:
     678                case token::OBJECT_TYPE:
    673679                        pOut ->SetType (NscType_Object);
    674680                        break;
    675681
    676                 case STRING_TYPE:
     682                case token::STRING_TYPE:
    677683                        pOut ->SetType (NscType_String);
    678684                        break;
    679685
    680                 case VECTOR_TYPE:
     686                case token::VECTOR_TYPE:
    681687                        pOut ->SetType (NscType_Vector);
    682688                        break;
    683689
    684                 case ACTION_TYPE:
     690                case token::ACTION_TYPE:
    685691                        if (!g_pCtx ->IsNWScript ())
    686692                        {
    687693                                g_pCtx ->GenerateError ("\"action\" identifier only "
     
    692698                pOut ->SetType (NscType_Action);
    693699                        break;
    694700
    695                 case STRUCT_TYPE:
     701                case token::STRUCT_TYPE:
    696702                        assert (pId != NULL);
    697703                        {
    698704                                if (!g_pCtx ->IsPhase2 () && !g_pCtx ->IsNWScript ())
     
    723729                        }
    724730                        break;
    725731
    726                 case ENGINE_TYPE:
     732                case token::ENGINE_TYPE:
    727733                        assert (pId != NULL);
    728734                        {
    729735                                pOut ->SetType (pId ->GetType ());
     
    24222428{
    24232429        CNscPStackEntry *pOut = g_pCtx ->GetPStackEntry (__FILE__, __LINE__);
    24242430
     2431        // "Import" token definitions.
     2432        typedef yy::parser::token token;
     2433 
    24252434        //
    24262435        // If this is phase1 and we are in a function, do nothing
    24272436        //
     
    29232932                        }
    29242933                        break;
    29252934
    2926                 case SL:
     2935                case token::SL:
    29272936                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    29282937                        {
    29292938                                if (g_pCtx ->GetOptExpression () &&
     
    29482957                        }
    29492958                        break;
    29502959
    2951                 case SR:
     2960                case token::SR:
    29522961                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    29532962                        {
    29542963#ifdef NOT_ENABLED_YET
     
    29752984                        }
    29762985                        break;
    29772986
    2978                 case USR:
     2987                case token::USR:
    29792988                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    29802989                        {
    29812990#ifdef NOT_ENABLED_YET
     
    30863095                        }
    30873096                        break;
    30883097
    3089                 case LTEQ:
     3098                case token::LTEQ:
    30903099                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    30913100                        {
    30923101                                if (g_pCtx ->GetOptExpression () &&
     
    31283137                        }
    31293138                        break;
    31303139
    3131                 case GTEQ:
     3140                case token::GTEQ:
    31323141                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    31333142                        {
    31343143                                if (g_pCtx ->GetOptExpression () &&
     
    31703179                        }
    31713180                        break;
    31723181
    3173                 case EQ:
     3182                case token::EQ:
    31743183                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    31753184                        {
    31763185                                if (g_pCtx ->GetOptExpression () &&
     
    32603269                        }
    32613270                        break;
    32623271
    3263                 case NOTEQ:
     3272                case token::NOTEQ:
    32643273                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    32653274                        {
    32663275                                if (g_pCtx ->GetOptExpression () &&
     
    34403449                        }
    34413450                        break;
    34423451
    3443                 case MULEQ:
     3452                case token::MULEQ:
    34443453                        if (nLhsType == NscType_Vector && nRhsType == NscType_Float)
    34453454                        {
    34463455                                NscPushAssignment (pOut, NscPCode_AsnMultiply,
     
    34683477                        }
    34693478                        break;
    34703479
    3471                 case DIVEQ:
     3480                case token::DIVEQ:
    34723481                        if (nLhsType == NscType_Vector && nRhsType == NscType_Float)
    34733482                        {
    34743483                                NscPushAssignment (pOut, NscPCode_AsnDivide,
     
    34963505                        }
    34973506                        break;
    34983507
    3499                 case MODEQ:
     3508                case token::MODEQ:
    35003509                        if (nLhsType == NscType_Integer && nRhsType == NscType_Integer)
    35013510                        {
    35023511                                NscPushAssignment (pOut, NscPCode_AsnModulus,
     
    35093518                        }
    35103519                        break;
    35113520
    3512                 case ADDEQ:
     3521                case token::ADDEQ:
    35133522                        if (nLhsType == NscType_Vector && nRhsType == NscType_Vector)
    35143523                        {
    35153524                                NscPushAssignment (pOut, NscPCode_AsnAdd,
     
    35423551                        }
    35433552                        break;
    35443553
    3545                 case SUBEQ:
     3554                case token::SUBEQ:
    35463555                        if (nLhsType == NscType_Vector && nRhsType == NscType_Vector)
    35473556                        {
    35483557                                NscPushAssignment (pOut, NscPCode_AsnSubtract,
     
    35703579                        }
    35713580                        break;
    35723581
    3573                 case SLEQ:
     3582                case token::SLEQ:
    35743583                        pszOp = "<<=";
    35753584                        nOp = NscPCode_AsnShiftLeft;
    35763585asn_shift_operator:;
     
    35863595                        }
    35873596                        break;
    35883597
    3589                 case SREQ:
     3598                case token::SREQ:
    35903599                        pszOp = ">>=";
    35913600                        nOp = NscPCode_AsnShiftRight;
    35923601                        goto asn_shift_operator;
    35933602
    3594                 case USREQ:
     3603                case token::USREQ:
    35953604                        pszOp = ">>>=";
    35963605                        nOp = NscPCode_AsnUnsignedShiftRight;
    35973606                        goto asn_shift_operator;
    35983607
    3599                 case ANDEQ:
     3608                case token::ANDEQ:
    36003609                        pszOp = "&=";
    36013610                        nOp = NscPCode_AsnBitwiseAND;
    36023611asn_bitwise_expression:;
     
    36123621                        }
    36133622                        break;
    36143623
    3615                 case XOREQ:
     3624                case token::XOREQ:
    36163625                        pszOp = "^=";
    36173626                        nOp = NscPCode_AsnBitwiseXOR;
    36183627                        goto asn_bitwise_expression;
    36193628
    3620                 case OREQ:
     3629                case token::OREQ:
    36213630                        pszOp = "|=";
    36223631                        nOp = NscPCode_AsnBitwiseOR;
    36233632                        goto asn_bitwise_expression;
     
    36903699        else
    36913700        {
    36923701
     3702                // "Import" token definitions.
     3703                typedef yy::parser::token token;
     3704 
    36933705                //
    36943706                // Get operator information
    36953707                //
    36963708
    36973709                const char *pszOp;
    36983710                NscPCode nOp;
    3699                 if (nToken == ANDAND)
     3711                if (nToken == token::ANDAND)
    37003712                {
    37013713                        pszOp = "&&";
    37023714                        nOp = NscPCode_LogicalAND;
    37033715                }
    3704                 else if (nToken == OROR)
     3716                else if (nToken == token::OROR)
    37053717                {
    37063718                        pszOp = "||";
    37073719                        nOp = NscPCode_LogicalOR;
     
    37503762                        // If the operation is known to be true or false by the lhs
    37513763                        //
    37523764
    3753                         else if (nToken == ANDAND && nLhsConstant == 0)
     3765                        else if (nToken == token::ANDAND && nLhsConstant == 0)
    37543766                        {
    37553767                                pOut ->PushConstantInteger (0);
    37563768                                pOut ->SetType (NscType_Integer);
    37573769                        }
    3758                         else if (nToken == OROR && nLhsConstant == 1)
     3770                        else if (nToken == token::OROR && nLhsConstant == 1)
    37593771                        {
    37603772                                pOut ->PushConstantInteger (1);
    37613773                                pOut ->SetType (NscType_Integer);
     
    46734685{
    46744686        CNscPStackEntry *pOut = g_pCtx ->GetPStackEntry (__FILE__, __LINE__);
    46754687
     4688        // "Import" token definitions.
     4689        typedef yy::parser::token token;
     4690 
     4691
    46764692        //
    46774693        // If this is phase1 and we are in a function, do nothing
    46784694        //
     
    47064722        bool fCheckCond;
    47074723        switch (nToken)
    47084724        {
    4709                 case IF:
     4725                case token::IF:
    47104726                        nPCode = NscPCode_If;
    47114727                        nFenceType = NscFenceType_If;
    47124728                        pszToken = "if";
     
    47144730                        fCheckCond = pPrev == NULL;
    47154731                        break;
    47164732
    4717                 case WHILE:
     4733                case token::WHILE:
    47184734                        nPCode = NscPCode_While;
    47194735                        nFenceType = NscFenceType_While;
    47204736                        pszToken = "while";
     
    47224738                        fCheckCond = pPrev == NULL;
    47234739                        break;
    47244740
    4725                 case DO:
     4741                case token::DO:
    47264742                        nPCode = NscPCode_Do;
    47274743                        nFenceType = NscFenceType_Do;
    47284744                        pszToken = "do";
     
    47304746                        fCheckCond = pPrev != NULL;
    47314747                        break;
    47324748
    4733                 case FOR:
     4749                case token::FOR:
    47344750                        nPCode = NscPCode_For;
    47354751                        nFenceType = NscFenceType_For;
    47364752                        pszToken = "for";
     
    47384754                        fCheckCond = pPrev == NULL;
    47394755                        break;
    47404756
    4741                 case SWITCH:
     4757                case token::SWITCH:
    47424758                        nPCode = NscPCode_Switch;
    47434759                        nFenceType = NscFenceType_Switch;
    47444760                        pszToken = "switch";
     
    47874803                // for this
    47884804                //
    47894805
    4790                 if (nToken == SWITCH)
     4806                if (nToken == token::SWITCH)
    47914807                {
    47924808                        NscSymbolFence *pFence = g_pCtx ->GetCurrentFence ();
    47934809                        pFence ->nPrevLocals++;
     
    48064822        // then set return
    48074823        //
    48084824
    4809         if (nToken == IF && pFalse)
     4825        if (nToken == token::IF && pFalse)
    48104826        {
    48114827                if (fHadReturn)
    48124828                        NscSetFenceReturn (true);
     
    49764992        else
    49774993        {
    49784994
     4995                // "Import" token definitions.
     4996                typedef yy::parser::token token;
     4997 
    49794998                //
    49804999                // Get the conditional
    49815000                //
     
    49925011                // If this is a case
    49935012                //
    49945013
    4995                 if (nToken == CASE)
     5014                if (nToken == token::CASE)
    49965015                {
    49975016
    49985017                        //
     
    50615080                        // Test for only one default
    50625081                        //
    50635082
    5064                         if (nToken == DEFAULT)
     5083                        if (nToken == token::DEFAULT)
    50655084                        {
    50665085                                if (pFence ->fHasDefault)
    50675086                                {
     
    50865105                        //
    50875106
    50885107                        NscPCode nPCode;
    5089                         if (nToken == CASE)
     5108                        if (nToken == token::CASE)
    50905109                                nPCode = NscPCode_Case;
    5091                         else if (nToken == DEFAULT)
     5110                        else if (nToken == token::DEFAULT)
    50925111                                nPCode = NscPCode_Default;
    50935112                        else
    50945113                        {
     
    52455264
    52465265YYSTYPE NscBuildBreakContinue (int nToken)
    52475266{
     5267        // "Import" token definitions.
     5268        typedef yy::parser::token token;
     5269 
    52485270        CNscPStackEntry *pOut = g_pCtx ->GetPStackEntry (__FILE__, __LINE__);
    52495271
    52505272        //
     
    52625284        //
    52635285
    52645286        NscPCode nPCode;
    5265         if (nToken == BREAK)
     5287        if (nToken == token::BREAK)
    52665288                nPCode = NscPCode_Break;
    5267         else if (nToken == CONTINUE)
     5289        else if (nToken == token::CONTINUE)
    52685290                nPCode = NscPCode_Continue;
    52695291        else
    52705292        {
     
    52795301        NscSymbolFence *pFence = g_pCtx ->GetCurrentFence ();
    52805302        while (pFence)
    52815303        {
    5282                 if ((pFence ->nFenceType == NscFenceType_Switch && nToken == BREAK) ||
     5304                if ((pFence ->nFenceType == NscFenceType_Switch && nToken == token::BREAK) ||
    52835305                        pFence ->nFenceType == NscFenceType_Do ||
    52845306                        pFence ->nFenceType == NscFenceType_While ||
    52855307                        pFence ->nFenceType == NscFenceType_For)
     
    52885310        }
    52895311        if (pFence == NULL)
    52905312        {
    5291                 if (nToken == BREAK)
     5313                if (nToken == token::BREAK)
    52925314                {
    52935315            g_pCtx ->GenerateError ("\"break\" statement only allowed in "
    52945316                            "\"switch\", \"do\", \"while\", and \"for\" statements");
    52955317                }
    5296                 else if (nToken == CONTINUE)
     5318                else if (nToken == token::CONTINUE)
    52975319                {
    52985320            g_pCtx ->GenerateError ("\"continue\" statement only allowed in "
    52995321                            "\"do\", \"while\", and \"for\" statements");
  • nwntools-2.3.2

    diff nwntools-2.3.2/configure.ac nwntools-2.3.2.new/configure.ac
    old new  
    2020# Check bison version, substitute name for yychar
    2121bison_version=`bison -V | grep "^bison" | awk '{print $4}'`
    2222bison_v=`echo $bison_version | awk 'BEGIN { FS="." } {printf "%d", $1*10+$2;}'`
    23 AC_MSG_RESULT([checking bison version: $bison_version])
     23AC_MSG_RESULT([checking bison version: $bison_version ($bison_v)])
    2424
    25 if test -n "$bison_v" && test "$bison_v" -lt 20
    26 then
    27         AC_MSG_ERROR([need a bison version >= 2.0])
    28 fi
    29 
    30 if test -n "$bison_v" && test "$bison_v" -eq 20
    31 then
     25case $bison_v in
     26  (3*)
     27        AC_MSG_RESULT([setting lalr1 to use symbols])
     28        ;;
     29  (20)
    3230        AC_MSG_RESULT([setting bison lalr1 yychar variable name to yylooka_])
    3331        AC_DEFINE(YYCHAR_NAME,yylooka_,[name of yychar lookahead var in bison lalr1.cc])
    34 else
     32        ;;
     33  (2*)
    3534        AC_MSG_RESULT([setting bison lalr1 yychar variable name to yylooka])
    3635        AC_DEFINE(YYCHAR_NAME,yylooka,[name of yychar lookahead var in bison lalr1.cc])
    37 fi
     36        ;;
     37  (*)
     38        AC_MSG_ERROR([need a bison version >= 2.0])
     39        ;;
     40esac
    3841
    3942# Check for python
    4043AM_PATH_PYTHON(2.2,, :)