private SectionUse ParseUse() { SectionUse ast = new SectionUse(); ast.KeyToken = tape.Current; tape.MoveNext(); tape.Match(TokenKind.Colon); while (tape.CurrentKind != TokenKind.NewLine && tape.CurrentKind != TokenKind.EOF) { if (tape.CurrentKind == TokenKind.Ident) { ast.AddTypeToken(tape.Current); tape.MoveNext(); } else if (tape.CurrentKind == TokenKind.Comma) { tape.MoveNext(); } else { tape.error(string.Format("使用的'{0}'不是正确的类型名称", tape.Current.GetText())); tape.MoveNext(); } } SkipNewLine(); return(ast); }
private SectionBase ParseSection() { string headText = tape.Current.GetText(); if (headText.StartsWith("导入")) { SectionImport section = ParseImport(); return(section); } else if (headText.StartsWith("使用")) { SectionUse section = ParseUse(); return(section); } else if (headText.StartsWith("约定")) { SectionEnum section = ParseEnum(); return(section); } else if (headText.StartsWith("声明")) { SectionDim section = ParseDim(); return(section); } else if (headText.EndsWith("类型")) { SectionClassName section = ParseClass(); return(section); } else if (headText.EndsWith("属性")) { SectionProperties section = ParseProperties(); return(section); } else { SectionProc section = ParseProc(); if (section.NamePart.IsConstructor()) { SectionConstructor constructor = new SectionConstructor(section); return(constructor); } else { return(section); } //tape.error("错误的段落"); //tape.MoveNext(); //return null; } }