diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 163 |
1 files changed, 69 insertions, 94 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 271f4a8..a392474 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | |
2 | * Definition of the structure used to build the abstract syntax tree. | ||
3 | */ | ||
4 | #ifndef __EXPRESSION_H__ | 2 | #ifndef __EXPRESSION_H__ |
5 | #define __EXPRESSION_H__ | 3 | #define __EXPRESSION_H__ |
6 | 4 | ||
@@ -215,110 +213,84 @@ char *LSL_Keywords[] = | |||
215 | }; | 213 | }; |
216 | #endif | 214 | #endif |
217 | 215 | ||
218 | typedef union | ||
219 | { | ||
220 | float floatValue; | ||
221 | int integerValue; | ||
222 | char *stringValue; | ||
223 | char *keyValue; | ||
224 | float vectorValue[3]; | ||
225 | float rotationValue[4]; | ||
226 | union LSL_Leaf *listValue; | ||
227 | } LSL_Value; | ||
228 | |||
229 | typedef struct | ||
230 | { | ||
231 | char *name; | ||
232 | LSL_Type type; | ||
233 | LSL_Value value; | ||
234 | } LSL_Identifier; | ||
235 | |||
236 | typedef struct LSL_Expression | ||
237 | { | ||
238 | struct LSL_Expression *left; | ||
239 | struct LSL_Expression *right; | ||
240 | LSL_Value value; | ||
241 | LSL_Operation expression; | ||
242 | LSL_Type type; | ||
243 | } LSL_Expression; | ||
244 | |||
245 | typedef struct | 216 | typedef struct |
246 | { | 217 | { |
247 | LSL_Type type; | 218 | LSL_Type type; |
248 | LSL_Expression *expressions; | 219 | struct LSL_Expression *expressions; |
249 | } LSL_Statement; | 220 | } LSL_Statement; |
250 | 221 | ||
251 | typedef struct | 222 | typedef struct |
252 | { | 223 | { |
253 | LSL_Statement *statements; | 224 | LSL_Statement *statements; |
254 | } LSL_Block; | 225 | } LSL_Block; |
255 | 226 | ||
256 | typedef struct | 227 | typedef struct |
257 | { | 228 | { |
258 | char *name; | 229 | char *name; |
259 | LSL_Identifier *parameters; | 230 | struct LSL_Identifier *parameters; |
260 | LSL_Block block; | 231 | LSL_Block block; |
261 | LSL_Type type; | 232 | LSL_Type type; |
262 | } LSL_Function; | 233 | } LSL_Function; |
263 | 234 | ||
264 | typedef struct | 235 | typedef struct |
265 | { | 236 | { |
266 | char *name; | 237 | char *name; |
267 | LSL_Function *handlers; | 238 | LSL_Function *handlers; |
268 | } LSL_State; | 239 | } LSL_State; |
269 | 240 | ||
270 | typedef struct | 241 | typedef struct |
271 | { | 242 | { |
272 | char *name; | 243 | char *name; |
273 | LSL_Identifier *variables; | 244 | struct LSL_Identifier *variables; |
274 | LSL_Function *functions; | 245 | LSL_Function *functions; |
275 | LSL_State *states; | 246 | LSL_State *states; |
276 | } LSL_Script; | 247 | } LSL_Script; |
277 | 248 | ||
278 | typedef union LSL_Leaf | 249 | typedef union LSL_Leaf |
279 | { | 250 | { |
280 | char *commentValue; | 251 | char *commentValue; |
281 | LSL_Type typeValue; | 252 | LSL_Type typeValue; |
282 | char *nameValue; | 253 | char *nameValue; |
283 | LSL_Identifier *identifierValue; | 254 | struct LSL_Identifier *identifierValue; |
284 | float floatValue; | 255 | float floatValue; |
285 | int integerValue; | 256 | int integerValue; |
286 | char *stringValue; | 257 | char *stringValue; |
287 | char *keyValue; | 258 | char *keyValue; |
288 | float vectorValue[3]; | 259 | float vectorValue[3]; |
289 | float rotationValue[4]; | 260 | float rotationValue[4]; |
290 | union LSL_Leaf *listValue; | 261 | union LSL_Leaf *listValue; |
291 | char *labelValue; | 262 | char *labelValue; |
292 | // LSL_Operation expressionValue; | 263 | LSL_Operation operationValue; |
293 | LSL_Expression *expressionValue; | 264 | struct LSL_Expression *expressionValue; |
294 | LSL_Statement *doValue; | 265 | LSL_Statement *doValue; |
295 | LSL_Statement *forValue; | 266 | LSL_Statement *forValue; |
296 | LSL_Statement *ifValue; | 267 | LSL_Statement *ifValue; |
297 | LSL_Statement *elseValue; | 268 | LSL_Statement *elseValue; |
298 | LSL_Statement *elseIfValue; | 269 | LSL_Statement *elseIfValue; |
299 | char *jumpValue; | 270 | char *jumpValue; |
300 | char *stateChangeValue; | 271 | char *stateChangeValue; |
301 | LSL_Statement *statementValue; | 272 | LSL_Statement *statementValue; |
302 | LSL_Identifier *parameterValue; | 273 | struct LSL_Identifier *parameterValue; |
303 | LSL_Function *functionValue; | 274 | LSL_Function *functionValue; |
304 | LSL_State *stateValue; | 275 | LSL_State *stateValue; |
305 | LSL_Script *scriptValue; | 276 | LSL_Script *scriptValue; |
306 | // class LLScriptType *type; | ||
307 | // class LLScriptConstant *constant; | ||
308 | // class LLScriptIdentifier *identifier; | ||
309 | // class LLScriptSimpleAssignable *assignable; | ||
310 | // class LLScriptGlobalVariable *global; | ||
311 | // class LLScriptEvent *event; | ||
312 | // class LLScriptEventHandler *handler; | ||
313 | // class LLScriptExpression *expression; | ||
314 | // class LLScriptStatement *statement; | ||
315 | // class LLScriptGlobalFunctions *global_funcs; | ||
316 | // class LLScriptFunctionDec *global_decl; | ||
317 | // class LLScriptState *state; | ||
318 | // class LLScritpGlobalStorage *global_store; | ||
319 | // class LLScriptScript *script; | ||
320 | } LSL_Leaf; | 277 | } LSL_Leaf; |
321 | 278 | ||
279 | typedef struct | ||
280 | { | ||
281 | char *name; | ||
282 | LSL_Type type; | ||
283 | LSL_Leaf content; | ||
284 | } LSL_Identifier; | ||
285 | |||
286 | typedef struct LSL_Expression | ||
287 | { | ||
288 | struct LSL_Expression *left; | ||
289 | struct LSL_Expression *right; | ||
290 | LSL_Type type; | ||
291 | LSL_Leaf content; | ||
292 | } LSL_Expression; | ||
293 | |||
322 | typedef struct LSL_AST | 294 | typedef struct LSL_AST |
323 | { | 295 | { |
324 | struct LSL_AST *left; | 296 | struct LSL_AST *left; |
@@ -342,19 +314,9 @@ typedef struct LSL_AST | |||
342 | typedef struct | 314 | typedef struct |
343 | { | 315 | { |
344 | yyscan_t scanner; | 316 | yyscan_t scanner; |
345 | LSL_Expression *expression; | 317 | LSL_AST *ast; |
346 | } LuaSL_yyparseParam; | 318 | } LuaSL_yyparseParam; |
347 | 319 | ||
348 | |||
349 | void burnLeaf(LSL_AST *leaf); | ||
350 | void burnLSLExpression(LSL_Expression *exp); | ||
351 | LSL_Expression *addInteger(int value); | ||
352 | LSL_Expression *addOperation(LSL_Operation type, LSL_Expression *left, LSL_Expression *right); | ||
353 | LSL_Expression *newTree(const char *expr); | ||
354 | int evaluateExpression(LSL_Expression *exp, int old); | ||
355 | void outputExpression(LSL_Expression *exp); | ||
356 | void convertExpression2Lua(LSL_Expression *exp); | ||
357 | |||
358 | // the parameter name (of the reentrant 'yyparse' function) | 320 | // the parameter name (of the reentrant 'yyparse' function) |
359 | // data is a pointer to a 'SParserParam' structure | 321 | // data is a pointer to a 'SParserParam' structure |
360 | #define YYPARSE_PARAM data | 322 | #define YYPARSE_PARAM data |
@@ -362,6 +324,19 @@ void convertExpression2Lua(LSL_Expression *exp); | |||
362 | // the argument for the 'yylex' function | 324 | // the argument for the 'yylex' function |
363 | #define YYLEX_PARAM ((LuaSL_yyparseParam*)data)->scanner | 325 | #define YYLEX_PARAM ((LuaSL_yyparseParam*)data)->scanner |
364 | 326 | ||
327 | |||
328 | void burnLSLExpression(LSL_Expression *exp); | ||
329 | void burnAST(LSL_AST *ast); | ||
330 | LSL_AST *addExpression(LSL_Expression *exp); | ||
331 | LSL_Expression *addInteger(int value); | ||
332 | LSL_Expression *addOperation(LSL_Operation type, LSL_Expression *left, LSL_Expression *right); | ||
333 | int evaluateExpression(LSL_Expression *exp, int old); | ||
334 | int evaluateAST(LSL_AST *ast, int old); | ||
335 | void outputExpression(LSL_Expression *exp); | ||
336 | void outputAST(LSL_AST *ast); | ||
337 | void convertAST2Lua(LSL_AST *ast); | ||
338 | LSL_AST *newTree(const char *expr); | ||
339 | |||
365 | int yyerror(const char *msg); | 340 | int yyerror(const char *msg); |
366 | int yyparse(void *param); | 341 | int yyparse(void *param); |
367 | 342 | ||