public void Visit(EqualityNode node) { var right = Nodes.Pop(); var left = Nodes.Pop(); Nodes.Push(new EqualityNode(left, right)); }
public override bool Visit(EqualityNode node) { int nodeLeft = 0; int nodeRight = 0; if (node.Left is NumberNode) { nodeLeft = Visit(node.Left as NumberNode); } else if (node.Left is IdentifierNode) { nodeLeft = Visit(node.Left as IdentifierNode); } else { nodeLeft = Visit(node.Left as InfixExpressionNode); } if (node.Right is NumberNode) { nodeRight = Visit(node.Right as NumberNode); } else if (node.Right is IdentifierNode) { nodeRight = Visit(node.Right as IdentifierNode); } else { nodeRight = Visit(node.Right as InfixExpressionNode); } return(nodeLeft == nodeRight); }
public void Visit(EqualityNode equality) { equality.Left.Parent = equality; equality.Right.Parent = equality; equality.Left.Accept(this); equality.Right.Accept(this); }
private RdlSyntaxNode ComposeEqualityOperators() { var node = ComposeArithmeticOperators(Precendence.Level1); while (IsEqualityOperator(Current)) { switch (Current.TokenType) { case StatementType.GreaterEqual: Consume(StatementType.GreaterEqual); node = new GreaterEqualNode(node, ComposeEqualityOperators()); break; case StatementType.Greater: Consume(StatementType.Greater); node = new GreaterNode(node, ComposeEqualityOperators()); break; case StatementType.LessEqual: Consume(StatementType.LessEqual); node = new LessEqualNode(node, ComposeEqualityOperators()); break; case StatementType.Less: Consume(StatementType.Less); node = new LessNode(node, ComposeEqualityOperators()); break; case StatementType.Equality: Consume(StatementType.Equality); node = new EqualityNode(node, ComposeEqualityOperators()); break; case StatementType.Diff: Consume(StatementType.Diff); node = new DiffNode(node, ComposeEqualityOperators()); break; case StatementType.Between: node = new BetweenNode(ConsumeAndGetToken(), node, ComposeAndSkip(f => f.ComposeArithmeticOperators(Precendence.Level1), StatementType.And), ComposeArithmeticOperators(Precendence.Level1)); break; case StatementType.Not: Consume(StatementType.Not); node = new NotNode(Current, node); break; default: throw new NotSupportedException(); } } return(node); }
public DomainId <IEqualityNode> CreateEqualityOperation( string definition, DomainId <IAstNode> leftExpression, DomainId <IAstNode> rightExpression) { var equalityNode = new EqualityNode( m_ids.Next, definition, leftExpression, rightExpression); return(DomainItemRegistration <IEqualityNode>(equalityNode)); }
public void Visit(InNode node) { var right = (ArgsListNode)Nodes.Pop(); var left = Nodes.Pop(); Node exp = new EqualityNode(left, right.Args[0]); for (var i = 1; i < right.Args.Length; i++) { exp = new OrNode(exp, new EqualityNode(left, right.Args[i])); } Nodes.Push(exp); }
private Node ParseEquality() { var lNode = this.ParseRelational(); while (this.AreMoreTokens) { if (this.currentToken.Equals(TokenType.Symbol, "==")) { this.ReadNextToken(); lNode = new EqualityNode(lNode, this.ParseRelational()); } else if (this.currentToken.Equals(TokenType.Symbol, "!=")) { this.ReadNextToken(); lNode = new InequalityNode(lNode, this.ParseRelational()); } else { break; } } return(lNode); }
public void Visit(EqualityNode node) { node.Left.Accept(this); node.Right.Accept(this); node.Accept(_visitor); }
public void Visit(EqualityNode node) { }
/// <summary> /// Evaluate and availability expression. /// </summary> /// <param name="availabilityExpression">The expression to evaluate.</param> /// <param name="variables">The variables passed into the <see cref="IConversationSystem"/>.</param> /// <returns>True if the expression evaluates positively, false otherwise.</returns> public bool Evaluate(string availabilityExpression, Dictionary <string, string> variables) { var tokens = _lexer.Tokenize(availabilityExpression) .Where(x => x.Type != "(end)") .Where(x => x.Type != TOKEN_WHITESPACE) .ToArray(); var nodeStack = new Stack <AbstractNode>(); foreach (var token in tokens) { switch (token.Type) { case TOKEN_VALUE: if (!nodeStack.Any() || !(nodeStack.Peek() is EqualityNode)) { throw new ExpressionParseException(string.Format( "Value at {0} without preceding equality operator.", token.Position.Index)); } // trim quotes token.Value = token.Value.Substring(1, token.Value.Length - 2); nodeStack.Peek().Right = new ValueNode(token); LinkExpressions(nodeStack); break; case TOKEN_VARIABLE: if (nodeStack.Any() && nodeStack.Peek() is EqualityNode) { nodeStack.Peek().Right = new VariableNode(token); LinkExpressions(nodeStack); } else { nodeStack.Push(new VariableNode(token)); } break; case TOKEN_EQUALITY: if (!nodeStack.Any() || !(nodeStack.Peek() is VariableNode)) { throw new ExpressionParseException(string.Format( "Equality operator at {0} without preceding variable.", token.Position.Index)); } var eqNode = new EqualityNode(token); eqNode.Left = nodeStack.Pop(); nodeStack.Push(eqNode); break; case TOKEN_AND: if (!nodeStack.Any() || !(nodeStack.Peek() is ExpressionNode)) { throw new ExpressionParseException(string.Format( "AND operator at {0} without preceding expression.", token.Position.Index)); } var andNode = new AndNode(token); andNode.Left = nodeStack.Pop(); nodeStack.Push(andNode); break; case TOKEN_OR: if (!nodeStack.Any() || !(nodeStack.Peek() is ExpressionNode)) { throw new ExpressionParseException(string.Format( "OR operator at {0} without preceding expression.", token.Position.Index)); } var orNode = new OrNode(token); orNode.Left = nodeStack.Pop(); nodeStack.Push(orNode); break; case TOKEN_NOT: if (nodeStack.Any() && !(nodeStack.Peek() is ExpressionNode)) { throw new ExpressionParseException(string.Format( "NOT operator at {0} with preceding token that isn't an expression.", token.Position.Index)); } var notNode = new NotNode(token); if (nodeStack.Any()) { nodeStack.Peek().Right = notNode; } nodeStack.Push(notNode); break; } } return(!nodeStack.Any() || nodeStack.Peek().Evaluate(variables)); }
public override void Visit(EqualityNode node) { ReportReturnTypesAreNotSame(node, "Equality"); }
public override void Visit(EqualityNode node) => ProduceDebuggerInstructions(node, n => base.Visit(n));
/// <summary> /// Visit Equality node. /// </summary> /// <param name="node">Equality node of AST</param> public abstract void Visit(EqualityNode node);
/// <summary> /// Performs "Equality" specific operations. /// </summary> /// <param name="node">The "Equality" node.</param> public virtual void Visit(EqualityNode node) { ExpressionGenerateInstructions <EqualityNumeric>(); }
public abstract U Visit(EqualityNode node);