Add new state options to parser and actually enable them
- Added new state options that DECORATE got to the lemon parser. - Enable token generation for state options. They were previously not generated, so the grammar treated them as function calls instead.
This commit is contained in:
parent
078d37e073
commit
964ff46063
8 changed files with 101 additions and 39 deletions
|
|
@ -377,10 +377,11 @@ static void PrintStateLine(FLispString &out, ZCC_TreeNode *node)
|
|||
ZCC_StateLine *snode = (ZCC_StateLine *)node;
|
||||
out.Open("state-line");
|
||||
out.Add(snode->Sprite, 4);
|
||||
if (snode->bBright)
|
||||
{
|
||||
out.Add("bright", 6);
|
||||
}
|
||||
if (snode->bNoDelay) out.Add("nodelay", 7);
|
||||
if (snode->bBright) out.Add("bright", 6);
|
||||
if (snode->bFast) out.Add("fast", 4);
|
||||
if (snode->bSlow) out.Add("slow", 4);
|
||||
if (snode->bCanRaise) out.Add("canraise", 8);
|
||||
out.Add(*(snode->Frames));
|
||||
PrintNodes(out, snode->Offset);
|
||||
PrintNodes(out, snode->Action, false);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,19 @@ static void SetNodeLine(ZCC_TreeNode *name, int line)
|
|||
struct StateOpts {
|
||||
ZCC_Expression *Offset;
|
||||
bool Bright;
|
||||
bool Fast;
|
||||
bool Slow;
|
||||
bool NoDelay;
|
||||
bool CanRaise;
|
||||
|
||||
void Zero() {
|
||||
Offset = NULL;
|
||||
Bright = false;
|
||||
Fast = false;
|
||||
Slow = false;
|
||||
NoDelay = false;
|
||||
CanRaise = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct VarOrFun
|
||||
|
|
@ -433,15 +446,23 @@ state_line(X) ::= NWS(A) NWS(B) expr state_opts(C) state_action(D).
|
|||
}
|
||||
line->Frames = stat->Strings.Alloc(FName(B.Name()).GetChars());
|
||||
line->bBright = C.Bright;
|
||||
line->bFast = C.Fast;
|
||||
line->bSlow = C.Slow;
|
||||
line->bNoDelay = C.NoDelay;
|
||||
line->bCanRaise = C.CanRaise;
|
||||
line->Offset = C.Offset;
|
||||
line->Action = D;
|
||||
X = line;
|
||||
}
|
||||
|
||||
state_opts(X) ::= . { StateOpts opts; opts.Offset = NULL; opts.Bright = false; X = opts; }
|
||||
state_opts(X) ::= . { StateOpts opts; opts.Zero(); X = opts; }
|
||||
state_opts(X) ::= state_opts(A) BRIGHT. { A.Bright = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) FAST. { A.Fast = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) SLOW. { A.Slow = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) NODELAY. { A.NoDelay = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) CANRAISE. { A.CanRaise = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) OFFSET LPAREN expr(B) COMMA expr(C) RPAREN. { A.Offset = B; B->AppendSibling(C); X = A; }
|
||||
state_opts(X) ::= state_opts(A) LIGHT LPAREN light_list RPAREN. { X = A; }
|
||||
state_opts(X) ::= state_opts(A) LIGHT LPAREN light_list RPAREN. { X = A; } ///FIXME: GZDoom would want to know this
|
||||
|
||||
light_list ::= STRCONST.
|
||||
light_list ::= light_list COMMA STRCONST.
|
||||
|
|
|
|||
|
|
@ -147,6 +147,14 @@ static void InitTokenMap()
|
|||
TOKENDEF (TK_FloatConst, ZCC_FLOATCONST);
|
||||
TOKENDEF (TK_NonWhitespace, ZCC_NWS);
|
||||
|
||||
TOKENDEF (TK_Bright, ZCC_BRIGHT);
|
||||
TOKENDEF (TK_Slow, ZCC_SLOW);
|
||||
TOKENDEF (TK_Fast, ZCC_FAST);
|
||||
TOKENDEF (TK_NoDelay, ZCC_NODELAY);
|
||||
TOKENDEF (TK_Offset, ZCC_OFFSET);
|
||||
TOKENDEF (TK_CanRaise, ZCC_CANRAISE);
|
||||
TOKENDEF (TK_Light, ZCC_CANRAISE);
|
||||
|
||||
ZCC_InitOperators();
|
||||
ZCC_InitConversions();
|
||||
}
|
||||
|
|
@ -194,43 +202,44 @@ static void DoParse(const char *filename)
|
|||
while (sc.GetToken())
|
||||
{
|
||||
value.SourceLoc = sc.GetMessageLine();
|
||||
if (sc.TokenType == TK_StringConst)
|
||||
switch (sc.TokenType)
|
||||
{
|
||||
case TK_StringConst:
|
||||
value.String = state.Strings.Alloc(sc.String, sc.StringLen);
|
||||
tokentype = ZCC_STRCONST;
|
||||
}
|
||||
else if (sc.TokenType == TK_NameConst)
|
||||
{
|
||||
break;
|
||||
|
||||
case TK_NameConst:
|
||||
value.Int = sc.Name;
|
||||
tokentype = ZCC_NAMECONST;
|
||||
}
|
||||
else if (sc.TokenType == TK_IntConst)
|
||||
{
|
||||
break;
|
||||
|
||||
case TK_IntConst:
|
||||
value.Int = sc.Number;
|
||||
tokentype = ZCC_INTCONST;
|
||||
}
|
||||
else if (sc.TokenType == TK_UIntConst)
|
||||
{
|
||||
break;
|
||||
|
||||
case TK_UIntConst:
|
||||
value.Int = sc.Number;
|
||||
tokentype = ZCC_UINTCONST;
|
||||
}
|
||||
else if (sc.TokenType == TK_FloatConst)
|
||||
{
|
||||
break;
|
||||
|
||||
case TK_FloatConst:
|
||||
value.Float = sc.Float;
|
||||
tokentype = ZCC_FLOATCONST;
|
||||
}
|
||||
else if (sc.TokenType == TK_Identifier)
|
||||
{
|
||||
break;
|
||||
|
||||
case TK_Identifier:
|
||||
value.Int = FName(sc.String);
|
||||
tokentype = ZCC_IDENTIFIER;
|
||||
}
|
||||
else if (sc.TokenType == TK_NonWhitespace)
|
||||
{
|
||||
break;
|
||||
|
||||
case TK_NonWhitespace:
|
||||
value.Int = FName(sc.String);
|
||||
tokentype = ZCC_NWS;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
default:
|
||||
TokenMapEntry *zcctoken = TokenMap.CheckKey(sc.TokenType);
|
||||
if (zcctoken != NULL)
|
||||
{
|
||||
|
|
@ -240,16 +249,18 @@ static void DoParse(const char *filename)
|
|||
else
|
||||
{
|
||||
sc.ScriptMessage("Unexpected token %s.\n", sc.TokenName(sc.TokenType).GetChars());
|
||||
break;
|
||||
goto parse_end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
ZCCParse(parser, tokentype, value, &state);
|
||||
if (failed)
|
||||
{
|
||||
sc.ScriptMessage("Parse failed\n");
|
||||
break;
|
||||
goto parse_end;
|
||||
}
|
||||
}
|
||||
parse_end:
|
||||
value.Int = -1;
|
||||
ZCCParse(parser, ZCC_EOF, value, &state);
|
||||
ZCCParse(parser, 0, value, &state);
|
||||
|
|
|
|||
|
|
@ -253,7 +253,11 @@ struct ZCC_StateGoto : ZCC_StatePart
|
|||
struct ZCC_StateLine : ZCC_StatePart
|
||||
{
|
||||
char Sprite[4];
|
||||
BITFIELD bBright:1;
|
||||
BITFIELD bBright : 1;
|
||||
BITFIELD bFast : 1;
|
||||
BITFIELD bSlow : 1;
|
||||
BITFIELD bNoDelay : 1;
|
||||
BITFIELD bCanRaise : 1;
|
||||
FString *Frames;
|
||||
ZCC_Expression *Offset;
|
||||
ZCC_TreeNode *Action;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue