public bool Compare(Token op, TokenValue right, out string error) { switch (op.TokenType) { case TokenType.CompEq: return(Equal(right.Value, out error)); case TokenType.CompGt: return(Greater(right.Value, out error)); case TokenType.CompGe: return(Greater(right.Value, out error) || Equal(right.Value, out error)); case TokenType.CompLt: return(!Equal(right.Value, out error) && !Greater(right.Value, out error)); case TokenType.CompLe: return(!Greater(right.Value, out error)); case TokenType.CompNe: return(!Equal(right.Value, out error)); default: error = $@"Invalid compare operator ""{op.Text}"""; return(false); } }
public static TokenValue Load(Token left, IDictionary <string, EntityProperty> data) { if (!left.IsData()) { return(null); } if (left.TokenType == TokenType.GuidLiteral) { return(TokenValue.FromGuid(left.Text)); } if (left.TokenType == TokenType.DateTimeLiteral) { return(TokenValue.FromDateTime(left.Text)); } if (left.TokenType == TokenType.DoubleLiteral) { return(TokenValue.FromDouble(left.Text)); } if (left.TokenType == TokenType.IntLiteral) { return(TokenValue.FromInt(left.Text)); } if (left.TokenType == TokenType.LongLiteral) { return(TokenValue.FromLong(left.Text)); } if (left.TokenType == TokenType.StringLiteral) { return(TokenValue.FromString(left.Text)); } if (data.TryGetValue(left.Text, out EntityProperty value)) { return(new TokenValue(value)); } return(new TokenValue()); }