Ejemplo n.º 1
0
        public override void EnterLocalVariableDeclaration([NotNull] NovaParser.LocalVariableDeclarationContext context)
        {
            VariableDeclaratorContext declarator = context.variableDeclarator();

            string type = context.typeType().GetChild(0).GetText();
            string name = declarator.variableDeclaratorId().GetText();

            DeclarationStatement statement = new DeclarationStatement(Parent, context);

            Variable variable = new Variable(name, type, context.variableDeclarator());

            ExpressionNode value = new ExpressionNode(statement);

            VariableInitializerContext initializer = declarator.variableInitializer();

            if (initializer != null)
            {
                ExpressionContext  expressionContext = initializer.expression();
                ExpressionListener listener          = new ExpressionListener(statement);

                expressionContext.EnterRule(listener);

                value = listener.GetResult();
            }

            statement.Variable = variable;
            statement.Value    = value;

            Result.Add(statement);
        }