aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_LSL_tree.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-12 03:14:17 +1000
committerDavid Walter Seikel2012-01-12 03:14:17 +1000
commitfc5d487de27aa7aa17502008c848d06758223888 (patch)
tree8f3007f53f49c146ae6c30a100decd3b3a0af1dd /LuaSL/src/LuaSL_LSL_tree.h
parentLeaf cloner. (diff)
downloadSledjHamr-fc5d487de27aa7aa17502008c848d06758223888.zip
SledjHamr-fc5d487de27aa7aa17502008c848d06758223888.tar.gz
SledjHamr-fc5d487de27aa7aa17502008c848d06758223888.tar.bz2
SledjHamr-fc5d487de27aa7aa17502008c848d06758223888.tar.xz
Switch to the lemon parser.
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h47
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
23typedef struct _LSL_Token LSL_Token; 36typedef struct _LSL_Token LSL_Token;
24typedef struct _LSL_Leaf LSL_Leaf; 37typedef struct _LSL_Leaf LSL_Leaf;
38typedef struct _LSL_Parenthesis LSL_Parenthesis;
25typedef struct _LSL_Identifier LSL_Identifier; 39typedef struct _LSL_Identifier LSL_Identifier;
26typedef struct _LSL_Statement LSL_Statement; 40typedef struct _LSL_Statement LSL_Statement;
27typedef struct _LSL_Block LSL_Block; 41typedef 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
60struct _LSL_Token 75struct _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
134struct _LSL_Parenthesis
135{
136 LSL_Leaf *left;
137 LSL_Leaf *expression;
138 LSL_Leaf *right;
139};
140
118struct _LSL_Identifier // For variables and function parameters. 141struct _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.
124struct _LSL_Statement 147struct _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
129struct _LSL_Block 153struct _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 206void burnLeaf(LSL_Leaf *leaf);
180LSL_Leaf *addExpression(LSL_Leaf *exp); 207LSL_Leaf *addExpression(LSL_Leaf *exp);
181LSL_Leaf *addInteger(LSL_Leaf *lval, int value);
182LSL_Leaf *addOperation(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *right); 208LSL_Leaf *addOperation(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *right);
183LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr); 209LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval);
184LSL_Statement *createStatement(LSL_Type type, LSL_Leaf *root); 210LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr);
185LSL_Leaf *addStatement(LSL_Statement *statement, LSL_Leaf *root);
186 211
187int yyerror(const char *msg); 212int yyerror(const char *msg);
188int yyparse(void *param); 213
214void *ParseAlloc(void *(*mallocProc)(size_t));
215void ParseTrace(FILE *TraceFILE, char *zTracePrompt);
216void Parse(void *yyp, int yymajor, LSL_Leaf *yyminor, LuaSL_yyparseParam *param);
217void ParseFree(void *p, void (*freeProc)(void*));
189 218
190 219
191#endif // __EXPRESSION_H__ 220#endif // __EXPRESSION_H__