aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.c10
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h2
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y6
3 files changed, 10 insertions, 8 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c
index a0490c9..0f9013a 100644
--- a/LuaSL/src/LuaSL_LSL_tree.c
+++ b/LuaSL/src/LuaSL_LSL_tree.c
@@ -290,7 +290,8 @@ LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval)
290 if (lval) 290 if (lval)
291 { 291 {
292 lval->value.parenthesis = parens; 292 lval->value.parenthesis = parens;
293 lval->basicType = expr->basicType; 293 if (expr)
294 lval->basicType = expr->basicType;
294 } 295 }
295 } 296 }
296 return lval; 297 return lval;
@@ -311,19 +312,20 @@ LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr)
311 return lval; 312 return lval;
312} 313}
313 314
314LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval) 315LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr)
315{ 316{
316 LSL_Parenthesis *parens = malloc(sizeof(LSL_Parenthesis)); 317 LSL_Parenthesis *parens = malloc(sizeof(LSL_Parenthesis));
317 318
318 if (parens) 319 if (parens)
319 { 320 {
320 parens->left = lval; 321 parens->left = lval;
321 parens->expression = type; 322 parens->expression = expr;
322 parens->right = rval; 323 parens->right = rval;
323 if (lval) 324 if (lval)
324 { 325 {
325 lval->value.parenthesis = parens; 326 lval->value.parenthesis = parens;
326 lval->basicType = type->basicType; 327 if (type)
328 lval->basicType = type->basicType;
327 lval->token = tokens[LSL_TYPECAST_OPEN - lowestToken]; 329 lval->token = tokens[LSL_TYPECAST_OPEN - lowestToken];
328 } 330 }
329 if (rval) 331 if (rval)
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index e56e94c..1429393 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -289,7 +289,7 @@ LSL_Leaf *addExpression(LSL_Leaf *exp);
289LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right); 289LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right);
290LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); 290LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval);
291LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr); 291LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr);
292LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Leaf *rval); 292LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *expr);
293 293
294void *ParseAlloc(void *(*mallocProc)(size_t)); 294void *ParseAlloc(void *(*mallocProc)(size_t));
295void ParseTrace(FILE *TraceFILE, char *zTracePrompt); 295void ParseTrace(FILE *TraceFILE, char *zTracePrompt);
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index a43885f..83aff23 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -11,7 +11,7 @@
11%token_destructor {burnLeaf($$);} 11%token_destructor {burnLeaf($$);}
12 12
13 13
14program ::= script LSL_SCRIPT(A). { A->left = param->ast; param->ast = A; } // Lemon does not like the start symbol to be on the RHS, so give it a dummy one. 14program ::= script LSL_SCRIPT(A). { if (NULL != A) A->left = param->ast; param->ast = A; } // Lemon does not like the start symbol to be on the RHS, so give it a dummy one.
15 15
16%right LSL_BOOL_AND. 16%right LSL_BOOL_AND.
17expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(B, C, D); } 17expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(B, C, D); }
@@ -68,7 +68,7 @@ exprList ::= expr.
68exprList ::= . 68exprList ::= .
69expr ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN exprList LSL_PARENTHESIS_CLOSE. 69expr ::= LSL_IDENTIFIER LSL_PARENTHESIS_OPEN exprList LSL_PARENTHESIS_CLOSE.
70expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, D); } 70expr(A) ::= LSL_PARENTHESIS_OPEN(B) expr(C) LSL_PARENTHESIS_CLOSE(D). { A = addParenthesis(B, C, D); }
71expr(A) ::= LSL_PARENTHESIS_OPEN(B) type(C) LSL_PARENTHESIS_CLOSE(D). { A = addTypecast(B, C, D); } 71expr(A) ::= LSL_PARENTHESIS_OPEN(B) type(C) LSL_PARENTHESIS_CLOSE(D) expr(E). { A = addTypecast(B, C, D, E); }
72 72
73%right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN. 73%right LSL_ASSIGNMENT_CONCATENATE LSL_ASSIGNMENT_ADD LSL_ASSIGNMENT_SUBTRACT LSL_ASSIGNMENT_MULTIPLY LSL_ASSIGNMENT_MODULO LSL_ASSIGNMENT_DIVIDE LSL_ASSIGNMENT_PLAIN.
74expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_CONCATENATE expr. 74expr ::= LSL_IDENTIFIER LSL_ASSIGNMENT_CONCATENATE expr.
@@ -151,7 +151,7 @@ state ::= LSL_IDENTIFIER stateBlock.
151%nonassoc LSL_SCRIPT. 151%nonassoc LSL_SCRIPT.
152script ::= script state. 152script ::= script state.
153script ::= script function. 153script ::= script function.
154script ::= script statement(A). { A->left = param->ast; param->ast = A; } 154script ::= script statement(A). { if (NULL != A) A->left = param->ast; param->ast = A; }
155script ::= . 155script ::= .
156 156
157%nonassoc LSL_SPACE LSL_COMMENT LSL_COMMENT_LINE LSL_UNKNOWN. 157%nonassoc LSL_SPACE LSL_COMMENT LSL_COMMENT_LINE LSL_UNKNOWN.