From b27dab5443ca5919e7727fd2666559a6498d8c3d Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 21 Jan 2012 19:24:53 +1000 Subject: Parse 'crements. --- LuaSL/src/LuaSL_LSL_tree.h | 1 + LuaSL/src/LuaSL_compile.c | 10 ++++++++++ LuaSL/src/LuaSL_lemon_yaccer.y | 8 ++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index d537948..c0930b3 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -336,6 +336,7 @@ typedef struct void burnLeaf(void *data); +LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement); LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block); LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close); diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 5a3a68b..cb64038 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -432,6 +432,16 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, return lval; } +LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *crement) +{ + if ((variable) && (crement)) + { + crement->basicType = variable->basicType; + } + + return crement; +} + LSL_Leaf *addParameter(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier) { LSL_Identifier *result = calloc(1, sizeof(LSL_Identifier)); diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 6e82578..4a5cb3b 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y @@ -176,10 +176,10 @@ identifier ::= identifier LSL_DOT LSL_IDENTIFIER. identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); } %right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. -expr ::= identifier LSL_DECREMENT_PRE. -expr ::= identifier LSL_INCREMENT_PRE. -expr ::= LSL_DECREMENT_PRE identifier. -expr ::= LSL_INCREMENT_PRE identifier. +expr(A) ::= identifier(B) LSL_DECREMENT_PRE(C). { A = addCrement(compiler, B, C); } +expr(A) ::= identifier(B) LSL_INCREMENT_PRE(C). { A = addCrement(compiler, B, C); } +expr(A) ::= LSL_DECREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C); } +expr(A) ::= LSL_INCREMENT_PRE(C) identifier(B). { A = addCrement(compiler, B, C); } %nonassoc LSL_COMMA. -- cgit v1.1