diff options
author | David Walter Seikel | 2012-01-17 14:15:07 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-17 14:15:07 +1000 |
commit | f45e1dde5cc9eb67a7891fae5ebe8b38dcef0c97 (patch) | |
tree | 5397eb344c6d6ac64071539b59dca5093a8fefc9 | |
parent | Use stringshare, and const. (diff) | |
download | SledjHamr-f45e1dde5cc9eb67a7891fae5ebe8b38dcef0c97.zip SledjHamr-f45e1dde5cc9eb67a7891fae5ebe8b38dcef0c97.tar.gz SledjHamr-f45e1dde5cc9eb67a7891fae5ebe8b38dcef0c97.tar.bz2 SledjHamr-f45e1dde5cc9eb67a7891fae5ebe8b38dcef0c97.tar.xz |
Only need one of each in the value union.
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 27 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 8 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 2 |
3 files changed, 9 insertions, 28 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 626d005..e179295 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -183,39 +183,20 @@ struct _LSL_Leaf | |||
183 | opType basicType; | 183 | opType basicType; |
184 | union | 184 | union |
185 | { | 185 | { |
186 | opType operationValue; | ||
187 | LSL_Parenthesis *parenthesis; | ||
188 | |||
189 | float floatValue; | 186 | float floatValue; |
187 | float vectorValue[3]; | ||
188 | float rotationValue[4]; | ||
190 | int integerValue; | 189 | int integerValue; |
191 | char *keyValue; | ||
192 | LSL_Leaf *listValue; | 190 | LSL_Leaf *listValue; |
193 | const char *stringValue; | 191 | const char *stringValue; |
194 | float vectorValue[3]; | 192 | opType operationValue; |
195 | float rotationValue[4]; | 193 | LSL_Parenthesis *parenthesis; |
196 | |||
197 | LSL_Identifier *identifierValue; | 194 | LSL_Identifier *identifierValue; |
198 | LSL_Identifier *variableValue; | ||
199 | |||
200 | const char *labelValue; | ||
201 | LSL_Statement *doValue; | ||
202 | LSL_Statement *forValue; | ||
203 | LSL_Statement *elseIfValue; | ||
204 | LSL_Statement *elseValue; | ||
205 | LSL_Statement *ifValue; | ||
206 | const char *jumpValue; | ||
207 | LSL_Statement *returnValue; | ||
208 | const char *stateChangeValue; | ||
209 | LSL_Statement *whileValue; | ||
210 | LSL_Statement *statementValue; | 195 | LSL_Statement *statementValue; |
211 | |||
212 | LSL_Block *blockValue; | 196 | LSL_Block *blockValue; |
213 | LSL_Identifier *parameterValue; | ||
214 | LSL_Function *functionValue; | 197 | LSL_Function *functionValue; |
215 | LSL_State *stateValue; | 198 | LSL_State *stateValue; |
216 | LSL_Script *scriptValue; | 199 | LSL_Script *scriptValue; |
217 | |||
218 | const char *unknownValue; | ||
219 | } value; | 200 | } value; |
220 | }; | 201 | }; |
221 | 202 | ||
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index e54e0e6..3a9a6c4 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -298,7 +298,7 @@ LSL_Leaf *addParameter(LSL_Leaf *type, LSL_Leaf *identifier) | |||
298 | if ( (identifier) && (result)) | 298 | if ( (identifier) && (result)) |
299 | { | 299 | { |
300 | result->name = identifier->value.stringValue; | 300 | result->name = identifier->value.stringValue; |
301 | identifier->value.variableValue = result; | 301 | identifier->value.identifierValue = result; |
302 | identifier->token = tokens[LSL_PARAMETER - lowestToken]; | 302 | identifier->token = tokens[LSL_PARAMETER - lowestToken]; |
303 | identifier->left = type; | 303 | identifier->left = type; |
304 | if (type) | 304 | if (type) |
@@ -436,7 +436,7 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi | |||
436 | if ( (identifier) && (result)) | 436 | if ( (identifier) && (result)) |
437 | { | 437 | { |
438 | result->name = identifier->value.stringValue; | 438 | result->name = identifier->value.stringValue; |
439 | identifier->value.variableValue = result; | 439 | identifier->value.identifierValue = result; |
440 | identifier->left = type; | 440 | identifier->left = type; |
441 | identifier->right = assignment; | 441 | identifier->right = assignment; |
442 | if (assignment) | 442 | if (assignment) |
@@ -822,7 +822,7 @@ static void outputIntegerToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
822 | static void outputParameterToken(FILE *file, outputMode mode, LSL_Leaf *content) | 822 | static void outputParameterToken(FILE *file, outputMode mode, LSL_Leaf *content) |
823 | { | 823 | { |
824 | if (content) | 824 | if (content) |
825 | fprintf(file, "%s", content->value.parameterValue->name); | 825 | fprintf(file, "%s", content->value.identifierValue->name); |
826 | } | 826 | } |
827 | 827 | ||
828 | static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content) | 828 | static void outputParameterListToken(FILE *file, outputMode mode, LSL_Leaf *content) |
@@ -866,7 +866,7 @@ static void outputStatementToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
866 | static void outputVariableToken(FILE *file, outputMode mode, LSL_Leaf *content) | 866 | static void outputVariableToken(FILE *file, outputMode mode, LSL_Leaf *content) |
867 | { | 867 | { |
868 | if (content) | 868 | if (content) |
869 | fprintf(file, "%s", content->value.variableValue->name); | 869 | fprintf(file, "%s", content->value.identifierValue->name); |
870 | } | 870 | } |
871 | 871 | ||
872 | static void doneParsing(LuaSL_compiler *compiler) | 872 | static void doneParsing(LuaSL_compiler *compiler) |
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 68d0b43..9c90ed5 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -109,7 +109,7 @@ STRING \"(\\.|[^\\"\n])*\" | |||
109 | <<EOF>> { return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_SCRIPT); } | 109 | <<EOF>> { return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_SCRIPT); } |
110 | 110 | ||
111 | /* Everything else */ | 111 | /* Everything else */ |
112 | . %{ printf(" unexpected character.\n"); yylval->value.unknownValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} | 112 | . %{ printf(" unexpected character.\n"); yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} |
113 | 113 | ||
114 | %% | 114 | %% |
115 | 115 | ||