diff options
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 4 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 13 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 15 |
3 files changed, 11 insertions, 21 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index e179295..fd9c65a 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -178,7 +178,7 @@ struct _LSL_Leaf | |||
178 | LSL_Leaf *left; | 178 | LSL_Leaf *left; |
179 | LSL_Leaf *right; | 179 | LSL_Leaf *right; |
180 | LSL_Token *token; | 180 | LSL_Token *token; |
181 | char *ignorableText; | 181 | Eina_Strbuf *ignorableText; |
182 | int line, column, len; | 182 | int line, column, len; |
183 | opType basicType; | 183 | opType basicType; |
184 | union | 184 | union |
@@ -265,7 +265,7 @@ typedef struct | |||
265 | FILE *file; | 265 | FILE *file; |
266 | LSL_Leaf *ast; | 266 | LSL_Leaf *ast; |
267 | LSL_Script script; | 267 | LSL_Script script; |
268 | char *ignorableText; | 268 | Eina_Strbuf *ignorableText; |
269 | LSL_Leaf *lval; | 269 | LSL_Leaf *lval; |
270 | int column, line; | 270 | int column, line; |
271 | LSL_Block *currentBlock; | 271 | LSL_Block *currentBlock; |
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 9ebda0f..277e278 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -203,7 +203,7 @@ void burnLeaf(LSL_Leaf *leaf) | |||
203 | burnLeaf(leaf->left); | 203 | burnLeaf(leaf->left); |
204 | burnLeaf(leaf->right); | 204 | burnLeaf(leaf->right); |
205 | // TODO - Should free up the value to. | 205 | // TODO - Should free up the value to. |
206 | free(leaf->ignorableText); | 206 | eina_strbuf_free(leaf->ignorableText); |
207 | free(leaf); | 207 | free(leaf); |
208 | } | 208 | } |
209 | } | 209 | } |
@@ -447,9 +447,9 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi | |||
447 | } | 447 | } |
448 | if (compiler->currentBlock) | 448 | if (compiler->currentBlock) |
449 | { | 449 | { |
450 | compiler->currentBlock->vcount++; | 450 | // compiler->currentBlock->vcount++; |
451 | compiler->currentBlock->variables = realloc(compiler->currentBlock->variables, compiler->currentBlock->vcount * sizeof(LSL_Identifier *)); | 451 | // compiler->currentBlock->variables = realloc(compiler->currentBlock->variables, compiler->currentBlock->vcount * sizeof(LSL_Identifier *)); |
452 | compiler->currentBlock->variables[compiler->currentBlock->vcount - 1] = result; | 452 | // compiler->currentBlock->variables[compiler->currentBlock->vcount - 1] = result; |
453 | } | 453 | } |
454 | else | 454 | else |
455 | { | 455 | { |
@@ -784,7 +784,7 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf) | |||
784 | { | 784 | { |
785 | outputLeaf(file, mode, leaf->left); | 785 | outputLeaf(file, mode, leaf->left); |
786 | if ((!(LSL_NOIGNORE & leaf->token->flags)) && (leaf->ignorableText)) | 786 | if ((!(LSL_NOIGNORE & leaf->token->flags)) && (leaf->ignorableText)) |
787 | fprintf(file, "%s", leaf->ignorableText); | 787 | fwrite(eina_strbuf_string_get(leaf->ignorableText), 1, eina_strbuf_length_get(leaf->ignorableText), file); |
788 | if (leaf->token->output) | 788 | if (leaf->token->output) |
789 | leaf->token->output(file, mode, leaf); | 789 | leaf->token->output(file, mode, leaf); |
790 | else | 790 | else |
@@ -857,7 +857,7 @@ static void outputStatementToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
857 | { | 857 | { |
858 | outputLeaf(file, mode, content->value.statementValue->expressions); | 858 | outputLeaf(file, mode, content->value.statementValue->expressions); |
859 | if (content->ignorableText) | 859 | if (content->ignorableText) |
860 | fprintf(file, "%s", content->ignorableText); | 860 | fwrite(eina_strbuf_string_get(content->ignorableText), 1, eina_strbuf_length_get(content->ignorableText), file); |
861 | fprintf(file, "%s", content->token->token); | 861 | fprintf(file, "%s", content->token->token); |
862 | } | 862 | } |
863 | } | 863 | } |
@@ -947,6 +947,7 @@ Eina_Bool compileLSL(gameGlobals *game, char *script) | |||
947 | 947 | ||
948 | memset(&compiler, 0, sizeof(LuaSL_compiler)); | 948 | memset(&compiler, 0, sizeof(LuaSL_compiler)); |
949 | compiler.game = game; | 949 | compiler.game = game; |
950 | compiler.ignorableText = eina_strbuf_new(); | ||
950 | 951 | ||
951 | strncpy(compiler.fileName, script, PATH_MAX - 1); | 952 | strncpy(compiler.fileName, script, PATH_MAX - 1); |
952 | compiler.fileName[PATH_MAX - 1] = '\0'; | 953 | compiler.fileName[PATH_MAX - 1] = '\0'; |
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 9c90ed5..3270aff 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -136,21 +136,10 @@ int common(YYSTYPE *lval, char *text, int len, LuaSL_compiler *compiler, boolean | |||
136 | if (checkIgnorable) | 136 | if (checkIgnorable) |
137 | { | 137 | { |
138 | lval->ignorableText = compiler->ignorableText; | 138 | lval->ignorableText = compiler->ignorableText; |
139 | compiler->ignorableText = NULL; | 139 | compiler->ignorableText = eina_strbuf_new(); |
140 | } | 140 | } |
141 | else | 141 | else |
142 | { | 142 | eina_strbuf_append_length(compiler->ignorableText, text, len); |
143 | if (compiler->ignorableText) | ||
144 | { | ||
145 | int lenI = strlen(compiler->ignorableText); | ||
146 | int lenT = strlen(text); | ||
147 | |||
148 | compiler->ignorableText = realloc(compiler->ignorableText, lenI + lenT + 1); | ||
149 | sprintf(&(compiler->ignorableText[lenI]), "%s", text); | ||
150 | } | ||
151 | else | ||
152 | compiler->ignorableText = strdup(text); | ||
153 | } | ||
154 | 143 | ||
155 | return type; | 144 | return type; |
156 | } | 145 | } |