public override AstNode VisitDeclaratorlist([NotNull] GLSL_ES300Parser.DeclaratorlistContext context)
        {
            VariableDeclarationList declaratorList = new VariableDeclarationList();
            var currentContext = context;

            while (currentContext != null)
            {
                var dec = currentContext.declarator();
                if (dec != null)
                {
                    if (dec.fully_specified_type() != null)
                    {
                        declaratorList.Type = (TypeSpecifier)this.Visit(dec.fully_specified_type());
                    }

                    VariableDeclaration declaration = new VariableDeclaration();
                    if (dec.Identifier() != null)
                    {
                        declaration.Name = new Identifier()
                        {
                            Name = dec.Identifier().Symbol.Text
                        };

                        if (dec.LeftBracket() != null)
                        {
                            declaration.ArraySpecifier = new ArraySpecifier();
                            if (dec.constant_expression() != null)
                            {
                                declaration.ArraySpecifier.ArraySizeExpression = (Expression)this.Visit(dec.constant_expression());
                            }
                        }
                        if (dec.initializer() != null)
                        {
                            declaration.Initializer = (Expression)this.Visit(dec.initializer().assignment_expression());
                        }

                        declaratorList.Declarations.Add(declaration);
                    }

                    currentContext = null;
                }
                else
                {
                    VariableDeclaration declaration = new VariableDeclaration();
                    if (currentContext.Identifier() != null)
                    {
                        declaration.Name = new Identifier()
                        {
                            Name = currentContext.Identifier().Symbol.Text
                        };
                    }
                    if (currentContext.LeftBracket() != null)
                    {
                        declaration.ArraySpecifier = new ArraySpecifier();
                        if (currentContext.constant_expression() != null)
                        {
                            declaration.ArraySpecifier.ArraySizeExpression = (Expression)this.Visit(currentContext.constant_expression());
                        }
                    }
                    if (currentContext.initializer() != null)
                    {
                        declaration.Initializer = (Expression)this.Visit(currentContext.initializer().assignment_expression());
                    }

                    currentContext = currentContext.declaratorlist();
                    declaratorList.Declarations.Add(declaration);
                }
            }

            declaratorList.Declarations.Reverse();
            return(declaratorList);
        }
示例#2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="GLSL_ES300Parser.declaratorlist"/>.
 /// <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 VisitDeclaratorlist([NotNull] GLSL_ES300Parser.DeclaratorlistContext context)
 {
     return(VisitChildren(context));
 }