From d3356bf6e8eeadd3afbd9db2e59621d50dbefb63 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 17 Jan 2012 10:47:26 +1000 Subject: Actually make state work. lol --- LuaSL/src/LuaSL_LSL_tree.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'LuaSL/src/LuaSL_LSL_tree.c') 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); static void outputParameterToken(FILE *file, LSL_Leaf *content); static void outputParameterListToken(FILE *file, LSL_Leaf *content); static void outputParenthesisToken(FILE *file, LSL_Leaf *content); +static void outputStateToken(FILE *file, LSL_Leaf *content); static void outputStatementToken(FILE *file, LSL_Leaf *content); static void outputVariableToken(FILE *file, LSL_Leaf *content); @@ -119,7 +120,7 @@ LSL_Token LSL_Tokens[] = {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputParameterToken, NULL, NULL}, {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL, NULL}, {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL, NULL}, - {LSL_STATE, ST_NONE, "state", LSL_NONE, NULL, NULL, NULL}, + {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken, NULL, NULL}, {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL, NULL}, {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 return lval; } -LSL_Leaf *addState(LuaSL_yyparseParam *param, char *name, LSL_Leaf *state) +LSL_Leaf *addState(LuaSL_yyparseParam *param, LSL_Leaf *identifier, LSL_Leaf *block) { LSL_State *result = calloc(1, sizeof(LSL_State)); - if (result) + if ((identifier) && (result)) { - result->name = name; + result->name = identifier->value.stringValue; + result->block = block; + identifier->value.stateValue = result; param->script.scount++; param->script.states = realloc(param->script.states, param->script.scount * sizeof(LSL_State *)); param->script.states[param->script.scount - 1] = result; } - return state; + return identifier; } LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *expr) @@ -829,6 +832,17 @@ static void outputParenthesisToken(FILE *file, LSL_Leaf *content) } } +static void outputStateToken(FILE *file, LSL_Leaf *content) +{ + if (content) + { + LSL_State *state = content->value.stateValue; + + fprintf(file, "%s", state->name); + outputLeaf(file, state->block); + } +} + static void outputStatementToken(FILE *file, LSL_Leaf *content) { if (content) -- cgit v1.1