From ff5b1c802a26789ff769521262db79854b24939b Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 10 Jan 2012 01:43:10 +1000 Subject: Almost got white space and comments working. Still a bug left somewhere, I think it's in operations ordering. --- LuaSL/src/LuaSL_LSL_tree.h | 88 ++++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 42 deletions(-) (limited to 'LuaSL/src/LuaSL_LSL_tree.h') diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index adefa07..fe56c29 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h @@ -20,7 +20,7 @@ extern int yydebug; // http://w-hat.com/stackdepth is a useful discussion about some aspects of the LL parser. -typedef union _LSL_Leaf LSL_Leaf; +typedef struct _LSL_Leaf LSL_Leaf; typedef struct _LSL_Value LSL_Value; typedef struct _LSL_Identifier LSL_Identifier; typedef struct _LSL_Statement LSL_Statement; @@ -65,43 +65,48 @@ typedef struct evaluateToken evaluate; } LSL_Token; -union _LSL_Leaf +struct _LSL_Leaf { - char *commentValue; - char *spaceValue; - - LSL_Type operationValue; - LSL_AST *expressionValue; - - float floatValue; - int integerValue; - char *keyValue; - LSL_Leaf *listValue; - char *stringValue; - float vectorValue[3]; - float rotationValue[4]; - - LSL_Identifier *variableValue; - - char *labelValue; - LSL_Statement *doValue; - LSL_Statement *forValue; - LSL_Statement *elseIfValue; - LSL_Statement *elseValue; - LSL_Statement *ifValue; - char *jumpValue; - LSL_Statement *returnValue; - char *stateChangeValue; - LSL_Statement *whileValue; - LSL_Statement *statementValue; - - LSL_Block *blockValue; - LSL_Identifier *parameterValue; - LSL_Function *functionValue; - LSL_State *stateValue; - LSL_Script *scriptValue; - - char *unknownValue; + union + { + char *commentValue; + char *spaceValue; + + LSL_Type operationValue; + LSL_AST *expressionValue; + + float floatValue; + int integerValue; + char *keyValue; + LSL_Leaf *listValue; + char *stringValue; + float vectorValue[3]; + float rotationValue[4]; + + LSL_Identifier *variableValue; + + char *labelValue; + LSL_Statement *doValue; + LSL_Statement *forValue; + LSL_Statement *elseIfValue; + LSL_Statement *elseValue; + LSL_Statement *ifValue; + char *jumpValue; + LSL_Statement *returnValue; + char *stateChangeValue; + LSL_Statement *whileValue; + LSL_Statement *statementValue; + + LSL_Block *blockValue; + LSL_Identifier *parameterValue; + LSL_Function *functionValue; + LSL_State *stateValue; + LSL_Script *scriptValue; + + char *unknownValue; + } value; + char *ignorableText; + int line, column; }; struct _LSL_Value @@ -176,7 +181,7 @@ typedef struct } LuaSL_yyparseParam; // the parameter name (of the reentrant 'yyparse' function) -// data is a pointer to a 'SParserParam' structure +// data is a pointer to a 'yyparseParam' structure #define YYPARSE_PARAM data // the argument for the 'yylex' function @@ -184,12 +189,11 @@ typedef struct LSL_AST *addExpression(LSL_AST *exp); -LSL_AST *addInteger(int value); -LSL_AST *addOperation(LSL_Type type, LSL_AST *left, LSL_AST *right); -LSL_AST *addParenthesis(LSL_AST *expr); +LSL_AST *addInteger(LSL_Leaf *lval, int value); +LSL_AST *addOperation(LSL_Leaf *lval, LSL_Type type, LSL_AST *left, LSL_AST *right); +LSL_AST *addParenthesis(LSL_Leaf *lval, LSL_AST *expr); LSL_Statement *createStatement(LSL_Type type, LSL_AST *root); LSL_AST *addStatement(LSL_Statement *statement, LSL_AST *root); -LSL_AST *addSpace(char *text, LSL_AST *root); int yyerror(const char *msg); int yyparse(void *param); -- cgit v1.1