public FileAST Parse(SourceFileModel fileModel) { ContextFile fileContext = new ContextFile(this.projectContext, fileModel); List <LineTokenCollection> Tokens = Scan(fileContext, fileModel); //foreach (LineTokenCollection ltc in Tokens) //{ // Console.WriteLine(ltc); // foreach(LexToken tok in ltc.ToList()) // { // Console.Write(tok.Text+" "); // } // Console.WriteLine(); //} FileRawParser parser = new FileRawParser(); FileRaw fileRaw = parser.Parse(Tokens, fileContext); //FileMutilTypeRaw FileASTParser fileASTParser = new FileASTParser(); FileAST fileAST = fileASTParser.Parse(fileRaw, fileContext); //FileSource fileType = ParseSingleMutil(fileMutilType); //if (fileType != null) //{ // fileType.FileModel = fileModel; // fileType.ProjectContext = this.projectContext; //} //return fileType; return(fileAST); }
public FileRaw Parse(IEnumerable <LineTokenCollection> lineTokens, ContextFile fileContext) { SectionParser sectionParser = new SectionParser(); List <LineTokenCollection> tempLineTokens = new List <LineTokenCollection>(); foreach (var item in lineTokens) { if (item.Count > 0) { tempLineTokens.Add(item); } } Sections = sectionParser.Parse(tempLineTokens, fileContext); fileRaw = new FileRaw(); fileRaw.Sections = Sections; return(fileRaw); }
public FileAST Parse(FileRaw fileRaw, ContextFile fileContext) { fileAST = new FileAST(fileContext); tape = new ArrayTape <SectionRaw>(fileRaw.Sections); while (tape.HasCurrent) { SectionRaw section = tape.Current; if (section is SectionImportRaw) { fileAST.ImportSection = new SectionImport(fileAST, section as SectionImportRaw); tape.MoveNext(); } else if (section is SectionUseRaw) { //fileAST.UseSection = (section as SectionUse); //fileAST.UseSection.FileContext = fileAST.FileContext; //tape.MoveNext(); fileAST.UseSection = new SectionUse(fileAST, section as SectionUseRaw); //fileAST.ImporteSection.FileContext = fileAST.FileContext; tape.MoveNext(); } //else if (section is SectionNameRaw) //{ // ParseType(); //} else if ((section is SectionExtendsRaw) || (section is SectionPropertiesRaw) || (section is SectionProcRaw) || section is SectionNameRaw) { //ParseTypeSection(); var tempTypeBody = ParseTempTypeBody(); TypeAST tast = tempTypeBody.Parse(); fileAST.AddTypeAST(tast); } else { throw new CCException(); } } return(fileAST); }