Beispiel #1
0
        public override Node VisitVarDecl(ML4DParser.VarDeclContext context)
        {
            VariableDCLNode varDeclNode;

            switch (context.type.type.Type)
            {
            case ML4DLexer.INT:
                varDeclNode = new VariableDCLNode("int", context.id.Text, (ExpressionNode)Visit(context.init));
                break;

            case ML4DLexer.DOUBLE:
                varDeclNode = new VariableDCLNode("double", context.id.Text, (ExpressionNode)Visit(context.init));
                break;

            case ML4DLexer.BOOL:
                varDeclNode = new VariableDCLNode("bool", context.id.Text, (ExpressionNode)Visit(context.init));
                break;

            default:
                throw new NotSupportedException(
                          $"The variable {context.id.Text}, was declared with an illegal type.");
            }
            return(varDeclNode);
        }
Beispiel #2
0
 /// <summary>
 /// Exit a parse tree produced by the <c>varDecl</c>
 /// labeled alternative in <see cref="ML4DParser.dcl"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitVarDecl([NotNull] ML4DParser.VarDeclContext context)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>varDecl</c>
 /// labeled alternative in <see cref="ML4DParser.dcl"/>.
 /// <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 VisitVarDecl([NotNull] ML4DParser.VarDeclContext context)
 {
     return(VisitChildren(context));
 }