diff options
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.c | 3 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 59 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 16 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_parser_param.h | 38 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_type_parser.h | 45 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_yaccer.y | 3 |
6 files changed, 75 insertions, 89 deletions
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 @@ | |||
2 | * Implementation of functions used to build the abstract syntax tree. | 2 | * Implementation of functions used to build the abstract syntax tree. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "LuaSL_parser_param.h" | 5 | #include "LuaSL_LSL_tree.h" |
6 | #include "LuaSL_yaccer.tab.h" | ||
7 | #include <stdlib.h> | 6 | #include <stdlib.h> |
8 | 7 | ||
9 | /** | 8 | /** |
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 @@ | |||
4 | #ifndef __EXPRESSION_H__ | 4 | #ifndef __EXPRESSION_H__ |
5 | #define __EXPRESSION_H__ | 5 | #define __EXPRESSION_H__ |
6 | 6 | ||
7 | #ifndef YY_NO_UNISTD_H | ||
8 | #define YY_NO_UNISTD_H 1 | ||
9 | #endif // YY_NO_UNISTD_H | ||
10 | |||
11 | |||
7 | /** | 12 | /** |
8 | * @brief The operation type | 13 | * @brief The operation type |
9 | */ | 14 | */ |
@@ -27,6 +32,57 @@ typedef struct tagSExpression | |||
27 | } SExpression; | 32 | } SExpression; |
28 | 33 | ||
29 | /** | 34 | /** |
35 | * @brief The structure used by flex and bison | ||
36 | */ | ||
37 | typedef union tagTypeParser | ||
38 | { | ||
39 | SExpression *expression; | ||
40 | int value; | ||
41 | int ival; | ||
42 | float fval; | ||
43 | char *sval; | ||
44 | // class LLScriptType *type; | ||
45 | // class LLScriptConstant *constant; | ||
46 | // class LLScriptIdentifier *identifier; | ||
47 | // class LLScriptSimpleAssignable *assignable; | ||
48 | // class LLScriptGlobalVariable *global; | ||
49 | // class LLScriptEvent *event; | ||
50 | // class LLScriptEventHandler *handler; | ||
51 | // class LLScriptExpression *expression; | ||
52 | // class LLScriptStatement *statement; | ||
53 | // class LLScriptGlobalFunctions *global_funcs; | ||
54 | // class LLScriptFunctionDec *global_decl; | ||
55 | // class LLScriptState *state; | ||
56 | // class LLScritpGlobalStorage *global_store; | ||
57 | // class LLScriptScript *script; | ||
58 | }STypeParser; | ||
59 | |||
60 | // define the type for flex and bison | ||
61 | #define YYSTYPE STypeParser | ||
62 | |||
63 | |||
64 | #ifndef excludeLexer | ||
65 | #include "LuaSL_lexer.h" | ||
66 | #endif | ||
67 | |||
68 | |||
69 | /** | ||
70 | * @brief structure given as argument to the reentrant 'yyparse' function. | ||
71 | */ | ||
72 | typedef struct tagSParserParam | ||
73 | { | ||
74 | yyscan_t scanner; | ||
75 | SExpression *expression; | ||
76 | }SParserParam; | ||
77 | |||
78 | // the parameter name (of the reentrant 'yyparse' function) | ||
79 | // data is a pointer to a 'SParserParam' structure | ||
80 | #define YYPARSE_PARAM data | ||
81 | |||
82 | // the argument for the 'yylex' function | ||
83 | #define YYLEX_PARAM ((SParserParam*)data)->scanner | ||
84 | |||
85 | /** | ||
30 | * @brief It creates an identifier | 86 | * @brief It creates an identifier |
31 | * @param value The number value | 87 | * @param value The number value |
32 | * @return The expression or NULL in case of no memory | 88 | * @return The expression or NULL in case of no memory |
@@ -55,5 +111,8 @@ int evaluate(SExpression *e); | |||
55 | int yyerror(const char *msg); | 111 | int yyerror(const char *msg); |
56 | int yyparse(void *param); | 112 | int yyparse(void *param); |
57 | 113 | ||
114 | #include "LuaSL_yaccer.tab.h" | ||
115 | |||
116 | |||
58 | #endif // __EXPRESSION_H__ | 117 | #endif // __EXPRESSION_H__ |
59 | 118 | ||
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 @@ | |||
1 | %{ | 1 | %{ |
2 | 2 | ||
3 | #include "LuaSL_type_parser.h" | 3 | #define excludeLexer |
4 | #include "LuaSL_yaccer.tab.h" | 4 | #include "LuaSL_LSL_tree.h" |
5 | 5 | ||
6 | %} | 6 | %} |
7 | 7 | ||
@@ -29,3 +29,15 @@ WS [ \r\n\t]* | |||
29 | 29 | ||
30 | %% | 30 | %% |
31 | 31 | ||
32 | int XXyywrap() | ||
33 | { | ||
34 | #ifdef FLEX_SCANNER | ||
35 | #ifndef LL_WINDOWS | ||
36 | // get gcc to stop complaining about lack of use of yyunput | ||
37 | (void) yyunput; | ||
38 | (void) input; | ||
39 | #endif | ||
40 | #endif | ||
41 | return(1); | ||
42 | } | ||
43 | |||
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 @@ | |||
1 | /* | ||
2 | * ParserParam.h | ||
3 | * Definitions of the parameters for the reentrant functions | ||
4 | * of flex (yylex) and bison (yyparse) | ||
5 | */ | ||
6 | |||
7 | // 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. | ||
8 | |||
9 | #ifndef __PARSERPARAM_H__ | ||
10 | #define __PARSERPARAM_H__ | ||
11 | |||
12 | #ifndef YY_NO_UNISTD_H | ||
13 | #define YY_NO_UNISTD_H 1 | ||
14 | #endif // YY_NO_UNISTD_H | ||
15 | |||
16 | #include "LuaSL_type_parser.h" | ||
17 | #include "LuaSL_lexer.h" | ||
18 | #include "LuaSL_LSL_tree.h" | ||
19 | |||
20 | /** | ||
21 | * @brief structure given as argument to the reentrant 'yyparse' function. | ||
22 | */ | ||
23 | typedef struct tagSParserParam | ||
24 | { | ||
25 | yyscan_t scanner; | ||
26 | SExpression *expression; | ||
27 | }SParserParam; | ||
28 | |||
29 | // the parameter name (of the reentrant 'yyparse' function) | ||
30 | // data is a pointer to a 'SParserParam' structure | ||
31 | #define YYPARSE_PARAM data | ||
32 | |||
33 | // the argument for the 'yylex' function | ||
34 | #define YYLEX_PARAM ((SParserParam*)data)->scanner | ||
35 | |||
36 | #endif // __PARSERPARAM_H__ | ||
37 | |||
38 | |||
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 @@ | |||
1 | /* | ||
2 | * TypeParser.h | ||
3 | * Definition of the structure used internally by the parser and lexer | ||
4 | * to exchange data. | ||
5 | */ | ||
6 | |||
7 | #ifndef __TYPE_PARSER_H__ | ||
8 | #define __TYPE_PARSER_H__ | ||
9 | |||
10 | #include "LuaSL_LSL_tree.h" | ||
11 | |||
12 | /** | ||
13 | * @brief The structure used by flex and bison | ||
14 | */ | ||
15 | typedef union tagTypeParser | ||
16 | { | ||
17 | SExpression *expression; | ||
18 | int value; | ||
19 | int ival; | ||
20 | float fval; | ||
21 | char *sval; | ||
22 | // class LLScriptType *type; | ||
23 | // class LLScriptConstant *constant; | ||
24 | // class LLScriptIdentifier *identifier; | ||
25 | // class LLScriptSimpleAssignable *assignable; | ||
26 | // class LLScriptGlobalVariable *global; | ||
27 | // class LLScriptEvent *event; | ||
28 | // class LLScriptEventHandler *handler; | ||
29 | // class LLScriptExpression *expression; | ||
30 | // class LLScriptStatement *statement; | ||
31 | // class LLScriptGlobalFunctions *global_funcs; | ||
32 | // class LLScriptFunctionDec *global_decl; | ||
33 | // class LLScriptState *state; | ||
34 | // class LLScritpGlobalStorage *global_store; | ||
35 | // class LLScriptScript *script; | ||
36 | }STypeParser; | ||
37 | |||
38 | // define the type for flex and bison | ||
39 | #define YYSTYPE STypeParser | ||
40 | |||
41 | int yyerror(const char *msg); | ||
42 | |||
43 | |||
44 | #endif // __TYPE_PARSER_H__ | ||
45 | |||
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 @@ | |||
1 | %{ | 1 | %{ |
2 | 2 | ||
3 | #include "LuaSL_parser_param.h" | 3 | #include "LuaSL_LSL_tree.h" |
4 | #include "LuaSL_yaccer.tab.h" | ||
5 | 4 | ||
6 | %} | 5 | %} |
7 | 6 | ||