Ejemplo n.º 1
0
        PackageAST parsePackage()
        {
            List <Token> tokens = new List <Token>();

            if (CurrentKind == TokenKind.Ident /*|| CurrentToken.IsAtomData()*/)
            {
                tokens.Add(CurrentToken);
                MoveNext();
                while (CurrentKind == TokenKind.DIV)
                {
                    MoveNext();
                    if (CurrentKind == TokenKind.Ident /*|| CurrentToken.IsAtomData()*/)
                    {
                        tokens.Add(CurrentToken);
                        MoveNext();
                    }
                    else
                    {
                        error("错误的开发包名称");
                    }
                }
            }
            else
            {
                error("错误的开发包名称");
                MoveNext();
            }
            PackageAST package = new PackageAST();

            package.PackageTokens = tokens;
            return(package);
        }
Ejemplo n.º 2
0
        List <PackageAST> parsePackageList()
        {
            List <PackageAST> list = new List <PackageAST>();

            if (CurrentKind == TokenKind.Ident)
            {
                PackageAST ast = parsePackage();
                if (ast != null)
                {
                    list.Add(ast);
                }
                while (CurrentKind == TokenKind.Comma)
                {
                    MoveNext();
                    if (CurrentKind == TokenKind.Ident)
                    {
                        PackageAST ast2 = parsePackage();
                        if (ast != null)
                        {
                            list.Add(ast2);
                        }
                    }
                    else
                    {
                        //error("错误的类型名称");
                        break;
                    }
                }
            }
            else
            {
                error("错误的开发包名称");
                MoveNext();
            }
            return(list);
        }