Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ if (MSVC)
endforeach(flag_var)
endif()

if (BISON_VERSION VERSION_GREATER "3.6.0")
add_definitions(-DNWN_BISON_3_6=1)
elseif (BISON_VERSION VERSION_GREATER "3.0.0")
add_definitions(-DNWN_BISON_3=1)
endif (BISON_VERSION VERSION_GREATER "3.6.0")

add_subdirectory(_NwnBaseLib)
add_subdirectory(_NwnDataLib)
add_subdirectory(_NwnUtilLib)
Expand Down
1 change: 1 addition & 0 deletions _NscLib/Nsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ enum NscConstants
NscMaxScript = 0x4000000,
NscMaxHash = 64,
NscMaxLabelSize = 16, // internal setting only, don't sweat it
NscMaxSyntaxErrors = 32,
};

//-----------------------------------------------------------------------------
Expand Down
27 changes: 3 additions & 24 deletions _NscLib/NscCompat.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
/* NscCompat.h
*/


/* Bison 3 does not define some of these
values. YYEMPTY is needed in all cases
the NWN_BISON_3 macro is defined by the CMakeLists.txt
based on the version of bison found
*/
#ifdef NWN_BISON_3_6
# define YYCHAR_NAME yyla.kind()
# define YYLA_EMPTY yyla.clear()
# define YYLVAL yyla.value
# define YYLA_CHARNAME_LEX yyla.kind_ = yytranslate_(yylex(&YYLVAL,context))
#else
# define YYEMPTY (-2)
# ifdef NWN_BISON_3
# define YYLVAL yyla.value
# define YYCHAR_NAME yyla.type
# else
# define YYCHAR_NAME yychar
# define YYLVAL yylval
# endif
# define YYLA_EMPTY YYCHAR_NAME = YYEMPTY
# define YYLA_CHARNAME_LEX YYCHAR_NAME = yylex(&YYLVAL, context)
#endif


// This much match what's generated in NscParser.hpp
enum nwtoken {
IDENTIFIER = 258,
INTEGER_CONST = 259,
Expand Down
7 changes: 1 addition & 6 deletions _NscLib/NscCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,14 +558,9 @@ const char *NscGetActionName (int nAction, NscCompiler *pCompiler)
// g_pCtx->yyerror(s);
//}
//#else
#if (NWN_BISON_3 || NWN_BISON_3_6)
void yy::parser::error (const std::string& m)
#else
void yy::parser::error (const location_type& loc, const std::string& m)
#endif

{
context.yyerror(m.c_str());
ctxt.yyerror(m.c_str());
}
//#endif

Expand Down
8 changes: 7 additions & 1 deletion _NscLib/NscContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1860,12 +1860,18 @@ try_again:;
if (p)
*p = 0;

//
// Make all includes lowercase
//
size_t i;
for(i = 0; pszTemp[i] != '\0'; i++)
pszTemp[i] = tolower(pszTemp[i]);

//
// Search the current list of included files and see
// if we have already done it
//

size_t i;
for (i = 0; i < m_asFiles .size (); i++)
{
if (stricmp (m_asFiles [i] .strName .c_str (), pszTemp) == 0)
Expand Down
8 changes: 6 additions & 2 deletions _NscLib/NscContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,12 @@ class CNscContext

virtual void yyerror (const char *pszMessage)
{
pszMessage; // Get rid of warning 4100
// GenerateError ("%s", pszMessage);
//pszMessage; // Get rid of warning 4100
//GenerateError ("%s", pszMessage);
if (!strncmp("TOOMANY", pszMessage, 7))
GenerateMessage(NscMessage_ErrorTooManyErrors, NscMaxSyntaxErrors);
else
GenerateMessage (NscMessage_ErrorTokenSyntaxError, pszMessage);
}

// @cmember Get a PStackEntry
Expand Down
33 changes: 12 additions & 21 deletions _NscLib/NscParser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
class CNscContext;
%}

%lex-param { CNscContext& context}
%parse-param { CNscContext& context}
%lex-param { CNscContext& ctxt}
%parse-param { CNscContext& ctxt}
%define parse.error verbose

%{
#include "Precomp.h"
Expand All @@ -53,6 +54,7 @@ class CNscPStackEntry;

int yylex (YYSTYPE* yylval, CNscContext& context);
int yylex (YYSTYPE* yylval);
void yyerror (const char *pszMessage);

YYSTYPE NscBuildIdentifier (YYSTYPE p);
YYSTYPE NscBuildObjectConstant (int nOID);
Expand Down Expand Up @@ -95,7 +97,6 @@ YYSTYPE NscBuildBlankStatement ();
YYSTYPE NscBuildMarkLine (int nIndex, YYSTYPE pStatement);
void NscBuildSaveLine (int nIndex);
void NscBuildCopyLine (int nDest, int nSource);
bool NscBuildSyntaxError (int nToken, YYSTYPE yylval);
%}

%token IDENTIFIER INTEGER_CONST FLOAT_CONST STRING_CONST
Expand Down Expand Up @@ -693,17 +694,14 @@ expression_statement:
| error
{
$$ = NULL;
if (NscBuildSyntaxError (YYCHAR_NAME, YYLVAL))
if (yynerrs_ >= NscMaxSyntaxErrors) {
error("TOOMANY");
YYABORT;
while (YYCHAR_NAME != EOF && YYCHAR_NAME != ';' && YYCHAR_NAME != '{' && YYCHAR_NAME != '}')
{
if (YYLVAL != NULL)
YYLVAL;
YYLA_EMPTY;
YYLA_CHARNAME_LEX;
}
if (YYCHAR_NAME == ';')
YYLA_EMPTY;
// clear lookahead. Unless it's '}' because that confuses the unwinder
// and you get a lot of extra errors.
if (yyla.type_get() != 74)
yyclearin;
}
;

Expand Down Expand Up @@ -1020,16 +1018,9 @@ translation_unit:
| error
{
$$ = NULL;
if (NscBuildSyntaxError (YYCHAR_NAME, YYLVAL))
if (yynerrs_ >= NscMaxSyntaxErrors)
YYABORT;
while (YYCHAR_NAME != EOF && YYCHAR_NAME != ';' && YYCHAR_NAME != '{' && YYCHAR_NAME != '}')
{
if (YYLVAL != NULL)
YYLVAL;
YYLA_EMPTY;
YYLA_CHARNAME_LEX;
}
YYLA_EMPTY;
yyclearin;
}
;

Expand Down
Loading