From 8e5c2dcb54fc39ad10101bf7e705e7729c62c965 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 7 Jan 2012 19:26:07 +1000 Subject: We don't need LSL_Expression. --- LuaSL/src/LuaSL_LSL_tree.c | 39 +++++++-------------------------------- LuaSL/src/LuaSL_LSL_tree.h | 18 +++++------------- 2 files changed, 12 insertions(+), 45 deletions(-) (limited to 'LuaSL') diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c index e6dfa4c..78414fe 100644 --- a/LuaSL/src/LuaSL_LSL_tree.c +++ b/LuaSL/src/LuaSL_LSL_tree.c @@ -104,28 +104,6 @@ LSL_Token **tokens = NULL; int lowestToken = 999999; -static LSL_Expression *newLSLExpression(LSL_Type type, LSL_Expression *left, LSL_Expression *right) -{ - LSL_Expression *exp = malloc(sizeof(LSL_Expression)); - - if (exp == NULL) return NULL; - - exp->left = left; - exp->right = right; - exp->token = tokens[type - lowestToken]; - - return exp; -} - -static void burnLSLExpression(LSL_Expression *exp) -{ - if (exp == NULL) return; - - burnLSLExpression(exp->left); - burnLSLExpression(exp->right); - free(exp); -} - static LSL_AST *newAST(LSL_Type type, LSL_AST *left, LSL_AST *right) { LSL_AST *ast = malloc(sizeof(LSL_AST)); @@ -147,13 +125,10 @@ static void burnAST(LSL_AST *ast) burnAST(ast->left); burnAST(ast->right); - // Burn the contents to. - if ((ast->token) && (ast->token->type == LSL_EXPRESSION)) - burnLSLExpression(ast->content.expressionValue); free(ast); } -LSL_AST *addExpression(LSL_Expression *exp) +LSL_AST *addExpression(LSL_AST *exp) { LSL_AST *ast = newAST(LSL_EXPRESSION, NULL, NULL); @@ -163,9 +138,9 @@ LSL_AST *addExpression(LSL_Expression *exp) return ast; } -LSL_Expression *addInteger(int value) +LSL_AST *addInteger(int value) { - LSL_Expression *exp = newLSLExpression(LSL_INTEGER, NULL, NULL); + LSL_AST *exp = newAST(LSL_INTEGER, NULL, NULL); if (exp) exp->content.integerValue = value; @@ -173,9 +148,9 @@ LSL_Expression *addInteger(int value) return exp; } -LSL_Expression *addOperation(LSL_Operation type, LSL_Expression *left, LSL_Expression *right) +LSL_AST *addOperation(LSL_Operation type, LSL_AST *left, LSL_AST *right) { - LSL_Expression *exp = newLSLExpression(LSL_EXPRESSION, left, right); + LSL_AST *exp = newAST(LSL_EXPRESSION, left, right); if (exp) { @@ -198,7 +173,7 @@ static void evaluateIntegerToken(LSL_Leaf *content, LSL_Value *result) } } -static void evaluateExpression(LSL_Expression *exp, LSL_Value *result) +static void evaluateExpression(LSL_AST *exp, LSL_Value *result) { LSL_Value left, right; @@ -300,7 +275,7 @@ static void evaluateAST(LSL_AST *ast, LSL_Value *result) ast->token->evaluate(&(ast->content), result); } -static void outputExpression(LSL_Expression *exp) +static void outputExpression(LSL_AST *exp) { if (NULL == exp) return; diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 0d49737..4764ce8 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -122,7 +122,7 @@ typedef int LSL_Type; typedef struct { LSL_Type type; - struct LSL_Expression *expressions; + struct LSL_AST *expressions; } LSL_Statement; typedef struct @@ -167,7 +167,7 @@ typedef union LSL_Leaf union LSL_Leaf *listValue; char *labelValue; LSL_Operation operationValue; - struct LSL_Expression *expressionValue; + struct LSL_AST *expressionValue; LSL_Statement *doValue; LSL_Statement *forValue; LSL_Statement *ifValue; @@ -209,14 +209,6 @@ typedef struct LSL_Leaf content; } LSL_Identifier; -typedef struct LSL_Expression -{ - struct LSL_Expression *left; - struct LSL_Expression *right; - LSL_Token *token; - LSL_Leaf content; -} LSL_Expression; - typedef struct LSL_AST { struct LSL_AST *left; @@ -251,9 +243,9 @@ typedef struct #define YYLEX_PARAM ((LuaSL_yyparseParam*)data)->scanner -LSL_AST *addExpression(LSL_Expression *exp); -LSL_Expression *addInteger(int value); -LSL_Expression *addOperation(LSL_Operation type, LSL_Expression *left, LSL_Expression *right); +LSL_AST *addExpression(LSL_AST *exp); +LSL_AST *addInteger(int value); +LSL_AST *addOperation(LSL_Operation type, LSL_AST *left, LSL_AST *right); int yyerror(const char *msg); int yyparse(void *param); -- cgit v1.1