diff options
author | David Walter Seikel | 2012-01-17 14:05:48 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-17 14:05:48 +1000 |
commit | 67bb592b153cd97ece90f12b106c251ca4d08694 (patch) | |
tree | f5a50082e2e0e08050f27f0ab685f599ff8b87d9 /LuaSL | |
parent | Store the lexer provided length. (diff) | |
download | SledjHamr-67bb592b153cd97ece90f12b106c251ca4d08694.zip SledjHamr-67bb592b153cd97ece90f12b106c251ca4d08694.tar.gz SledjHamr-67bb592b153cd97ece90f12b106c251ca4d08694.tar.bz2 SledjHamr-67bb592b153cd97ece90f12b106c251ca4d08694.tar.xz |
Use stringshare, and const.
Diffstat (limited to 'LuaSL')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 22 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 4 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 8 |
3 files changed, 17 insertions, 17 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 20ba877..626d005 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -159,7 +159,7 @@ typedef enum | |||
159 | struct _allowedTypes | 159 | struct _allowedTypes |
160 | { | 160 | { |
161 | opType result; | 161 | opType result; |
162 | char *name; | 162 | const char *name; |
163 | int subTypes; | 163 | int subTypes; |
164 | }; | 164 | }; |
165 | 165 | ||
@@ -167,7 +167,7 @@ struct _LSL_Token | |||
167 | { | 167 | { |
168 | LSL_Type type; | 168 | LSL_Type type; |
169 | opSubType subType; | 169 | opSubType subType; |
170 | char *token; | 170 | const char *token; |
171 | LSL_Flags flags; | 171 | LSL_Flags flags; |
172 | outputToken output; | 172 | outputToken output; |
173 | evaluateToken evaluate; | 173 | evaluateToken evaluate; |
@@ -190,22 +190,22 @@ struct _LSL_Leaf | |||
190 | int integerValue; | 190 | int integerValue; |
191 | char *keyValue; | 191 | char *keyValue; |
192 | LSL_Leaf *listValue; | 192 | LSL_Leaf *listValue; |
193 | char *stringValue; | 193 | const char *stringValue; |
194 | float vectorValue[3]; | 194 | float vectorValue[3]; |
195 | float rotationValue[4]; | 195 | float rotationValue[4]; |
196 | 196 | ||
197 | LSL_Identifier *identifierValue; | 197 | LSL_Identifier *identifierValue; |
198 | LSL_Identifier *variableValue; | 198 | LSL_Identifier *variableValue; |
199 | 199 | ||
200 | char *labelValue; | 200 | const char *labelValue; |
201 | LSL_Statement *doValue; | 201 | LSL_Statement *doValue; |
202 | LSL_Statement *forValue; | 202 | LSL_Statement *forValue; |
203 | LSL_Statement *elseIfValue; | 203 | LSL_Statement *elseIfValue; |
204 | LSL_Statement *elseValue; | 204 | LSL_Statement *elseValue; |
205 | LSL_Statement *ifValue; | 205 | LSL_Statement *ifValue; |
206 | char *jumpValue; | 206 | const char *jumpValue; |
207 | LSL_Statement *returnValue; | 207 | LSL_Statement *returnValue; |
208 | char *stateChangeValue; | 208 | const char *stateChangeValue; |
209 | LSL_Statement *whileValue; | 209 | LSL_Statement *whileValue; |
210 | LSL_Statement *statementValue; | 210 | LSL_Statement *statementValue; |
211 | 211 | ||
@@ -215,7 +215,7 @@ struct _LSL_Leaf | |||
215 | LSL_State *stateValue; | 215 | LSL_State *stateValue; |
216 | LSL_Script *scriptValue; | 216 | LSL_Script *scriptValue; |
217 | 217 | ||
218 | char *unknownValue; | 218 | const char *unknownValue; |
219 | } value; | 219 | } value; |
220 | }; | 220 | }; |
221 | 221 | ||
@@ -229,7 +229,7 @@ struct _LSL_Parenthesis | |||
229 | 229 | ||
230 | struct _LSL_Identifier // For variables and function parameters. | 230 | struct _LSL_Identifier // For variables and function parameters. |
231 | { | 231 | { |
232 | char *name; | 232 | const char *name; |
233 | LSL_Leaf value; | 233 | LSL_Leaf value; |
234 | }; | 234 | }; |
235 | 235 | ||
@@ -249,7 +249,7 @@ struct _LSL_Block | |||
249 | 249 | ||
250 | struct _LSL_Function | 250 | struct _LSL_Function |
251 | { | 251 | { |
252 | char *name; | 252 | const char *name; |
253 | LSL_Leaf *type; | 253 | LSL_Leaf *type; |
254 | LSL_Leaf *params; | 254 | LSL_Leaf *params; |
255 | LSL_Leaf *block; | 255 | LSL_Leaf *block; |
@@ -257,14 +257,14 @@ struct _LSL_Function | |||
257 | 257 | ||
258 | struct _LSL_State | 258 | struct _LSL_State |
259 | { | 259 | { |
260 | char *name; | 260 | const char *name; |
261 | LSL_Leaf *block; | 261 | LSL_Leaf *block; |
262 | LSL_Function **handlers; | 262 | LSL_Function **handlers; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | struct _LSL_Script | 265 | struct _LSL_Script |
266 | { | 266 | { |
267 | char *name; | 267 | const char *name; |
268 | LSL_Function **functions; | 268 | LSL_Function **functions; |
269 | LSL_State **states; | 269 | LSL_State **states; |
270 | LSL_Identifier **variables; | 270 | LSL_Identifier **variables; |
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 523b9c3..e54e0e6 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -277,7 +277,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, | |||
277 | } | 277 | } |
278 | if (OT_invalid == lval->basicType) | 278 | if (OT_invalid == lval->basicType) |
279 | { | 279 | { |
280 | char *leftType = "", *rightType = ""; | 280 | const char *leftType = "", *rightType = ""; |
281 | 281 | ||
282 | if (left) | 282 | if (left) |
283 | leftType = allowed[left->basicType].name; | 283 | leftType = allowed[left->basicType].name; |
@@ -335,7 +335,7 @@ LSL_Leaf *addFunction(LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *open, LSL_ | |||
335 | { | 335 | { |
336 | if (identifier) | 336 | if (identifier) |
337 | { | 337 | { |
338 | char *temp = identifier->value.stringValue; | 338 | const char *temp = identifier->value.stringValue; |
339 | 339 | ||
340 | identifier->token = tokens[LSL_FUNCTION - lowestToken]; | 340 | identifier->token = tokens[LSL_FUNCTION - lowestToken]; |
341 | identifier->value.functionValue = func; | 341 | identifier->value.functionValue = func; |
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 5945599..68d0b43 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -98,18 +98,18 @@ STRING \"(\\.|[^\\"\n])*\" | |||
98 | "state" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_STATE_CHANGE); %} | 98 | "state" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_STATE_CHANGE); %} |
99 | "while" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_WHILE); %} | 99 | "while" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_WHILE); %} |
100 | 100 | ||
101 | {IDENTIFIER} %{ yylval->value.stringValue = strdup(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_IDENTIFIER); %} | 101 | {IDENTIFIER} %{ yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_IDENTIFIER); %} |
102 | 102 | ||
103 | /* Types. */ | 103 | /* Types. */ |
104 | {INTEGER} %{ yylval->value.integerValue = atoi(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_INTEGER); %} | 104 | {INTEGER} %{ yylval->value.integerValue = atoi(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_INTEGER); %} |
105 | {FLOAT} %{ yylval->value.floatValue = atof(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FLOAT); %} | 105 | {FLOAT} %{ yylval->value.floatValue = atof(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FLOAT); %} |
106 | {KEY} %{ yylval->value.stringValue = strdup(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_KEY); %} | 106 | {KEY} %{ yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_KEY); %} |
107 | {STRING} %{ yylval->value.stringValue = strdup(yytext); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_STRING); %} | 107 | {STRING} %{ yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_STRING); %} |
108 | 108 | ||
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 = strdup(yytext); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} | 112 | . %{ printf(" unexpected character.\n"); yylval->value.unknownValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} |
113 | 113 | ||
114 | %% | 114 | %% |
115 | 115 | ||