From 6629a6b405c3d1f9364ab44a8afc8e899cc3714a Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 21 Jan 2012 17:20:32 +1000 Subject: The default state is a different syntax from the other states. --- LuaSL/src/LuaSL_compile.c | 12 ++++++++++-- LuaSL/src/LuaSL_lemon_yaccer.y | 3 ++- LuaSL/src/LuaSL_lexer.l | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 7744c60..6fc3ce1 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -135,6 +135,7 @@ LSL_Token LSL_Tokens[] = {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputIdentifierToken, NULL}, {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL}, {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL}, + {LSL_DEFAULT, ST_NONE, "default", LSL_NONE, outputStateToken, NULL}, {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken, NULL}, {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL}, @@ -1105,8 +1106,15 @@ static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content) { LSL_State *state = content->value.stateValue; - fprintf(file, "%s", state->name); - outputLeaf(file, mode, state->block); + if (state) + { + if (0 == strcmp(state->name, "default")) + fprintf(file, "%s\n", state->name); + else + fprintf(file, "state %s\n", state->name); + outputLeaf(file, mode, state->block); + fprintf(file, "\n"); + } } } diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y index 1e5389d..4c8cf75 100644 --- a/LuaSL/src/LuaSL_lemon_yaccer.y +++ b/LuaSL/src/LuaSL_lemon_yaccer.y @@ -32,7 +32,8 @@ script ::= . %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. stateBlock ::= LSL_BLOCK_OPEN functionList LSL_BLOCK_CLOSE. -state(S) ::= LSL_IDENTIFIER(I) stateBlock(B). { S = addState(compiler, I, B); } +state(S) ::= LSL_DEFAULT(I) stateBlock(B). { S = addState(compiler, I, B); } +state(S) ::= LSL_STATE_CHANGE LSL_IDENTIFIER(I) stateBlock(B). { S = addState(compiler, I, B); } // Function definitions. diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 1d2548a..132710c 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l @@ -91,6 +91,7 @@ STRING \"(\\.|[^\\"\n])*\" "vector" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_TYPE_VECTOR); %} /* Statement keywords. */ +"default" %{ yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_DEFAULT); %} "do" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_DO); %} "for" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FOR); %} "else" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_ELSE); %} -- cgit v1.1