mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
Let the grammar accept unsigned integer constants
This commit is contained in:
parent
33344201fa
commit
1b4851224e
2 changed files with 17 additions and 1 deletions
|
@ -449,7 +449,7 @@ type_name(X) ::= DOT dottable_id(A).
|
||||||
* straight away.)
|
* straight away.)
|
||||||
*/
|
*/
|
||||||
vector_size(X) ::= . { X.Int = ZCC_Vector3; X.SourceLoc = stat->sc.GetMessageLine(); }
|
vector_size(X) ::= . { X.Int = ZCC_Vector3; X.SourceLoc = stat->sc.GetMessageLine(); }
|
||||||
vector_size(X) ::= LT INTCONST(A) GT.
|
vector_size(X) ::= LT intconst(A) GT.
|
||||||
{
|
{
|
||||||
if (A.Int >= 2 && A.Int <= 4)
|
if (A.Int >= 2 && A.Int <= 4)
|
||||||
{
|
{
|
||||||
|
@ -462,6 +462,8 @@ vector_size(X) ::= LT INTCONST(A) GT.
|
||||||
}
|
}
|
||||||
X.SourceLoc = A.SourceLoc;
|
X.SourceLoc = A.SourceLoc;
|
||||||
}
|
}
|
||||||
|
intconst(X) ::= INTCONST(A). { X = A; }
|
||||||
|
intconst(X) ::= UINTCONST(A). { X = A; }
|
||||||
|
|
||||||
/* Type names can also be used as identifiers in contexts where type names
|
/* Type names can also be used as identifiers in contexts where type names
|
||||||
* are not normally allowed. */
|
* are not normally allowed. */
|
||||||
|
@ -1123,6 +1125,14 @@ constant(X) ::= INTCONST(A).
|
||||||
intconst->IntVal = A.Int;
|
intconst->IntVal = A.Int;
|
||||||
X = intconst;
|
X = intconst;
|
||||||
}
|
}
|
||||||
|
constant(X) ::= UINTCONST(A).
|
||||||
|
{
|
||||||
|
NEW_AST_NODE(ExprConstant, intconst, A);
|
||||||
|
intconst->Operation = PEX_ConstValue;
|
||||||
|
intconst->Type = TypeUInt32;
|
||||||
|
intconst->IntVal = A.Int;
|
||||||
|
X = intconst;
|
||||||
|
}
|
||||||
constant(X) ::= FLOATCONST(A).
|
constant(X) ::= FLOATCONST(A).
|
||||||
{
|
{
|
||||||
NEW_AST_NODE(ExprConstant, floatconst, A);
|
NEW_AST_NODE(ExprConstant, floatconst, A);
|
||||||
|
|
|
@ -140,6 +140,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_IntConst, ZCC_INTCONST);
|
TOKENDEF (TK_IntConst, ZCC_INTCONST);
|
||||||
|
TOKENDEF (TK_UIntConst, ZCC_UINTCONST);
|
||||||
TOKENDEF (TK_FloatConst, ZCC_FLOATCONST);
|
TOKENDEF (TK_FloatConst, ZCC_FLOATCONST);
|
||||||
TOKENDEF (TK_NonWhitespace, ZCC_NWS);
|
TOKENDEF (TK_NonWhitespace, ZCC_NWS);
|
||||||
}
|
}
|
||||||
|
@ -197,6 +198,11 @@ static void DoParse(const char *filename)
|
||||||
value.Int = sc.Number;
|
value.Int = sc.Number;
|
||||||
tokentype = ZCC_INTCONST;
|
tokentype = ZCC_INTCONST;
|
||||||
}
|
}
|
||||||
|
else if (sc.TokenType == TK_UIntConst)
|
||||||
|
{
|
||||||
|
value.Int = sc.Number;
|
||||||
|
tokentype = ZCC_UINTCONST;
|
||||||
|
}
|
||||||
else if (sc.TokenType == TK_FloatConst)
|
else if (sc.TokenType == TK_FloatConst)
|
||||||
{
|
{
|
||||||
value.Float = sc.Float;
|
value.Float = sc.Float;
|
||||||
|
|
Loading…
Reference in a new issue