private PackageNameAST ParsePackageName(TokenTape tape) { PackageNameAST pname = new PackageNameAST(); //TokenKind currentKind = tape.Current.Kind; while (IsPackageNamePart(tape.CurrentKind)) { //currentKind = tape.Current.Kind; if (tape.CurrentKind == TokenKind.Ident) { pname.Add(tape.Current); tape.MoveNext(); } else if (tape.CurrentKind == TokenKind.DIV) { tape.MoveNext(); } //else if (tape.CurrentKind == TokenKind.Semi) //{ // break; //} //else if (tape.CurrentKind == TokenKind.NewLine) //{ // break; //} //else //{ // tape.error(string.Format("'{0}'不是正确的开发包名称", tape.Current.GetText())); // tape.MoveNext(); //} } return(pname); }
public Exp Parse(List <Token> tokens, ContextFile fileContext) { tape = new TokenTape(tokens, fileContext); Exp exp = ParseAssign(); return(exp); }
private SectionDim.DimVarAST ParseDimVar(TokenTape tape) { SectionDim.DimVarAST dimv = new SectionDim.DimVarAST(); dimv.NameToken = tape.Current; tape.MoveNext(); tape.Match(TokenKind.Assign); dimv.TypeToken = tape.Current; tape.MoveNext(); return(dimv); }
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); }