public List <SectionRaw> Parse(IEnumerable <LineTokenCollection> lineTokens, ContextFile fileContext) { this.fileContext = fileContext; Sections.Clear(); List <LineTokenCollection> tokens = new List <LineTokenCollection>(lineTokens); tape = new ArrayTape <LineTokenCollection>(tokens.ToArray()); while (tape.HasCurrent) { if (IsSectionHead(tape.Current)) { SectionRaw section = ParseSection(); if (section != null) { Sections.Add(section); } } else { if (tape.Current.Count > 0) { error(tape.Current.FirstToken, "错误的段头"); } tape.MoveNext(); } } return(Sections); }
public object[] ParseItems(IEnumerable <object> elements, ContextExp context, bool isAssignTo) { this.ExpContext = context; this.IsAssignTo = isAssignTo; Tape = new ArrayTape <object>(elements.ToArray()); chains.Clear(); featurer = new ChainItemFeaturer(context); while (Tape.HasCurrent) { bool b = ParseItem(); } return(chains.Reverse().ToArray()); }
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); }
public StmtRawParser(IEnumerable <LineTokenCollection> lineTokens, ContextProc context) { stmtList.Clear(); this.context = context; tape = new ArrayTape <LineTokenCollection>(lineTokens); }