diff options
author | David Walter Seikel | 2012-01-21 17:20:32 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-21 17:20:32 +1000 |
commit | 6629a6b405c3d1f9364ab44a8afc8e899cc3714a (patch) | |
tree | 7bc2a8b2a50a16d3e1b3966ace7e08dd25e1c62f | |
parent | Add more LSL constants and functions. (diff) | |
download | SledjHamr-6629a6b405c3d1f9364ab44a8afc8e899cc3714a.zip SledjHamr-6629a6b405c3d1f9364ab44a8afc8e899cc3714a.tar.gz SledjHamr-6629a6b405c3d1f9364ab44a8afc8e899cc3714a.tar.bz2 SledjHamr-6629a6b405c3d1f9364ab44a8afc8e899cc3714a.tar.xz |
The default state is a different syntax from the other states.
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 12 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_lemon_yaccer.y | 3 | ||||
-rw-r--r-- | 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[] = | |||
135 | {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputIdentifierToken, NULL}, | 135 | {LSL_PARAMETER, ST_NONE, "parameter", LSL_NONE, outputIdentifierToken, NULL}, |
136 | {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL}, | 136 | {LSL_PARAMETER_LIST, ST_NONE, "plist", LSL_NONE, outputParameterListToken, NULL}, |
137 | {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL}, | 137 | {LSL_FUNCTION, ST_NONE, "function", LSL_NONE, outputFunctionToken, NULL}, |
138 | {LSL_DEFAULT, ST_NONE, "default", LSL_NONE, outputStateToken, NULL}, | ||
138 | {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken, NULL}, | 139 | {LSL_STATE, ST_NONE, "state", LSL_NONE, outputStateToken, NULL}, |
139 | {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL}, | 140 | {LSL_SCRIPT, ST_NONE, "", LSL_NONE, NULL, NULL}, |
140 | 141 | ||
@@ -1105,8 +1106,15 @@ static void outputStateToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
1105 | { | 1106 | { |
1106 | LSL_State *state = content->value.stateValue; | 1107 | LSL_State *state = content->value.stateValue; |
1107 | 1108 | ||
1108 | fprintf(file, "%s", state->name); | 1109 | if (state) |
1109 | outputLeaf(file, mode, state->block); | 1110 | { |
1111 | if (0 == strcmp(state->name, "default")) | ||
1112 | fprintf(file, "%s\n", state->name); | ||
1113 | else | ||
1114 | fprintf(file, "state %s\n", state->name); | ||
1115 | outputLeaf(file, mode, state->block); | ||
1116 | fprintf(file, "\n"); | ||
1117 | } | ||
1110 | } | 1118 | } |
1111 | } | 1119 | } |
1112 | 1120 | ||
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 ::= . | |||
32 | 32 | ||
33 | %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. | 33 | %nonassoc LSL_BLOCK_OPEN LSL_BLOCK_CLOSE LSL_STATE. |
34 | stateBlock ::= LSL_BLOCK_OPEN functionList LSL_BLOCK_CLOSE. | 34 | stateBlock ::= LSL_BLOCK_OPEN functionList LSL_BLOCK_CLOSE. |
35 | state(S) ::= LSL_IDENTIFIER(I) stateBlock(B). { S = addState(compiler, I, B); } | 35 | state(S) ::= LSL_DEFAULT(I) stateBlock(B). { S = addState(compiler, I, B); } |
36 | state(S) ::= LSL_STATE_CHANGE LSL_IDENTIFIER(I) stateBlock(B). { S = addState(compiler, I, B); } | ||
36 | 37 | ||
37 | // Function definitions. | 38 | // Function definitions. |
38 | 39 | ||
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])*\" | |||
91 | "vector" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_TYPE_VECTOR); %} | 91 | "vector" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_TYPE_VECTOR); %} |
92 | 92 | ||
93 | /* Statement keywords. */ | 93 | /* Statement keywords. */ |
94 | "default" %{ yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_DEFAULT); %} | ||
94 | "do" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_DO); %} | 95 | "do" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_DO); %} |
95 | "for" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FOR); %} | 96 | "for" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_FOR); %} |
96 | "else" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_ELSE); %} | 97 | "else" %{ return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_ELSE); %} |