예제 #1
0
        private SectionRaw ParseSection()
        {
            string headText      = tape.Current.FirstToken.Text;
            bool   secondIsColon = tape.Current.SecondToken.IsKind(TokenKindSymbol.Colon);

            if (false)
            {
                //<<重新编写分析,同行换行都可以>>
            }
            else if (secondIsColon && headText == "导入包")
            {
                SectionImportRaw section = ParseImport();
                return(section);
            }
            else if (secondIsColon && headText == "导入类")
            {
                SectionUseRaw section = ParseUse();
                return(section);
            }
            //else if (secondIsColon && headText == "约定")
            //{
            //    SectionEnum section = ParseEnum();
            //    return section;
            //}
            else if (secondIsColon && headText == "名称")
            {
                SectionNameRaw section = ParseClassName();
                return(section);
            }
            else if (secondIsColon && headText == "属于")
            {
                SectionExtendsRaw section = ParseExtends();
                return(section);
            }
            //else if (secondIsColon && headText == "声明" )
            //{
            //    SectionDim section = ParseDim();
            //    return section;
            //}
            else if (secondIsColon && headText == "属性")
            {
                SectionPropertiesRaw section = ParseProperties();
                return(section);
            }
            else
            {
                SectionProcRaw section = ParseProc();
                return(section);
            }
        }
예제 #2
0
        private void ParseUseClass(SectionUseRaw ast, List <LexToken> sourceTokens)
        {
            ImportPackageRawParser packageParser = new ImportPackageRawParser();

            for (int i = 0; i < sourceTokens.Count; i++)
            {
                LexToken token = sourceTokens[i];
                if (token.IsKind(TokenKindKeyword.Ident))
                {
                    ast.Parts.Add((LexTokenText)token);
                }
                else if (token.IsKind(TokenKindSymbol.Comma))
                {
                }
                else
                {
                    error(token, string.Format("使用的'{0}'不是正确的类型名称", token.Text));
                }
            }
        }
예제 #3
0
        private SectionUseRaw ParseUse()
        {
            SectionUseRaw ast = new SectionUseRaw();

            ast.KeyToken = (LexTokenText)tape.Current.FirstToken;
            List <LexToken> tokens = tape.Current.GetSubs(2);

            ParseUseClass(ast, tokens);
            tape.MoveNext();
            while (tape.HasCurrent)
            {
                if (IsSectionHead(tape.Current))
                {
                    break;
                }
                List <LexToken> tokens2 = tape.Current.ToList();
                ParseUseClass(ast, tokens2);
                tape.MoveNext();
            }
            return(ast);
        }
예제 #4
0
 public SectionUse(SectionUseRaw raw)
 {
     Raw = raw;
 }
예제 #5
0
 public SectionUse(FileAST fileAST, SectionUseRaw raw)
 {
     ASTFile = fileAST;
     Raw     = raw;
 }