aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src/LuaSL_LSL_tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/src/LuaSL_LSL_tree.c')
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.c b/LuaSL/src/LuaSL_LSL_tree.c
index e37f794..af6e02f 100644
--- a/LuaSL/src/LuaSL_LSL_tree.c
+++ b/LuaSL/src/LuaSL_LSL_tree.c
@@ -15,6 +15,7 @@ static void outputIntegerToken(FILE *file, LSL_Leaf *content);
15static void outputParameterToken(FILE *file, LSL_Leaf *content); 15static void outputParameterToken(FILE *file, LSL_Leaf *content);
16static void outputParameterListToken(FILE *file, LSL_Leaf *content); 16static void outputParameterListToken(FILE *file, LSL_Leaf *content);
17static void outputParenthesisToken(FILE *file, LSL_Leaf *content); 17static void outputParenthesisToken(FILE *file, LSL_Leaf *content);
18static void outputStateToken(FILE *file, LSL_Leaf *content);
18static void outputStatementToken(FILE *file, LSL_Leaf *content); 19static void outputStatementToken(FILE *file, LSL_Leaf *content);
19static void outputVariableToken(FILE *file, LSL_Leaf *content); 20static void outputVariableToken(FILE *file, LSL_Leaf *content);
20 21
@@ -119,7 +120,7 @@ LSL_Token LSL_Tokens[] =
119 {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputParameterToken, NULL, NULL}, 120 {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputParameterToken, NULL, NULL},
120 {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL, NULL}, 121 {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL, NULL},
121 {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL, NULL}, 122 {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL, NULL},
122 {LSL_STATE, ST_NONE, "state", LSL_NONE, NULL, NULL, NULL}, 123 {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken, NULL, NULL},
123 {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL, NULL}, 124 {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL, NULL},
124 125
125 {LSL_UNKNOWN, ST_NONE, "unknown", LSL_NONE, NULL, NULL, NULL}, 126 {LSL_UNKNOWN, ST_NONE, "unknown", LSL_NONE, NULL, NULL, NULL},
@@ -362,19 +363,21 @@ LSL_Leaf *addParenthesis(LSL_Leaf *lval, LSL_Leaf *expr, LSL_Type type, LSL_Leaf
362 return lval; 363 return lval;
363} 364}
364 365
365LSL_Leaf *addState(LuaSL_yyparseParam *param, char *name, LSL_Leaf *state) 366LSL_Leaf *addState(LuaSL_yyparseParam *param, LSL_Leaf *identifier, LSL_Leaf *block)
366{ 367{
367 LSL_State *result = calloc(1, sizeof(LSL_State)); 368 LSL_State *result = calloc(1, sizeof(LSL_State));
368 369
369 if (result) 370 if ((identifier) && (result))
370 { 371 {
371 result->name = name; 372 result->name = identifier->value.stringValue;
373 result->block = block;
374 identifier->value.stateValue = result;
372 param->script.scount++; 375 param->script.scount++;
373 param->script.states = realloc(param->script.states, param->script.scount * sizeof(LSL_State *)); 376 param->script.states = realloc(param->script.states, param->script.scount * sizeof(LSL_State *));
374 param->script.states[param->script.scount - 1] = result; 377 param->script.states[param->script.scount - 1] = result;
375 } 378 }
376 379
377 return state; 380 return identifier;
378} 381}
379 382
380LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr) 383LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr)
@@ -829,6 +832,17 @@ static void outputParenthesisToken(FILE *file, LSL_Leaf *content)
829 } 832 }
830} 833}
831 834
835static void outputStateToken(FILE *file, LSL_Leaf *content)
836{
837 if (content)
838 {
839 LSL_State *state = content->value.stateValue;
840
841 fprintf(file, "%s", state->name);
842 outputLeaf(file, state->block);
843 }
844}
845
832static void outputStatementToken(FILE *file, LSL_Leaf *content) 846static void outputStatementToken(FILE *file, LSL_Leaf *content)
833{ 847{
834 if (content) 848 if (content)