Exemplo n.º 1
0
        public Node VariableDeclaration()
        {
            var result = new VariableDeclaration();

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

            result.Add(identifierList);

            while (CurrentToken == TokenCategory.COMA)
            {
                Expect(TokenCategory.COMA);
                identifierList.Add(new Identifier()
                {
                    AnchorToken = Expect(TokenCategory.IDENTIFIER)
                });
            }

            Expect(TokenCategory.COLON);
            result.Add(Type());
            Expect(TokenCategory.SEMICOLON);

            return(result);
        }
Exemplo n.º 2
0
        public Node VariableDeclaration()
        {
            var result = new VariableDeclarationItems();

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

            while (CurrentToken == TokenCategory.COMMA)
            {
                Expect(TokenCategory.COMMA);

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

            var varFinal = new VariableDeclaration();

            if (CurrentToken != TokenCategory.LIST)
            {
                varFinal.Add(SimpleType());
            }

            else if (CurrentToken == TokenCategory.LIST)
            {
                varFinal.Add(ListType());
            }

            varFinal.Add(result);
            Expect(TokenCategory.SEMICOLON);

            return(varFinal);
        }