diff options
Diffstat (limited to 'LuaSL/src/LuaSL_lemon_yaccer.y')
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 3df7def..e62776b 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y | |||
@@ -2,7 +2,7 @@ | |||
2 | #include "LuaSL.h" | 2 | #include "LuaSL.h" |
3 | } | 3 | } |
4 | 4 | ||
5 | %extra_argument {LuaSL_yyparseParam *param} | 5 | %extra_argument {LuaSL_compiler *compiler} |
6 | 6 | ||
7 | %stack_size 1024 | 7 | %stack_size 1024 |
8 | 8 | ||
@@ -14,7 +14,7 @@ | |||
14 | // The start symbol, just coz we need one. | 14 | // The start symbol, just coz we need one. |
15 | 15 | ||
16 | // Lemon does not like the start symbol to be on the RHS, so give it a dummy start symbol. | 16 | // Lemon does not like the start symbol to be on the RHS, so give it a dummy start symbol. |
17 | program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = param->ast; param->ast = A; } | 17 | program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } |
18 | 18 | ||
19 | // Various forms of "space". The lexer takes care of them for us. | 19 | // Various forms of "space". The lexer takes care of them for us. |
20 | 20 | ||
@@ -23,16 +23,16 @@ program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = param->ast; p | |||
23 | // Basic script structure. | 23 | // Basic script structure. |
24 | 24 | ||
25 | %nonassoc LSL_SCRIPT. | 25 | %nonassoc LSL_SCRIPT. |
26 | script ::= script state(A). { if (NULL != A) A->left = param->ast; param->ast = A; } | 26 | script ::= script state(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } |
27 | script ::= script function(A). { if (NULL != A) A->left = param->ast; param->ast = A; } | 27 | script ::= script function(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } |
28 | script ::= script statement(A). { if (NULL != A) A->left = param->ast; param->ast = A; } | 28 | script ::= script statement(A). { if (NULL != A) A->left = compiler->ast; compiler->ast = A; } |
29 | script ::= . | 29 | script ::= . |
30 | 30 | ||
31 | // State definitions. | 31 | // State definitions. |
32 | 32 | ||
33 | %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. | 33 | %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. |
34 | stateBlock ::= LSL_BLOCK_OPEN functionList LSL_BLOCK_CLOSE. | 34 | stateBlock ::= LSL_BLOCK_OPEN functionList LSL_BLOCK_CLOSE. |
35 | state(S) ::= LSL_IDENTIFIER(I) stateBlock(B). { S = addState(param, I, B); } | 35 | state(S) ::= LSL_IDENTIFIER(I) stateBlock(B). { S = addState(compiler, I, B); } |
36 | 36 | ||
37 | // Function definitions. | 37 | // Function definitions. |
38 | 38 | ||
@@ -89,40 +89,40 @@ exprList ::= expr. | |||
89 | exprList ::= . | 89 | exprList ::= . |
90 | 90 | ||
91 | %right LSL_BOOL_AND. | 91 | %right LSL_BOOL_AND. |
92 | expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(param, B, C, D); } | 92 | expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(compiler, B, C, D); } |
93 | %right LSL_BOOL_OR. | 93 | %right LSL_BOOL_OR. |
94 | expr(A) ::= expr(B) LSL_BOOL_OR(C) expr(D). { A = addOperation(param, B, C, D); } | 94 | expr(A) ::= expr(B) LSL_BOOL_OR(C) expr(D). { A = addOperation(compiler, B, C, D); } |
95 | 95 | ||
96 | %left LSL_BIT_AND LSL_BIT_XOR LSL_BIT_OR. | 96 | %left LSL_BIT_AND LSL_BIT_XOR LSL_BIT_OR. |
97 | expr(A) ::= expr(B) LSL_BIT_OR(C) expr(D). { A = addOperation(param, B, C, D); } | 97 | expr(A) ::= expr(B) LSL_BIT_OR(C) expr(D). { A = addOperation(compiler, B, C, D); } |
98 | expr(A) ::= expr(B) LSL_BIT_XOR(C) expr(D). { A = addOperation(param, B, C, D); } | 98 | expr(A) ::= expr(B) LSL_BIT_XOR(C) expr(D). { A = addOperation(compiler, B, C, D); } |
99 | expr(A) ::= expr(B) LSL_BIT_AND(C) expr(D). { A = addOperation(param, B, C, D); } | 99 | expr(A) ::= expr(B) LSL_BIT_AND(C) expr(D). { A = addOperation(compiler, B, C, D); } |
100 | 100 | ||
101 | %right LSL_EQUAL LSL_NOT_EQUAL. | 101 | %right LSL_EQUAL LSL_NOT_EQUAL. |
102 | expr(A) ::= expr(B) LSL_NOT_EQUAL(C) expr(D). { A = addOperation(param, B, C, D); } | 102 | expr(A) ::= expr(B) LSL_NOT_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } |
103 | expr(A) ::= expr(B) LSL_EQUAL(C) expr(D). { A = addOperation(param, B, C, D); } | 103 | expr(A) ::= expr(B) LSL_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } |
104 | %right LSL_LESS_THAN LSL_GREATER_THAN LSL_LESS_EQUAL LSL_GREATER_EQUAL. | 104 | %right LSL_LESS_THAN LSL_GREATER_THAN LSL_LESS_EQUAL LSL_GREATER_EQUAL. |
105 | expr(A) ::= expr(B) LSL_GREATER_EQUAL(C) expr(D). { A = addOperation(param, B, C, D); } | 105 | expr(A) ::= expr(B) LSL_GREATER_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } |
106 | expr(A) ::= expr(B) LSL_LESS_EQUAL(C) expr(D). { A = addOperation(param, B, C, D); } | 106 | expr(A) ::= expr(B) LSL_LESS_EQUAL(C) expr(D). { A = addOperation(compiler, B, C, D); } |
107 | expr(A) ::= expr(B) LSL_GREATER_THAN(C) expr(D). { A = addOperation(param, B, C, D); } | 107 | expr(A) ::= expr(B) LSL_GREATER_THAN(C) expr(D). { A = addOperation(compiler, B, C, D); } |
108 | expr(A) ::= expr(B) LSL_LESS_THAN(C) expr(D). { A = addOperation(param, B, C, D); } | 108 | expr(A) ::= expr(B) LSL_LESS_THAN(C) expr(D). { A = addOperation(compiler, B, C, D); } |
109 | 109 | ||
110 | %left LSL_LEFT_SHIFT LSL_RIGHT_SHIFT. | 110 | %left LSL_LEFT_SHIFT LSL_RIGHT_SHIFT. |
111 | expr(A) ::= expr(B) LSL_RIGHT_SHIFT(C) expr(D). { A = addOperation(param, B, C, D); } | 111 | expr(A) ::= expr(B) LSL_RIGHT_SHIFT(C) expr(D). { A = addOperation(compiler, B, C, D); } |
112 | expr(A) ::= expr(B) LSL_LEFT_SHIFT(C) expr(D). { A = addOperation(param, B, C, D); } | 112 | expr(A) ::= expr(B) LSL_LEFT_SHIFT(C) expr(D). { A = addOperation(compiler, B, C, D); } |
113 | 113 | ||
114 | %left LSL_SUBTRACT LSL_ADD LSL_CONCATENATE. | 114 | %left LSL_SUBTRACT LSL_ADD LSL_CONCATENATE. |
115 | expr(A) ::= expr(B) LSL_ADD(C) expr(D). { A = addOperation(param, B, C, D); } | 115 | expr(A) ::= expr(B) LSL_ADD(C) expr(D). { A = addOperation(compiler, B, C, D); } |
116 | expr(A) ::= expr(B) LSL_SUBTRACT(C) expr(D). { A = addOperation(param, B, C, D); } | 116 | expr(A) ::= expr(B) LSL_SUBTRACT(C) expr(D). { A = addOperation(compiler, B, C, D); } |
117 | %left LSL_DIVIDE LSL_MODULO LSL_MULTIPLY LSL_DOT_PRODUCT LSL_CROSS_PRODUCT. | 117 | %left LSL_DIVIDE LSL_MODULO LSL_MULTIPLY LSL_DOT_PRODUCT LSL_CROSS_PRODUCT. |
118 | expr(A) ::= expr(B) LSL_MULTIPLY(C) expr(D). { A = addOperation(param, B, C, D); } | 118 | expr(A) ::= expr(B) LSL_MULTIPLY(C) expr(D). { A = addOperation(compiler, B, C, D); } |
119 | expr(A) ::= expr(B) LSL_MODULO(C) expr(D). { A = addOperation(param, B, C, D); } | 119 | expr(A) ::= expr(B) LSL_MODULO(C) expr(D). { A = addOperation(compiler, B, C, D); } |
120 | expr(A) ::= expr(B) LSL_DIVIDE(C) expr(D). { A = addOperation(param, B, C, D); } | 120 | expr(A) ::= expr(B) LSL_DIVIDE(C) expr(D). { A = addOperation(compiler, B, C, D); } |
121 | 121 | ||
122 | %right LSL_BIT_NOT LSL_BOOL_NOT LSL_NEGATION. | 122 | %right LSL_BIT_NOT LSL_BOOL_NOT LSL_NEGATION. |
123 | expr(A) ::= LSL_BIT_NOT(B) expr(C). { A = addOperation(param, NULL, B, C); } | 123 | expr(A) ::= LSL_BIT_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); } |
124 | expr(A) ::= LSL_BOOL_NOT(B) expr(C). { A = addOperation(param, NULL, B, C); } | 124 | expr(A) ::= LSL_BOOL_NOT(B) expr(C). { A = addOperation(compiler, NULL, B, C); } |
125 | expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(param, NULL, B, C); } | 125 | expr(A) ::= LSL_SUBTRACT(B) expr(C). [LSL_NEGATION] { A = addOperation(compiler, NULL, B, C); } |
126 | 126 | ||
127 | // Types, typecasts, and expression reordering. | 127 | // Types, typecasts, and expression reordering. |
128 | 128 | ||
@@ -162,8 +162,8 @@ expr ::= identifier LSL_ASSIGNMENT_DIVIDE expr. | |||
162 | expr ::= identifier LSL_ASSIGNMENT_PLAIN expr. | 162 | expr ::= identifier LSL_ASSIGNMENT_PLAIN expr. |
163 | 163 | ||
164 | // Hmm think this can have commas seperating the assignment parts. | 164 | // Hmm think this can have commas seperating the assignment parts. |
165 | statement(A) ::= type(B) identifier(C) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(param, B, C, D, E)); } | 165 | statement(A) ::= type(B) identifier(C) LSL_ASSIGNMENT_PLAIN(D) expr(E) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(compiler, B, C, D, E)); } |
166 | statement(A) ::= type(B) identifier(C) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(param, B, C, NULL, NULL)); } | 166 | statement(A) ::= type(B) identifier(C) LSL_STATEMENT(F). { A = addStatement(F, LSL_IDENTIFIER, addVariable(compiler, B, C, NULL, NULL)); } |
167 | 167 | ||
168 | %right LSL_DOT LSL_IDENTIFIER. | 168 | %right LSL_DOT LSL_IDENTIFIER. |
169 | identifier ::= identifier LSL_DOT LSL_IDENTIFIER. | 169 | identifier ::= identifier LSL_DOT LSL_IDENTIFIER. |
@@ -200,28 +200,28 @@ expr ::= LSL_ANGLE_OPEN expr LSL_COMMA expr LSL_COMMA expr LSL_ANGLE_CLOSE. [L | |||
200 | 200 | ||
201 | %parse_accept | 201 | %parse_accept |
202 | { | 202 | { |
203 | gameGlobals *game = param->game; | 203 | gameGlobals *game = compiler->game; |
204 | 204 | ||
205 | PI("Parsing complete."); | 205 | PI("Parsing complete."); |
206 | } | 206 | } |
207 | 207 | ||
208 | %parse_failure | 208 | %parse_failure |
209 | { | 209 | { |
210 | gameGlobals *game = param->game; | 210 | gameGlobals *game = compiler->game; |
211 | 211 | ||
212 | PE("Giving up. Parser is hopelessly lost!"); | 212 | PE("Giving up. Parser is hopelessly lost!"); |
213 | } | 213 | } |
214 | 214 | ||
215 | %stack_overflow | 215 | %stack_overflow |
216 | { | 216 | { |
217 | gameGlobals *game = param->game; | 217 | gameGlobals *game = compiler->game; |
218 | 218 | ||
219 | PE("Giving up. Parser stack overflow @ line %04d column %04d.", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens. | 219 | PE("Giving up. Parser stack overflow @ line %04d column %04d.", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens. |
220 | } | 220 | } |
221 | 221 | ||
222 | %syntax_error | 222 | %syntax_error |
223 | { | 223 | { |
224 | gameGlobals *game = param->game; | 224 | gameGlobals *game = compiler->game; |
225 | 225 | ||
226 | PE("Syntax error @ line %04d column %04d.", yyminor.yy0->line, yyminor.yy0->column); | 226 | PE("Syntax error @ line %04d column %04d.", yyminor.yy0->line, yyminor.yy0->column); |
227 | } | 227 | } |