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); } }
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)); } } }
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); }
public SectionUse(SectionUseRaw raw) { Raw = raw; }
public SectionUse(FileAST fileAST, SectionUseRaw raw) { ASTFile = fileAST; Raw = raw; }