Beispiel #1
0
        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);
        }
Beispiel #2
0
 /// <summary>
 /// Exit a parse tree produced by the <c>infixRelationalExpr</c>
 /// labeled alternative in <see cref="ML4DParser.bool_expr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitInfixRelationalExpr([NotNull] ML4DParser.InfixRelationalExprContext context)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>infixRelationalExpr</c>
 /// labeled alternative in <see cref="ML4DParser.bool_expr"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitInfixRelationalExpr([NotNull] ML4DParser.InfixRelationalExprContext context)
 {
     return(VisitChildren(context));
 }