public void FirstTestName() { var route = new RouteNode <Uri>(new StubRoute <Uri>()); var joinNode = new JoinNode <Uri>(_id++, new ConstantNode <Uri>()); joinNode.Add(route); var alpha = new AlphaNode <Uri>(_id++); alpha.Add(joinNode); var equal = new EqualNode <Uri>(() => _id++); equal.Add("version", alpha); var segment = new SegmentNode <Uri>(1); segment.Add(equal); var engine = new MagnumRoutingEngine <Uri>(x => x); engine.Match <RootNode <Uri> >().Single().Add(segment); bool called = false; var uri = new Uri("http://localhost/version"); engine.Route(uri, x => { called = true; }); called.ShouldBeTrue(); }
public EqualNode Equal() { EqualNode equalNode = new EqualNode(); Match(TokenType.EQUAL); return(equalNode); }
public void FirstTestName() { var route = new RouteNode<Uri>(new StubRoute<Uri>()); var joinNode = new JoinNode<Uri>(_id++, new ConstantNode<Uri>()); joinNode.Add(route); var alpha = new AlphaNode<Uri>(_id++); alpha.Add(joinNode); var equal = new EqualNode<Uri>(() => _id++); equal.Add("version", alpha); var segment = new SegmentNode<Uri>(1); segment.Add(equal); var engine = new MagnumRoutingEngine<Uri>(x => x); engine.Match<RootNode<Uri>>().Single().Add(segment); bool called = false; var uri = new Uri("http://localhost/version"); engine.Route(uri, x => { called = true; }); called.ShouldBeTrue(); }
protected virtual QueryNode VisitEqual(EqualNode node, ElasticSearchQueryOptimizerState state) { state.Boost = 1f; var node2 = Visit(node.LeftNode, state); return(new EqualNode(node2, Visit(node.RightNode, state), state.Boost)); }
public static EqualNode <T, TProperty> Equal <T, TProperty>(this RuntimeConfigurator configurator) where T : class { EqualNode <T, TProperty> node = configurator.CreateNode(id => new EqualNode <T, TProperty>(id, configurator)); return(node); }
public override bool Visit <T, TProperty>(EqualNode <T, TProperty> node, Func <RuntimeVisitor, bool> next) { Append("EqualNode[{0}] ({1})", Tokens <T>(), typeof(TProperty).GetShortName()); return(Indent(next)); }
// TODO: ProcessAsVirtualField? Both Solr and Lucene do this // TODO: null value check (change to !ExistsQuery/MissingQuery then?) protected QueryBase VisitEqual(EqualNode node, ElasticQueryMapperState state) { // TODO: Move these 3 lines to separate method for reuse? var fieldName = GetFormattedFieldName(node); var valueNode = node.GetValueNode <string>(); var value = ValueFormatter.FormatValueForIndexStorage(valueNode.Value, fieldName); // TODO: Maybe use Term if keyword field, otherwise MatchPhrase? // TODO: Match/MatchPhrase? /* Like the match query, the match_phrase query first analyzes the query string to produce a list of terms. * It then searches for all the terms, but keeps only documents that contain all of the search terms, * in the same positions relative to each other. */ // TODO: Term query /* the term query looks in the inverted index for the exact term only; it won’t match any variants */ return(new TermQuery { Field = fieldName, Value = value, Boost = node.Boost }); }
public override ASTNode VisitComparisson([NotNull] CoolParser.ComparissonContext context) { ComparisonOperation operators; switch (context.op.Text) { case "<=": operators = new LessEqual(context); break; case "<": operators = new Less(context); break; case "=": operators = new EqualNode(context); break; default: throw new NotSupportedException(); } operators.LeftOperand = Visit(context.expression(0)) as ExpressionNode; // LEFT EXPRESSION operators.RightOperand = Visit(context.expression(1)) as ExpressionNode; //RIGHT EXPRESSION return(operators); }
public void Init() { _testExpression = Expression.Equal(TestLeftExpression, TestRightExpression); TestObject = new EqualNode( MockNodeFactory.Object, TestExpression); }
protected virtual string HandleEqual(EqualNode node) { var fieldNode = QueryHelper.GetFieldNode(node); var valueNode = QueryHelper.GetValueNode <string>(node); var result = string.Format("[field[@name='{0}'] = '{1}']", fieldNode.FieldKey, valueNode.Value); return(result); }
public void Visit(EqualNode node) { Visit(node as BinaryNode); if (object_return_type) { Code.Add(new AssignStrToVarCodeLine(return_type, "Bool")); } }
public void Visit(EqualNode node) { BinaryOperationVisit(node); if (special_object_return_type) { SetReturnType("Bool"); } }
public override bool Visit <T, TProperty>(EqualNode <T, TProperty> node, Func <RuntimeVisitor, bool> next) { // _current = _vertices.Get(node.Id, id => new Vertex(typeof (EqualNode<,>), typeof (TProperty), "==")); // // if (_stack.Count > 0) // _edges.Add(new Edge(_stack.Peek(), _current, _current.TargetType.Name)); return(Next(() => base.Visit(node, next))); }
public void EqualExpressionHasExpectedRight() { IExpressionNode actual = TestObject.Build(TestEqualExpression); EqualNode actualNode = actual.VerifyIsActually <EqualNode>(); ConstantNode rightNode = actualNode.Right.VerifyIsActually <ConstantNode>(); Assert.AreSame(TestConstantOne, rightNode.SourceExpression); }
public void EqualExpressionHasExpectedLeft() { IExpressionNode actual = TestObject.Build(TestEqualExpression); EqualNode actualNode = actual.VerifyIsActually <EqualNode>(); ConstantNode leftNode = actualNode.Left.VerifyIsActually <ConstantNode>(); Assert.AreSame(TestConstantZero, leftNode.SourceExpression); }
public void EqualExpressionIsExpected() { Expression testExpression = TestEqualExpression; IExpressionNode actual = TestObject.Build(testExpression); EqualNode actualNode = actual.VerifyIsActually <EqualNode>(); Assert.AreSame(testExpression, actualNode.SourceExpression); }
public override string GenCode() { var tmp2 = new EqualNode(left, right); tmp2.linenumber = linenumber; Node tmp = new LogicNotNode(tmp2); tmp.linenumber = linenumber; tmp.GenCode(); return(null); }
public RoutingEngineRoutingRunner() { _idGenerator = new SequentialNodeIdGenerator(); _engine = new MagnumRoutingEngine <Uri>(x => x); _segment = new SegmentNode <Uri>(1); _engine.Match <RootNode <Uri> >().Single().Add(_segment); _equal = new EqualNode <Uri>(() => _id++); _segment.Add(_equal); }
public RoutingEngineRoutingRunner() { _idGenerator = new SequentialNodeIdGenerator(); _engine = new MagnumRoutingEngine<Uri>(x => x); _segment = new SegmentNode<Uri>(1); _engine.Match<RootNode<Uri>>().Single().Add(_segment); _equal = new EqualNode<Uri>(() => _id++); _segment.Add(_equal); }
public void Given_an_existing_segment_condition() { _engine = new MagnumRoutingEngine<Uri>(x => x); var segmentNode = new SegmentNode<Uri>(1); var equals = new EqualNode<Uri>(() => _id++); equals.Add("version", new AlphaNode<Uri>(_id++)); segmentNode.Add(equals); _engine.Add(segmentNode); }
public override bool Visit <TT, TTProperty>(EqualNode <TT, TTProperty> node, Func <RuntimeVisitor, bool> next) { var locator = this as NotEqualNodeSelector <TT, TTProperty>; if (locator != null) { locator._node = node; return(false); } return(base.Visit(node, next)); }
public void Given_an_existing_segment_condition() { _engine = new MagnumRoutingEngine <Uri>(x => x); var segmentNode = new SegmentNode <Uri>(1); var equals = new EqualNode <Uri>(() => _id++); equals.Add("version", new AlphaNode <Uri>(_id++)); segmentNode.Add(equals); _engine.Add(segmentNode); }
protected virtual BaseQuery HandleEqual(EqualNode node, ElasticSearchQueryMapperState state) { BaseQuery query; var fieldNode = node.GetFieldNode(); var valueNode = QueryHelper.GetValueNode <object>(node); if (ProcessAsVirtualField(fieldNode, valueNode, node.Boost, ComparisonType.Equal, state, out query)) { return(query); } return(HandleEqual(fieldNode.FieldKey, valueNode.Value, node.Boost)); }
public void Visit(EqualNode node) { node.LeftOperand.Accept(this); node.RightOperand.Accept(this); if (node.LeftOperand.StaticType.Text != node.RightOperand.StaticType.Text || !(new string[3] { "Bool", "Int", "String" }.Contains(node.LeftOperand.StaticType.Text))) { errors.Add(SemanticError.InvalidUseOfOperator(node, node.LeftOperand.StaticType, node.RightOperand.StaticType)); } if (!scope.IsDefinedType("Bool", out node.StaticType)) { errors.Add(SemanticError.NotDeclaredType(new TypeNode(node.Line, node.Column, "Bool"))); } }
public override ASTNode VisitComparisson([NotNull] CoolParser.ComparissonContext context) { BinaryOperatorNode coNode = null; if (context.op.Text == "<") { coNode = new LessNode(context.Start.Line, context.Start.Column); } if (context.op.Text == "=") { coNode = new EqualNode(context.Start.Line, context.Start.Column); } if (context.op.Text == "<=") { coNode = new LessEqualNode(context.Start.Line, context.Start.Column); } coNode.LeftOperand = Visit(context.expr(0)) as ExpressionNode; coNode.RightOperand = Visit(context.expr(1)) as ExpressionNode; return(coNode); }
public override Node VisitInfixRelationalExpr(ML4DParser.InfixRelationalExprContext context) { InfixExpressionNode node; switch (context.op.Type) { case ML4DLexer.LTHAN: node = new LessThanNode(context.op.Text); break; case ML4DLexer.GTHAN: node = new GreaterThanNode(context.op.Text); break; case ML4DLexer.LETHAN: node = new LessEqualThanNode(context.op.Text); break; case ML4DLexer.GETHAN: node = new GreaterEqualThanNode(context.op.Text); break; case ML4DLexer.EQUALS: node = new EqualNode(context.op.Text); break; case ML4DLexer.NOTEQUALS: node = new NotEqualNode(context.op.Text); break; default: throw new NotSupportedException( $"The operator {context.op.Text}, is not a valid relational operator."); } node.Left = (ExpressionNode)Visit(context.left); node.Right = (ExpressionNode)Visit(context.right); return(node); }
public void ValidOperandsToOrOperation() { OrNode node = new OrNode("Or"); EqualNode fourplus6equal10 = new EqualNode("="); InfixExpressionNode addNode = new AdditionNode("+"); addNode.Left = new IntNode(4); addNode.Right = new IntNode(6); fourplus6equal10.Left = addNode; fourplus6equal10.Right = new IntNode(10); node.Left = fourplus6equal10; node.Right = new BoolNode(false); SymbolTable symbolTable = new SymbolTable(); TypeCheckSymbolTableVisitor visitor = new TypeCheckSymbolTableVisitor(symbolTable); visitor.Visit(node); Assert.AreEqual(node.Type, "bool"); }
public void Select <TNode>(Node <TNode> node) where TNode : class { _node = null; node.Accept(this); if (_node == null) { EqualNode <T, TProperty> equalNode = _configurator.Equal <T, TProperty>(); var parentNode = node as Node <Token <T, TProperty> >; if (parentNode == null) { throw new ArgumentException("Expected " + typeof(T).Tokens() + ", but was " + typeof(TNode).Tokens()); } parentNode.AddActivation(equalNode); _node = equalNode; } _next.Select(_node[_value]); }
private ExpressionNode ParseEquality() { var lhs = ParseRel(); while (true) { if (_reader.Peek() is Equal) { Match <Equal>(); lhs = new EqualNode(lhs, ParseRel()); } else if (_reader.Peek() is NotEqual) { Match <NotEqual>(); lhs = new NotEqualNode(lhs, ParseRel()); } else { break; } } return(lhs); }
public override ASTN VisitComparer([NotNull] ComparerContext context) { ExprNode left = VisitExpr(context.left) as ExprNode; ExprNode right = VisitExpr(context.right) as ExprNode; ComparerNode node; switch (context.op.Type) { case EQU: node = new EqualNode(context); break; case LOW: node = new LowerNode(context); break; default: node = new LowerOrEqualNode(context); break; } node.Leftexpr = left; node.Rigthexpr = right; return(node); }
public virtual void VisitEqual(EqualNode equalNode) => throw new NotImplementedException();
protected virtual QueryNode VisitEqual(EqualNode node, AzureQueryOptimizerState state) { return((QueryNode) new EqualNode(this.Visit(node.LeftNode, state), this.Visit(node.RightNode, state), state.Boost)); }
private void processTokenToExpression(LogicalExpressionNode current, Token token) { if (LETokenType.Literal == token.Type) { current.Children.Add(new LiteralNode {Literal = token.Value, Negative = token.Negation}); return; } if (LETokenType.Number == token.Type) { current.Children.Add(new LiteralNode { Literal = token.Value, IsNumber=true, Negative = token.Negation }); return; } if (LETokenType.And == token.Type || LETokenType.Block == token.Type) { var conj = new ConjunctionNode {Negative = token.Negation}; current.Children.Add(conj); foreach (var child in token.Children) { processTokenToExpression(conj, child); } return; } if (LETokenType.Or == token.Type) { var disj = new DisjunctionNode {Negative = token.Negation}; current.Children.Add(disj); foreach (var child in token.Children) { processTokenToExpression(disj, child); } return; } if (0!=(token.Type & LETokenType.Compare)) { var fst = token.Children[0]; var sec = token.Children[1]; LogicalExpressionNode n; if (token.Type == LETokenType.Regex) { n = new RegexTestNode { First = fst.Value, Second = sec.Value, FirstIsLiteral = fst.Type == LETokenType.Literal, SecondIsLiteral = sec.Type == LETokenType.Literal }; }else if (fst.Type == LETokenType.Number) { var eq = new EqualValueNode(); n = eq; eq.Literal = sec.Value; eq.Value = fst.Value; eq.IsNumber = true; } else if (sec.Type == LETokenType.Number) { var eq = new EqualValueNode(); n = eq; eq.Literal = fst.Value; eq.Value = sec.Value; eq.IsNumber = true; } else if (sec.Type == LETokenType.Literal) { var eq = new EqualNode(); n = eq; if (fst.Type == LETokenType.String) { var eq2= new EqualValueNode(); eq2.Literal = sec.Value; eq2.Value = fst.Value; n = eq2; } else { eq.FirstLiteral = fst.Value; eq.SecondLiteral = sec.Value; } } else { var eq = new EqualValueNode(); n = eq; eq.Literal = fst.Value; eq.Value = sec.Value; } n.Negative = token.Negation; n.Operation = token.Type; if (token.Type != LETokenType.Neq && token.Type != LETokenType.Eq) { n.IsNumber = true; } if (LETokenType.Neq == token.Type) { n.Negative = !n.Negative; } current.Children.Add(n); } }
/// <summary> /// This method prints the equalNode /// </summary> /// <param name="equalNode">The node to print.</param> /// <returns>Returns null</returns> public override object Visit(EqualNode equalNode) { Print("EqualNode"); return(null); }