Beispiel #1
0
        //private bool IsImportPackageNamePart(LexToken token)
        //{
        //    return token.IsKind(TokenKindKeyword.Ident)
        //        || token.IsKind(TokenKindSymbol.DIV)
        //        || token.IsKind(TokenKindSymbol.Comma);
        //}

        private SectionImportRaw.PackageRaw ParsePackageName(TokenTape tape)
        {
            SectionImportRaw.PackageRaw pname = new SectionImportRaw.PackageRaw();
            if (tape.HasCurrent)
            {
                if (tape.Current.IsKind(TokenKindKeyword.Ident))
                {
                    pname.Parts.Add((LexTokenText)tape.Current);
                    tape.MoveNext();
                    if (tape.HasCurrent)
                    {
                        if (tape.Current.IsKind(TokenKindSymbol.DIV))
                        {
                            ParsePackageNameBackPart(tape, pname);
                        }
                    }
                }
                else
                {
                    tape.error(string.Format("'{0}'不是正确的开发包名称", tape.Current.Text));
                    return(null);
                }
            }
            else
            {
                tape.error(string.Format("'{0}'没有开发包名称", tape.Current.Text));
                return(null);
            }
            return(pname);
        }
Beispiel #2
0
        public Exp Parse(List <LexToken> tokens, ContextExp expContext)
        {
            this.expContext = expContext;
            tape            = new TokenTape(tokens, expContext.FileContext);
            Exp exp = ParseAssign();

            //exp.SetContextExp(expContext,false);
            return(exp);
        }
Beispiel #3
0
        public List <SectionImportRaw.PackageRaw> Parse(IEnumerable <LexToken> tokens, ContextFile fileContext)
        {
            this.fileContext = fileContext;
            List <LexToken> tokens2 = new List <LexToken>(tokens);

            tape = new TokenTape(tokens2.ToArray(), fileContext);
            List <SectionImportRaw.PackageRaw> asts = ParsePackageList();

            return(asts);
        }
Beispiel #4
0
 private bool BuildCurrentLineTape()
 {
     if (tape.HasCurrent)
     {
         var currLineTokens = SegToken(tape.Current.ToList());
         currLineTokenTape = new TokenTape(currLineTokens, this.context.ClassContext.FileContext);
         return(true);
     }
     return(false);
 }
Beispiel #5
0
        public List <PropertyASTRaw> Parse(IEnumerable <LexToken> tokens, ContextFile fileContext)
        {
            this.fileContext = fileContext;
            List <LexToken> tokens2 = new List <LexToken>(tokens);

            tape = new TokenTape(tokens2, fileContext);
            List <PropertyASTRaw> asts = ParseDimList();

            return(asts);
        }
Beispiel #6
0
        public SectionProcRaw Parse(IEnumerable <LexToken> tokens, ContextFile fileContext, SectionProcRaw procAST)
        {
            this.fileContext = fileContext;
            this.ast         = procAST;

            List <LexToken> tokens2 = new List <LexToken>(tokens);

            tape         = new TokenTape(tokens2.ToArray(), fileContext);
            ast.NamePart = ParseProcName();
            tape.Match(TokenKindSymbol.Colon);
            ast.RetToken = ParseRetProc();

            return(ast);
        }
Beispiel #7
0
 private void ParsePackageNameBackPart(TokenTape tape, SectionImportRaw.PackageRaw pname)
 {
     while (tape.HasCurrent && tape.Current.IsKind(TokenKindSymbol.DIV))
     {
         tape.MoveNext();
         if (tape.Current.IsKind(TokenKindKeyword.Ident))
         {
             pname.Parts.Add((LexTokenText)tape.Current);
             tape.MoveNext();
         }
         else
         {
             tape.error(string.Format("'{0}'没有开发包名称", tape.Current.Text));
         }
     }
 }