mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-21 03:11:40 +00:00
ZScript parser: added support for min and max value constants in the states block. Fixes #1019
This commit is contained in:
parent
071818dc2d
commit
456ae573ed
1 changed files with 49 additions and 14 deletions
|
@ -59,6 +59,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
// todo: parse stuff
|
// todo: parse stuff
|
||||||
//
|
//
|
||||||
string[] control_keywords = new string[] { "goto", "loop", "wait", "fail", "stop" };
|
string[] control_keywords = new string[] { "goto", "loop", "wait", "fail", "stop" };
|
||||||
|
string[] data_types = new string[] { "double", "int", "uint" };
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -150,6 +151,39 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
// this can be a function call, or a constant.
|
// this can be a function call, or a constant.
|
||||||
token = tokenizer.ExpectToken(ZScriptTokenType.Identifier);
|
token = tokenizer.ExpectToken(ZScriptTokenType.Identifier);
|
||||||
if (token != null && token.IsValid)
|
if (token != null && token.IsValid)
|
||||||
|
{
|
||||||
|
// Known data type? Then it's hopefully the .min or .max value (like int.min or int.max)
|
||||||
|
if (data_types.Contains(token.Value))
|
||||||
|
{
|
||||||
|
token = tokenizer.ExpectToken(ZScriptTokenType.Dot);
|
||||||
|
if(token == null || !token.IsValid)
|
||||||
|
{
|
||||||
|
parser.ReportError("Expected ., got " + ((Object)token ?? "<null>").ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
token = tokenizer.ExpectToken(ZScriptTokenType.Identifier);
|
||||||
|
if (token == null || !token.IsValid)
|
||||||
|
{
|
||||||
|
parser.ReportError("Expected an identifier, got " + ((Object)token ?? "<null>").ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (token.Value == "min")
|
||||||
|
{
|
||||||
|
duration = int.MinValue;
|
||||||
|
}
|
||||||
|
else if (token.Value == "max")
|
||||||
|
{
|
||||||
|
duration = int.MaxValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parser.ReportError("Expected min or max, got " + ((Object)token ?? "<null>").ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // No known data type
|
||||||
{
|
{
|
||||||
duration = -1;
|
duration = -1;
|
||||||
tokenizer.SkipWhitespace();
|
tokenizer.SkipWhitespace();
|
||||||
|
@ -166,6 +200,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!parser.ParseInteger(out duration))
|
if (!parser.ParseInteger(out duration))
|
||||||
|
|
Loading…
Reference in a new issue