aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_LSL_tree.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-17 10:29:48 +1000
committerDavid Walter Seikel2012-01-17 10:29:48 +1000
commitdc7af57b02a95b67fa4dc556861d327a020428bc (patch)
tree4cf32c36e25953ef8c21f3f50e39e9d58c260108 /LuaSL/src/LuaSL_LSL_tree.h
parentDisable the file compare for now, got lots to add before it will work again. (diff)
downloadSledjHamr-dc7af57b02a95b67fa4dc556861d327a020428bc.zip
SledjHamr-dc7af57b02a95b67fa4dc556861d327a020428bc.tar.gz
SledjHamr-dc7af57b02a95b67fa4dc556861d327a020428bc.tar.bz2
SledjHamr-dc7af57b02a95b67fa4dc556861d327a020428bc.tar.xz
Parser now understands state, function, and variable derlarations. Including scope. :-P
Diffstat (limited to 'LuaSL/src/LuaSL_LSL_tree.h')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h59
1 files changed, 36 insertions, 23 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index b547976..4113454 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -2,7 +2,7 @@
2#ifndef __LSL_TREE_H__ 2#ifndef __LSL_TREE_H__
3#define __LSL_TREE_H__ 3#define __LSL_TREE_H__
4 4
5#define LUASL_DEBUG 5//#define LUASL_DEBUG
6 6
7 7
8#include <stddef.h> // So we can have NULL defined. 8#include <stddef.h> // So we can have NULL defined.
@@ -218,8 +218,9 @@ struct _LSL_Leaf
218struct _LSL_Parenthesis 218struct _LSL_Parenthesis
219{ 219{
220 LSL_Leaf *left; 220 LSL_Leaf *left;
221 LSL_Leaf *expression; 221 LSL_Leaf *contents;
222 LSL_Leaf *right; 222 LSL_Leaf *right;
223 LSL_Type type;
223}; 224};
224 225
225struct _LSL_Identifier // For variables and function parameters. 226struct _LSL_Identifier // For variables and function parameters.
@@ -237,30 +238,32 @@ struct _LSL_Statement
237struct _LSL_Block 238struct _LSL_Block
238{ 239{
239 LSL_Block *outerBlock; 240 LSL_Block *outerBlock;
240 LSL_Statement *statements; 241 LSL_Statement **statements;
241 LSL_Identifier *scopeVariables; 242 LSL_Identifier **variables; // Those variables in this scope.
243 int scount, vcount;
242}; 244};
243 245
244struct _LSL_Function 246struct _LSL_Function
245{ 247{
246 char *name; 248 char *name;
247 LSL_Block block; 249 LSL_Leaf *type;
248 LSL_Identifier *parameters; 250 LSL_Leaf *params;
249 LSL_Type type; // Return type. 251 LSL_Leaf *block;
250}; 252};
251 253
252struct _LSL_State 254struct _LSL_State
253{ 255{
254 char *name; 256 char *name;
255 LSL_Function *handlers; 257 LSL_Function **handlers;
256}; 258};
257 259
258struct _LSL_Script 260struct _LSL_Script
259{ 261{
260 char *name; 262 char *name;
261 LSL_Function *functions; 263 LSL_Function **functions;
262 LSL_State *states; 264 LSL_State **states;
263 LSL_Identifier *variables; 265 LSL_Identifier **variables;
266 int fcount, scount, vcount;
264}; 267};
265 268
266// Define the type for flex and lemon. 269// Define the type for flex and lemon.
@@ -268,15 +271,18 @@ struct _LSL_Script
268 271
269typedef struct 272typedef struct
270{ 273{
271 void *scanner; // This should be of type yyscan_t, which is typedef to void * anyway, but that does not get defined until LuaSL_lexer.h, which depends on this struct being defined first. 274 void *scanner; // This should be of type yyscan_t, which is typedef to void * anyway, but that does not get defined until LuaSL_lexer.h, which depends on this struct being defined first.
272 int argc; 275 int argc;
273 char **argv; 276 char **argv;
274 char fileName[PATH_MAX]; 277 char fileName[PATH_MAX];
275 FILE *file; 278 FILE *file;
276 LSL_Leaf *ast; 279 LSL_Leaf *ast;
277 char *ignorableText; 280 LSL_Script script;
278 LSL_Leaf *lval; 281 char *ignorableText;
279 int column, line; 282 LSL_Leaf *lval;
283 int column, line;
284 LSL_Block *currentBlock;
285 LSL_Leaf *currentFunction;
280} LuaSL_yyparseParam; 286} LuaSL_yyparseParam;
281 287
282 288
@@ -286,11 +292,18 @@ typedef struct
286 292
287 293
288void burnLeaf(LSL_Leaf *leaf); 294void burnLeaf(LSL_Leaf *leaf);
289LSL_Leaf *addExpression(LSL_Leaf *exp); 295LSL_Leaf *addFunction(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close, LSL_Leaf *block);
290LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); 296LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right);
291LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); 297LSL_Leaf *addParameter(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *newParam);
298LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf *rval);
299LSL_Leaf *addState(LuaSL_yyparseParam *param, char *name, LSL_Leaf *state);
292LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr); 300LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr);
293LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr); 301LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr);
302LSL_Leaf *addVariable(LuaSL_yyparseParam *param, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr);
303
304void beginBlock(LuaSL_yyparseParam *param, LSL_Leaf *block);
305LSL_Leaf *collectParameters(LuaSL_yyparseParam *param, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam);
306void endBlock(LuaSL_yyparseParam *param, LSL_Leaf *block);
294 307
295void *ParseAlloc(void *(*mallocProc)(size_t)); 308void *ParseAlloc(void *(*mallocProc)(size_t));
296void ParseTrace(FILE *TraceFILE, char *zTracePrompt); 309void ParseTrace(FILE *TraceFILE, char *zTracePrompt);