示例#1
0
        /****************************************************************
         *                       Declaration Node
         ***************************************************************/

        public Node Declaration()
        {
            var declResult = new Declaration()
            {
                AnchorToken = Type()
            };

            var declId = new Identifier()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            };

            if (CurrentToken == TokenCategory.PARENTHESIS_OPEN)
            {
                declId.Add(ArrayDeclaration());
            }
            declResult.Add(declId);

            while (firstOfMultipleDeclarations.Contains(CurrentToken))
            {
                if (CurrentToken == TokenCategory.PARENTHESIS_OPEN)
                {
                    declId.Add(ArrayDeclaration());
                    declResult.Add(declId);
                }

                else if (CurrentToken == TokenCategory.COMMA)
                {
                    Expect(TokenCategory.COMMA);
                    declId = new Identifier()
                    {
                        AnchorToken = Expect(TokenCategory.IDENTIFIER)
                    };

                    if (CurrentToken != TokenCategory.PARENTHESIS_OPEN)
                    {
                        declResult.Add(declId);
                    }
                }
            }
            return(declResult);
        }
        public Node Declaration()
        {
            var result = new Declaration()
            {
                AnchorToken = Type()
            };

            result.Add(new Identifier()
            {
                AnchorToken = Expect(TokenCategory.IDENTIFIER)
            });
            return(result);
        }