From 4475fbd8d0c40f42aa7e14ccb5fbec59b31e4b4c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 5 Jan 2012 10:10:50 +1000 Subject: Consolidate the parser includes. --- LuaSL/src/LuaSL_LSL_tree.c | 3 +-- LuaSL/src/LuaSL_LSL_tree.h | 59 ++++++++++++++++++++++++++++++++++++++++++ LuaSL/src/LuaSL_lexer.l | 16 ++++++++++-- LuaSL/src/LuaSL_parser_param.h | 38 --------------------------- LuaSL/src/LuaSL_type_parser.h | 45 -------------------------------- LuaSL/src/LuaSL_yaccer.y | 3 +-- 6 files changed, 75 insertions(+), 89 deletions(-) delete mode 100644 LuaSL/src/LuaSL_parser_param.h delete mode 100644 LuaSL/src/LuaSL_type_parser.h (limited to 'LuaSL') diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index 7ea5d67..7cebecc 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c @@ -2,8 +2,7 @@ * Implementation of functions used to build the abstract syntax tree. */ -#include "LuaSL_parser_param.h" -#include "LuaSL_yaccer.tab.h" +#include "LuaSL_LSL_tree.h" #include /** diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 71d372e..9c27a8f 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -4,6 +4,11 @@ #ifndef __EXPRESSION_H__ #define __EXPRESSION_H__ +#ifndef YY_NO_UNISTD_H +#define YY_NO_UNISTD_H 1 +#endif // YY_NO_UNISTD_H + + /** * @brief The operation type */ @@ -27,6 +32,57 @@ typedef struct tagSExpression } SExpression; /** + * @brief The structure used by flex and bison + */ +typedef union tagTypeParser +{ + SExpression *expression; + int value; + int ival; + float fval; + char *sval; +// class LLScriptType *type; +// class LLScriptConstant *constant; +// class LLScriptIdentifier *identifier; +// class LLScriptSimpleAssignable *assignable; +// class LLScriptGlobalVariable *global; +// class LLScriptEvent *event; +// class LLScriptEventHandler *handler; +// class LLScriptExpression *expression; +// class LLScriptStatement *statement; +// class LLScriptGlobalFunctions *global_funcs; +// class LLScriptFunctionDec *global_decl; +// class LLScriptState *state; +// class LLScritpGlobalStorage *global_store; +// class LLScriptScript *script; +}STypeParser; + +// define the type for flex and bison +#define YYSTYPE STypeParser + + +#ifndef excludeLexer + #include "LuaSL_lexer.h" +#endif + + +/** + * @brief structure given as argument to the reentrant 'yyparse' function. + */ +typedef struct tagSParserParam +{ + yyscan_t scanner; + SExpression *expression; +}SParserParam; + +// the parameter name (of the reentrant 'yyparse' function) +// data is a pointer to a 'SParserParam' structure +#define YYPARSE_PARAM data + +// the argument for the 'yylex' function +#define YYLEX_PARAM ((SParserParam*)data)->scanner + +/** * @brief It creates an identifier * @param value The number value * @return The expression or NULL in case of no memory @@ -55,5 +111,8 @@ int evaluate(SExpression *e); int yyerror(const char *msg); int yyparse(void *param); +#include "LuaSL_yaccer.tab.h" + + #endif // __EXPRESSION_H__ diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index f55d458..93dd39c 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l @@ -1,7 +1,7 @@ %{ -#include "LuaSL_type_parser.h" -#include "LuaSL_yaccer.tab.h" +#define excludeLexer +#include "LuaSL_LSL_tree.h" %} @@ -29,3 +29,15 @@ WS [ \r\n\t]* %% +int XXyywrap() +{ +#ifdef FLEX_SCANNER + #ifndef LL_WINDOWS + // get gcc to stop complaining about lack of use of yyunput + (void) yyunput; + (void) input; + #endif +#endif + return(1); +} + diff --git a/LuaSL/src/LuaSL_parser_param.h b/LuaSL/src/LuaSL_parser_param.h deleted file mode 100644 index 944a671..0000000 --- a/LuaSL/src/LuaSL_parser_param.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * ParserParam.h - * Definitions of the parameters for the reentrant functions - * of flex (yylex) and bison (yyparse) - */ - -// Since in this sample we use the reentrant version of both flex and yacc we are forced to provide parameters for the yylex function, when called from yyparse. - -#ifndef __PARSERPARAM_H__ -#define __PARSERPARAM_H__ - -#ifndef YY_NO_UNISTD_H -#define YY_NO_UNISTD_H 1 -#endif // YY_NO_UNISTD_H - -#include "LuaSL_type_parser.h" -#include "LuaSL_lexer.h" -#include "LuaSL_LSL_tree.h" - -/** - * @brief structure given as argument to the reentrant 'yyparse' function. - */ -typedef struct tagSParserParam -{ - yyscan_t scanner; - SExpression *expression; -}SParserParam; - -// the parameter name (of the reentrant 'yyparse' function) -// data is a pointer to a 'SParserParam' structure -#define YYPARSE_PARAM data - -// the argument for the 'yylex' function -#define YYLEX_PARAM ((SParserParam*)data)->scanner - -#endif // __PARSERPARAM_H__ - - diff --git a/LuaSL/src/LuaSL_type_parser.h b/LuaSL/src/LuaSL_type_parser.h deleted file mode 100644 index 76842db..0000000 --- a/LuaSL/src/LuaSL_type_parser.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * TypeParser.h - * Definition of the structure used internally by the parser and lexer - * to exchange data. - */ - -#ifndef __TYPE_PARSER_H__ -#define __TYPE_PARSER_H__ - -#include "LuaSL_LSL_tree.h" - -/** - * @brief The structure used by flex and bison - */ -typedef union tagTypeParser -{ - SExpression *expression; - int value; - int ival; - float fval; - char *sval; -// class LLScriptType *type; -// class LLScriptConstant *constant; -// class LLScriptIdentifier *identifier; -// class LLScriptSimpleAssignable *assignable; -// class LLScriptGlobalVariable *global; -// class LLScriptEvent *event; -// class LLScriptEventHandler *handler; -// class LLScriptExpression *expression; -// class LLScriptStatement *statement; -// class LLScriptGlobalFunctions *global_funcs; -// class LLScriptFunctionDec *global_decl; -// class LLScriptState *state; -// class LLScritpGlobalStorage *global_store; -// class LLScriptScript *script; -}STypeParser; - -// define the type for flex and bison -#define YYSTYPE STypeParser - -int yyerror(const char *msg); - - -#endif // __TYPE_PARSER_H__ - diff --git a/LuaSL/src/LuaSL_yaccer.y b/LuaSL/src/LuaSL_yaccer.y index 07f1fd7..19009bf 100644 --- a/LuaSL/src/LuaSL_yaccer.y +++ b/LuaSL/src/LuaSL_yaccer.y @@ -1,7 +1,6 @@ %{ -#include "LuaSL_parser_param.h" -#include "LuaSL_yaccer.tab.h" +#include "LuaSL_LSL_tree.h" %} -- cgit v1.1