public FileType Parse(ZFileModel fileModel) { ContextFile fileContext = new ContextFile(this.projectContext, fileModel); List <Token> Tokens = Scan(fileContext, fileModel); FileSectionParser parser = new FileSectionParser(); FileMutilType fileMutilType = parser.Parse(Tokens, fileContext); FileType fileType = ParseSingleMutil(fileMutilType); fileType.FileModel = fileModel; fileType.ProjectContext = this.projectContext; return(fileType); }
private FileType ParseSingleMutil(FileMutilType fmt) { //int importCount = fmt.Importes.Count; //int useCount = fmt.Uses.Count; int propertyCount = fmt.Propertieses.Count; int procCount = fmt.Proces.Count; int enumCount = fmt.Enumes.Count; int dimCount = fmt.Dimes.Count; int classCount = fmt.Classes.Count; if (enumCount == 1 && dimCount == 0 && classCount == 0) { return(new FileEnum(fmt.FileContext, fmt.Enumes)); } else if (enumCount == 0 && dimCount == 1 && classCount == 0) { return(new FileDim(fmt.FileContext, fmt.Dimes[0], fmt.ImporteSection)); } else if (enumCount == 0 && classCount == 1) // (enumCount == 0 && dimCount == 0 && classCount == 1) { FileClass fsc = new FileClass(fmt.FileContext, fmt); //FileClass fsc = new FileClass() //{ // ClassSection = fmt.Classes[0], // ImporteSection = fmt.ImporteSection, // Proces = fmt.Proces, // UseSection = fmt.UseSection //}; //if (fmt.Dimes.Count > 0) //{ // fsc.DimSection = fmt.Dimes[0]; //} //if (fmt.Propertieses.Count > 0) //{ // fsc.PropertiesesSection = fmt.Propertieses[0]; //} return(fsc); } else if (enumCount == 0 && dimCount == 0 && classCount == 0) { return(null); } else { return(null); } }
public FileMutilType Parse(List <Token> tokens, ContextFile fileContext) { tape = new TokenTape(tokens, fileContext); fileMY = new FileMutilType(); fileMY.FileContext = fileContext; while (tape.CurrentKind != TokenKind.EOF) { TokenKind nkind = tape.Next.Kind; if (nkind == TokenKind.Colon && tape.CurrentKind == TokenKind.Ident) { SectionBase section = ParseSection(); if (section != null) { fileMY.AddSection(section); } } else if (tape.CurrentKind == TokenKind.NewLine) { SkipNewLine(); } else { SectionProc section = ParseProc(); if (section != null) { if (section.NamePart.IsConstructor()) { SectionConstructor constructor = new SectionConstructor(section); fileMY.AddSection(constructor); } else { fileMY.AddSection(section); } } } } return(fileMY); }