public ComparisonExpression(ComparisonParamExpression param, ComparisonValueExpression value, string @operator) { Require.NotNull(param, "param"); Require.NotNull(value, "value"); Require.NotNullOrEmpty(@operator, "operator"); Param = param; Value = value; Operator = @operator; }
protected virtual void Visit(ComparisonParamExpression exp) { }
void IExpressionVisitor.Visit(ComparisonParamExpression exp) { Visit(exp); }
// comparison : identifier comparison_op param_value private Expression Comparison() { using (var lookahead = _tokenzier.BeginLookahead()) { var sourceLocation = _tokenzier.CurrentLocation; var paramName = _tokenzier.NextToken(); if (paramName == null) { return null; } if (paramName.Kind != TokenKind.Identifier) { _context.AddError("Expected identifier.", sourceLocation); return null; } sourceLocation = _tokenzier.CurrentLocation; var op = _tokenzier.NextToken(); if (op == null || (op.Kind != TokenKind.ComparisonOperator && op.Kind != TokenKind.Identifier) || !_context.RegisteredComparisonOperators.Contains(op.Value)) { _context.AddError("Missing comparison operator after the parameter name.", sourceLocation); return null; } sourceLocation = _tokenzier.CurrentLocation; var value = ComparisonValue(); if (value == null) { _context.AddError("Missing parameter value.", sourceLocation); return null; } lookahead.Accept(); var param = new ComparisonParamExpression(paramName.Value); return new ComparisonExpression(param, value, op.Value); } }