mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-12-15 15:11:32 +00:00
Accept name constants in the grammar
This commit is contained in:
parent
b6e525d935
commit
33e835b58d
3 changed files with 18 additions and 0 deletions
|
@ -537,6 +537,10 @@ static void PrintExprConstant(FLispString &out, ZCC_TreeNode *node)
|
||||||
{
|
{
|
||||||
out.AddFloat(enode->DoubleVal);
|
out.AddFloat(enode->DoubleVal);
|
||||||
}
|
}
|
||||||
|
else if (enode->Type == TypeName)
|
||||||
|
{
|
||||||
|
out.AddName(ENamedName(enode->IntVal));
|
||||||
|
}
|
||||||
else if (enode->Type->IsKindOf(RUNTIME_CLASS(PInt)))
|
else if (enode->Type->IsKindOf(RUNTIME_CLASS(PInt)))
|
||||||
{
|
{
|
||||||
out.AddInt(enode->IntVal, static_cast<PInt *>(enode->Type)->Unsigned);
|
out.AddInt(enode->IntVal, static_cast<PInt *>(enode->Type)->Unsigned);
|
||||||
|
|
|
@ -1141,6 +1141,14 @@ constant(X) ::= FLOATCONST(A).
|
||||||
floatconst->DoubleVal = A.Float;
|
floatconst->DoubleVal = A.Float;
|
||||||
X = floatconst;
|
X = floatconst;
|
||||||
}
|
}
|
||||||
|
constant(X) ::= NAMECONST(A).
|
||||||
|
{
|
||||||
|
NEW_AST_NODE(ExprConstant, floatconst, A);
|
||||||
|
floatconst->Operation = PEX_ConstValue;
|
||||||
|
floatconst->Type = TypeName;
|
||||||
|
floatconst->IntVal = A.Int;
|
||||||
|
X = floatconst;
|
||||||
|
}
|
||||||
|
|
||||||
/************ Statements ************/
|
/************ Statements ************/
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@ static void InitTokenMap()
|
||||||
|
|
||||||
TOKENDEF (TK_Identifier, ZCC_IDENTIFIER);
|
TOKENDEF (TK_Identifier, ZCC_IDENTIFIER);
|
||||||
TOKENDEF (TK_StringConst, ZCC_STRCONST);
|
TOKENDEF (TK_StringConst, ZCC_STRCONST);
|
||||||
|
TOKENDEF (TK_NameConst, ZCC_NAMECONST);
|
||||||
TOKENDEF (TK_IntConst, ZCC_INTCONST);
|
TOKENDEF (TK_IntConst, ZCC_INTCONST);
|
||||||
TOKENDEF (TK_UIntConst, ZCC_UINTCONST);
|
TOKENDEF (TK_UIntConst, ZCC_UINTCONST);
|
||||||
TOKENDEF (TK_FloatConst, ZCC_FLOATCONST);
|
TOKENDEF (TK_FloatConst, ZCC_FLOATCONST);
|
||||||
|
@ -193,6 +194,11 @@ static void DoParse(const char *filename)
|
||||||
value.String = state.Strings.Alloc(sc.String, sc.StringLen);
|
value.String = state.Strings.Alloc(sc.String, sc.StringLen);
|
||||||
tokentype = ZCC_STRCONST;
|
tokentype = ZCC_STRCONST;
|
||||||
}
|
}
|
||||||
|
else if (sc.TokenType == TK_NameConst)
|
||||||
|
{
|
||||||
|
value.Int = sc.Name;
|
||||||
|
tokentype = ZCC_NAMECONST;
|
||||||
|
}
|
||||||
else if (sc.TokenType == TK_IntConst)
|
else if (sc.TokenType == TK_IntConst)
|
||||||
{
|
{
|
||||||
value.Int = sc.Number;
|
value.Int = sc.Number;
|
||||||
|
|
Loading…
Reference in a new issue