예제 #1
0
파일: ASTBuilder.cs 프로젝트: Deaxz/ML4D
        public override Node VisitUnaryExpr(ML4DParser.UnaryExprContext context)
        {
            UnaryExpressionNode node;

            switch (context.op.Type)
            {
            case ML4DLexer.MINUS:
                node       = new UnaryMinusNode("-");
                node.Inner = (ExpressionNode)Visit(context.right);
                break;

            case ML4DLexer.NOT:
                node       = new NotNode("not");
                node.Inner = (ExpressionNode)Visit(context.inner);
                break;

            default:
                throw new NotSupportedException(
                          $"The operator {context.op.Text}, is not a valid unary operator.");
            }
            return(node);
        }
예제 #2
0
 /// <summary>
 /// Exit a parse tree produced by the <c>unaryExpr</c>
 /// labeled alternative in <see cref="ML4DParser.expr"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitUnaryExpr([NotNull] ML4DParser.UnaryExprContext context)
 {
 }
예제 #3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>unaryExpr</c>
 /// labeled alternative in <see cref="ML4DParser.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 VisitUnaryExpr([NotNull] ML4DParser.UnaryExprContext context)
 {
     return(VisitChildren(context));
 }