|
@@ -686,12 +686,13 @@ namespace NTERA.Engine.Compiler
|
|
|
|
|
|
private static readonly Dictionary<Token, int> OrderOfOps = new Dictionary<Token, int>
|
|
|
{
|
|
|
- { Token.Or, 0 }, { Token.And, 0 }, { Token.Not, 0 },
|
|
|
+ { Token.Or, 0 }, { Token.And, 0 },
|
|
|
{ Token.Equal, 1 }, { Token.NotEqual, 1 },
|
|
|
{ Token.Less, 1 }, { Token.More, 1 }, { Token.LessEqual, 1 }, { Token.MoreEqual, 1 },
|
|
|
{ Token.Plus, 2 }, { Token.Minus, 2 },
|
|
|
{ Token.Asterisk, 3 }, { Token.Slash, 3 }, { Token.Modulo, 3 },
|
|
|
- { Token.Caret, 4 }, { Token.ShiftLeft, 4 }, { Token.ShiftRight, 4 }
|
|
|
+ { Token.Caret, 4 }, { Token.ShiftLeft, 4 }, { Token.ShiftRight, 4 },
|
|
|
+ { Token.Not, 5 },
|
|
|
};
|
|
|
|
|
|
protected ExecutionNode Expression(out ParserError error, bool useModulo = true, bool ternaryString = false)
|
|
@@ -707,7 +708,7 @@ namespace NTERA.Engine.Compiler
|
|
|
|
|
|
Token op = operators.Pop();
|
|
|
|
|
|
- if (op.IsUnary() && operands.Count == 1)
|
|
|
+ if (op.IsUnary() && operands.Count >= 1)
|
|
|
{
|
|
|
var operand = operands.Pop();
|
|
|
|
|
@@ -725,7 +726,7 @@ namespace NTERA.Engine.Compiler
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- else if (operands.Count >= 2)
|
|
|
+ else if (!op.IsUnary() && operands.Count >= 2)
|
|
|
{
|
|
|
ExecutionNode right = operands.Pop();
|
|
|
ExecutionNode left = operands.Pop();
|
|
@@ -790,15 +791,15 @@ namespace NTERA.Engine.Compiler
|
|
|
}
|
|
|
else if (token == Token.Identifer)
|
|
|
{
|
|
|
- if (FunctionDefinitions.Any(x => x.Name == Lexer.Identifier))
|
|
|
+ if (IsVariable(Lexer.Identifier))
|
|
|
{
|
|
|
- operands.Push(GetFunction(out error));
|
|
|
+ operands.Push(GetVariable(out error));
|
|
|
if (error != null)
|
|
|
return null;
|
|
|
}
|
|
|
- else if (IsVariable(Lexer.Identifier))
|
|
|
+ else if (FunctionDefinitions.Any(x => x.Name == Lexer.Identifier))
|
|
|
{
|
|
|
- operands.Push(GetVariable(out error));
|
|
|
+ operands.Push(GetFunction(out error));
|
|
|
if (error != null)
|
|
|
return null;
|
|
|
}
|