diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 3fc436e..9db83d0 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -10,7 +10,20 @@ | |||
10 | #include <sys/stat.h> | 10 | #include <sys/stat.h> |
11 | #include <fcntl.h> | 11 | #include <fcntl.h> |
12 | 12 | ||
13 | #include "LuaSL_yaccer.tab.h" | 13 | //#include <iostream> |
14 | //#include <cstdlib> | ||
15 | #include "assert.h" | ||
16 | //#include "ex5def.h" | ||
17 | //#include "example5.h" | ||
18 | #include <unistd.h> | ||
19 | #include <sys/types.h> | ||
20 | #include <sys/stat.h> | ||
21 | #include <fcntl.h> | ||
22 | #include <stdlib.h> | ||
23 | //#include "lexglobal.h" | ||
24 | //#define BUFS 1024 | ||
25 | |||
26 | #include "LuaSL_lemon_yaccer.h" | ||
14 | 27 | ||
15 | #define YYERRCODE 256 | 28 | #define YYERRCODE 256 |
16 | #define YYDEBUG 1 | 29 | #define YYDEBUG 1 |
@@ -22,6 +35,7 @@ extern int yydebug; | |||
22 | 35 | ||
23 | typedef struct _LSL_Token LSL_Token; | 36 | typedef struct _LSL_Token LSL_Token; |
24 | typedef struct _LSL_Leaf LSL_Leaf; | 37 | typedef struct _LSL_Leaf LSL_Leaf; |
38 | typedef struct _LSL_Parenthesis LSL_Parenthesis; | ||
25 | typedef struct _LSL_Identifier LSL_Identifier; | 39 | typedef struct _LSL_Identifier LSL_Identifier; |
26 | typedef struct _LSL_Statement LSL_Statement; | 40 | typedef struct _LSL_Statement LSL_Statement; |
27 | typedef struct _LSL_Block LSL_Block; | 41 | typedef struct _LSL_Block LSL_Block; |
@@ -54,7 +68,8 @@ typedef enum | |||
54 | LSL_INNER2OUTER = 4, | 68 | LSL_INNER2OUTER = 4, |
55 | LSL_UNARY = 8, | 69 | LSL_UNARY = 8, |
56 | LSL_ASSIGNMENT = 16, | 70 | LSL_ASSIGNMENT = 16, |
57 | LSL_CREATION = 32 | 71 | LSL_CREATION = 32, |
72 | LSL_NOIGNORE = 64 | ||
58 | } LSL_Flags; | 73 | } LSL_Flags; |
59 | 74 | ||
60 | struct _LSL_Token | 75 | struct _LSL_Token |
@@ -78,6 +93,7 @@ struct _LSL_Leaf | |||
78 | 93 | ||
79 | LSL_Type operationValue; | 94 | LSL_Type operationValue; |
80 | LSL_Leaf *expressionValue; | 95 | LSL_Leaf *expressionValue; |
96 | LSL_Parenthesis *parenthesis; | ||
81 | 97 | ||
82 | float floatValue; | 98 | float floatValue; |
83 | int integerValue; | 99 | int integerValue; |
@@ -115,6 +131,13 @@ struct _LSL_Leaf | |||
115 | int line, column; | 131 | int line, column; |
116 | }; | 132 | }; |
117 | 133 | ||
134 | struct _LSL_Parenthesis | ||
135 | { | ||
136 | LSL_Leaf *left; | ||
137 | LSL_Leaf *expression; | ||
138 | LSL_Leaf *right; | ||
139 | }; | ||
140 | |||
118 | struct _LSL_Identifier // For variables and function parameters. | 141 | struct _LSL_Identifier // For variables and function parameters. |
119 | { | 142 | { |
120 | char *name; | 143 | char *name; |
@@ -124,6 +147,7 @@ struct _LSL_Identifier // For variables and function parameters. | |||
124 | struct _LSL_Statement | 147 | struct _LSL_Statement |
125 | { | 148 | { |
126 | LSL_Leaf *expressions; /// For things like a for statement, might hold three expressions. | 149 | LSL_Leaf *expressions; /// For things like a for statement, might hold three expressions. |
150 | LSL_Type type; // Expression type. | ||
127 | }; | 151 | }; |
128 | 152 | ||
129 | struct _LSL_Block | 153 | struct _LSL_Block |
@@ -167,25 +191,30 @@ typedef struct | |||
167 | { | 191 | { |
168 | yyscan_t scanner; | 192 | yyscan_t scanner; |
169 | LSL_Leaf *ast; | 193 | LSL_Leaf *ast; |
194 | LSL_Leaf *lval; | ||
170 | } LuaSL_yyparseParam; | 195 | } LuaSL_yyparseParam; |
171 | 196 | ||
172 | // the parameter name (of the reentrant 'yyparse' function) | 197 | // the parameter name (of the reentrant 'yyparse' function) |
173 | // data is a pointer to a 'yyparseParam' structure | 198 | // data is a pointer to a 'yyparseParam' structure |
174 | #define YYPARSE_PARAM data | 199 | //#define YYPARSE_PARAM data |
175 | 200 | ||
176 | // the argument for the 'yylex' function | 201 | // the argument for the 'yylex' function |
177 | #define YYLEX_PARAM ((LuaSL_yyparseParam*)data)->scanner | 202 | #define YYLEX_PARAM ((LuaSL_yyparseParam*)data)->scanner |
203 | //#define ParseTOKENTYPE YYSTYPE * | ||
204 | //#define ParseARG_PDECL , LuaSL_yyparseParam *param | ||
178 | 205 | ||
179 | 206 | void burnLeaf(LSL_Leaf *leaf); | |
180 | LSL_Leaf *addExpression(LSL_Leaf *exp); | 207 | LSL_Leaf *addExpression(LSL_Leaf *exp); |
181 | LSL_Leaf *addInteger(LSL_Leaf *lval, int value); | ||
182 | LSL_Leaf *addOperation(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *right); | 208 | LSL_Leaf *addOperation(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *right); |
183 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr); | 209 | LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); |
184 | LSL_Statement *createStatement(LSL_Type type, LSL_Leaf *root); | 210 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr); |
185 | LSL_Leaf *addStatement(LSL_Statement *statement, LSL_Leaf *root); | ||
186 | 211 | ||
187 | int yyerror(const char *msg); | 212 | int yyerror(const char *msg); |
188 | int yyparse(void *param); | 213 | |
214 | void *ParseAlloc(void *(*mallocProc)(size_t)); | ||
215 | void ParseTrace(FILE *TraceFILE, char *zTracePrompt); | ||
216 | void Parse(void *yyp, int yymajor, LSL_Leaf *yyminor, LuaSL_yyparseParam *param); | ||
217 | void ParseFree(void *p, void (*freeProc)(void*)); | ||
189 | 218 | ||
190 | 219 | ||
191 | #endif // __EXPRESSION_H__ | 220 | #endif // __EXPRESSION_H__ |