- Fixed: The DECORATE expression evaluator evaluated operators of same

precedence right to left instead of left to right.


SVN r398 (trunk)
This commit is contained in:
Christoph Oelckers 2006-11-29 22:43:05 +00:00
parent 63bd2125f3
commit 37e8533773
2 changed files with 87 additions and 143 deletions

View file

@ -1,4 +1,6 @@
November 29, 2006 (Changes by Graf Zahl) November 29, 2006 (Changes by Graf Zahl)
- Fixed: The DECORATE expression evaluator evaluated operators of same
precedence right to left instead of left to right.
- Added global constants to DECORATE so that I can define meaningful flag - Added global constants to DECORATE so that I can define meaningful flag
names for some DECORATE functions. Technically these will be constants names for some DECORATE functions. Technically these will be constants
of the AActor class but that will make them accessible in all other actor of the AActor class but that will make them accessible in all other actor
@ -21,7 +23,6 @@ November 28, 2006
- Added integer constant declarations to objects. - Added integer constant declarations to objects.
- Added a simple symbol table to PClass. - Added a simple symbol table to PClass.
>>>>>>> .r394
November 27, 2006 (Changes by Graf Zahl) November 27, 2006 (Changes by Graf Zahl)
- Changed: When playing a shareware game no external WADs are loaded at all, - Changed: When playing a shareware game no external WADs are loaded at all,
not even zvox.wad or the skins directory. not even zvox.wad or the skins directory.

View file

@ -427,237 +427,180 @@ static ExpData *ParseExpressionL (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionK (cls); ExpData *tmp = ParseExpressionK (cls);
if (SC_CheckToken(TK_OrOr)) while (SC_CheckToken(TK_OrOr))
{ {
ExpData *right = ParseExpressionK (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = EX_LogOr; data->Type = EX_LogOr;
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionL (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
return data; tmp = data;
} }
else
{
return tmp; return tmp;
} }
}
static ExpData *ParseExpressionK (const PClass *cls) static ExpData *ParseExpressionK (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionJ (cls); ExpData *tmp = ParseExpressionJ (cls);
if (SC_CheckToken(TK_AndAnd)) while (SC_CheckToken(TK_AndAnd))
{ {
ExpData *right = ParseExpressionJ (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = EX_LogAnd; data->Type = EX_LogAnd;
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionK (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
return data; tmp = data;
} }
else
{
return tmp; return tmp;
} }
}
static ExpData *ParseExpressionJ (const PClass *cls) static ExpData *ParseExpressionJ (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionI (cls); ExpData *tmp = ParseExpressionI (cls);
if (SC_CheckToken('|')) while (SC_CheckToken('|'))
{ {
ExpData *right = ParseExpressionI (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = EX_Or; data->Type = EX_Or;
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionJ (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
return data; tmp = data;
} }
else
{
return tmp; return tmp;
} }
}
static ExpData *ParseExpressionI (const PClass *cls) static ExpData *ParseExpressionI (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionH (cls); ExpData *tmp = ParseExpressionH (cls);
if (SC_CheckToken('^')) while (SC_CheckToken('^'))
{ {
ExpData *right = ParseExpressionH (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = EX_Xor; data->Type = EX_Xor;
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionI (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
return data; tmp = data;
} }
else
{
return tmp; return tmp;
} }
}
static ExpData *ParseExpressionH (const PClass *cls) static ExpData *ParseExpressionH (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionG (cls); ExpData *tmp = ParseExpressionG (cls);
if (SC_CheckToken('&')) while (SC_CheckToken('&'))
{ {
ExpData *right = ParseExpressionG (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = EX_And; data->Type = EX_And;
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionH (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
return data; tmp = data;
} }
else
{
return tmp; return tmp;
} }
}
static ExpData *ParseExpressionG (const PClass *cls) static ExpData *ParseExpressionG (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionF (cls); ExpData *tmp = ParseExpressionF (cls);
while (SC_GetToken() && (sc_TokenType == TK_Eq || sc_TokenType == TK_Neq))
{
int token = sc_TokenType;
ExpData *right = ParseExpressionF (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = token == TK_Eq? EX_Eq : EX_NE;
if (SC_CheckToken(TK_Eq))
{
data->Type = EX_Eq;
}
else if (SC_CheckToken(TK_Neq))
{
data->Type = EX_NE;
}
else
{
delete data;
return tmp;
}
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionG (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
tmp = data;
return data; }
if (!sc_End) SC_UnGet();
return tmp;
} }
static ExpData *ParseExpressionF (const PClass *cls) static ExpData *ParseExpressionF (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionE (cls); ExpData *tmp = ParseExpressionE (cls);
while (SC_GetToken() && (sc_TokenType == '<' || sc_TokenType == '>' || sc_TokenType == TK_Leq || sc_TokenType == TK_Geq))
{
int token = sc_TokenType;
ExpData *right = ParseExpressionE (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = token == '<' ? EX_LT : sc_TokenType == '>' ? EX_GT : sc_TokenType == TK_Leq? EX_LE : EX_GE;
if (SC_CheckToken('<'))
{
data->Type = EX_LT;
}
else if (SC_CheckToken('>'))
{
data->Type = EX_GT;
}
else if (SC_CheckToken(TK_Leq))
{
data->Type = EX_LE;
}
else if (SC_CheckToken(TK_Geq))
{
data->Type = EX_GE;
}
else
{
delete data;
return tmp;
}
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionF (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
tmp = data;
return data; }
if (!sc_End) SC_UnGet();
return tmp;
} }
static ExpData *ParseExpressionE (const PClass *cls) static ExpData *ParseExpressionE (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionD (cls); ExpData *tmp = ParseExpressionD (cls);
while (SC_GetToken() && (sc_TokenType == TK_LShift || sc_TokenType == TK_RShift))
{
int token = sc_TokenType;
ExpData *right = ParseExpressionD (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = token == TK_LShift? EX_LShift : EX_RShift;
if (SC_CheckToken(TK_LShift))
{
data->Type = EX_LShift;
}
else if (SC_CheckToken(TK_RShift))
{
data->Type = EX_RShift;
}
else
{
delete data;
return tmp;
}
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionE (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
tmp = data;
return data; }
if (!sc_End) SC_UnGet();
return tmp;
} }
static ExpData *ParseExpressionD (const PClass *cls) static ExpData *ParseExpressionD (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionC (cls); ExpData *tmp = ParseExpressionC (cls);
while (SC_GetToken() && (sc_TokenType == '+' || sc_TokenType == '-'))
{
int token = sc_TokenType;
ExpData *right = ParseExpressionC (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = token == '+'? EX_Add : EX_Sub;
if (SC_CheckToken('+'))
{
data->Type = EX_Add;
}
else if (SC_CheckToken('-'))
{
data->Type = EX_Sub;
}
else
{
delete data;
return tmp;
}
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionD (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
tmp = data;
return data; }
if (!sc_End) SC_UnGet();
return tmp;
} }
static ExpData *ParseExpressionC (const PClass *cls) static ExpData *ParseExpressionC (const PClass *cls)
{ {
ExpData *tmp = ParseExpressionB (cls); ExpData *tmp = ParseExpressionB (cls);
while (SC_GetToken() && (sc_TokenType == '*' || sc_TokenType == '/' || sc_TokenType == '%'))
{
int token = sc_TokenType;
ExpData *right = ParseExpressionB (cls);
ExpData *data = new ExpData; ExpData *data = new ExpData;
data->Type = token == '*'? EX_Mul : sc_TokenType == '/'? EX_Div : EX_Mod;
if (SC_CheckToken('*'))
{
data->Type = EX_Mul;
}
else if (SC_CheckToken('/'))
{
data->Type = EX_Div;
}
else if (SC_CheckToken('%'))
{
data->Type = EX_Mod;
}
else
{
delete data;
return tmp;
}
data->Children[0] = tmp; data->Children[0] = tmp;
data->Children[1] = ParseExpressionC (cls); data->Children[1] = right;
data->EvalConst (cls); data->EvalConst (cls);
tmp = data;
return data; }
if (!sc_End) SC_UnGet();
return tmp;
} }
static ExpData *ParseExpressionB (const PClass *cls) static ExpData *ParseExpressionB (const PClass *cls)