- parser for states flags.

This commit is contained in:
Christoph Oelckers 2016-11-14 19:35:29 +01:00
commit 7bcd83f0c1
6 changed files with 87 additions and 43 deletions

View file

@ -358,6 +358,7 @@ static void PrintStates(FLispString &out, ZCC_TreeNode *node)
ZCC_States *snode = (ZCC_States *)node;
out.Break();
out.Open("states");
PrintNodes(out, snode->Flags, false, true);
PrintNodes(out, snode->Body, false, true);
out.Close();
}

View file

@ -418,14 +418,37 @@ enumerator(X) ::= IDENTIFIER(A) EQ expr(B). /* Expression must be constant. */
%type state_call_params {ZCC_FuncParm *}
%type state_opts {StateOpts}
%type states_opts { ZCC_Identifier *}
%type states_opt { ZCC_Identifier *}
states_def(X) ::= STATES(T) scanner_mode LBRACE states_body(A) RBRACE.
states_def(X) ::= STATES(T) states_opts(B) scanner_mode LBRACE states_body(A) RBRACE.
{
NEW_AST_NODE(States,def,T);
def->Flags = B;
def->Body = A;
X = def;
}
states_opts(X) ::= . { X = nullptr; }
states_opts(X) ::= LPAREN states_opt(A) RPAREN. { X = A; /*X-overwrites-A*/ }
states_opt(X) ::= IDENTIFIER(A).
{
NEW_AST_NODE(Identifier,id,A);
id->Id = A.Name();
X = id;
}
states_opt(X) ::= states_opt(A) COMMA IDENTIFIER(B).
{
NEW_AST_NODE(Identifier,id,B);
id->Id = B.Name();
X = A; /*X-overwrites-A*/
X->AppendSibling(id);
}
/* We use a special scanner mode to allow for sprite names and frame characters
* to not be quoted even if they contain special characters. The scanner_mode
* nonterminal is used to enter this mode. The scanner automatically leaves it

View file

@ -228,6 +228,7 @@ struct ZCC_EnumTerminator : ZCC_TreeNode
struct ZCC_States : ZCC_TreeNode
{
struct ZCC_StatePart *Body;
ZCC_Identifier *Flags;
};
struct ZCC_StatePart : ZCC_TreeNode