private List <PropertyASTRaw> ParseDimList() { List <PropertyASTRaw> list = new List <PropertyASTRaw>(); while (tape.HasCurrent && !tape.Current.IsKind(TokenKindSymbol.EOF)) { if (tape.Current.IsKind(TokenKindKeyword.Ident)) { var pname = ParseProperty(); if (pname != null) { list.Add(pname); } } else if (tape.Current.IsKind(TokenKindSymbol.Comma)) { tape.MoveNext(); } else { tape.error(string.Format("'{0}'不是正确的属性", tape.Current.Text)); tape.MoveNext(); } } return(list); }
//private bool IsImportPackageNamePart(LexToken token) //{ // return token.IsKind(TokenKindKeyword.Ident) // || token.IsKind(TokenKindSymbol.DIV) // || token.IsKind(TokenKindSymbol.Comma); //} private SectionImportRaw.PackageRaw ParsePackageName(TokenTape tape) { SectionImportRaw.PackageRaw pname = new SectionImportRaw.PackageRaw(); if (tape.HasCurrent) { if (tape.Current.IsKind(TokenKindKeyword.Ident)) { pname.Parts.Add((LexTokenText)tape.Current); tape.MoveNext(); if (tape.HasCurrent) { if (tape.Current.IsKind(TokenKindSymbol.DIV)) { ParsePackageNameBackPart(tape, pname); } } } else { tape.error(string.Format("'{0}'不是正确的开发包名称", tape.Current.Text)); return(null); } } else { tape.error(string.Format("'{0}'没有开发包名称", tape.Current.Text)); return(null); } return(pname); }
private void ParsePackageNameBackPart(TokenTape tape, SectionImportRaw.PackageRaw pname) { while (tape.HasCurrent && tape.Current.IsKind(TokenKindSymbol.DIV)) { tape.MoveNext(); if (tape.Current.IsKind(TokenKindKeyword.Ident)) { pname.Parts.Add((LexTokenText)tape.Current); tape.MoveNext(); } else { tape.error(string.Format("'{0}'没有开发包名称", tape.Current.Text)); } } }
private List <SectionImportRaw.PackageRaw> ParsePackageList() { List <SectionImportRaw.PackageRaw> list = new List <SectionImportRaw.PackageRaw>(); while (tape.HasCurrent && !tape.Current.IsKind(TokenKindSymbol.EOF)) { if (tape.Current.IsKind(TokenKindKeyword.Ident)) { SectionImportRaw.PackageRaw pname = ParsePackageName(tape); if (pname != null) { list.Add(pname); } } else if (tape.Current.IsKind(TokenKindSymbol.Comma)) { tape.MoveNext(); } else { tape.error(string.Format("'{0}'不是正确的导入名称", tape.Current.Text)); tape.MoveNext(); } //else if (tape.CurrentKind == TokenKind.NewLine) //{ // SkipNewLine(); //} //else //{ // tape.error(string.Format("'{0}'不是正确的导入名称", tape.Current.GetText())); // tape.MoveNext(); //} } //if (tape.CurrentKind == TokenKindSymbol.Semi) //{ // tape.MoveNext(); //} //SkipNewLine(); //tape.Match(TokenKind.Semi); return(list); }
private LexTokenText ParseRetProc() { if (tape.HasCurrent && tape.Current.IsKind(TokenKindKeyword.Ident)) { LexTokenText headToken = (LexTokenText)tape.Current; tape.MoveNext(); //if (tape.CurrentKind == TokenKindSymbol.NewLine) //{ // SkipNewLine(); //} return(headToken); } return(null); }
private StmtRaw ParseWhile() { StmtWhileRaw whileStmt = new StmtWhileRaw(); whileStmt.DangToken = (LexTokenText)(currLineTokenTape.Current); currLineTokenTape.MoveNext(); whileStmt.ConditionExp = ParseIfRawExpLine(); TapeMoveNext(); //BuildCurrentLine(); whileStmt.WhileBody = ParseStmtBlockRaw(whileStmt.DangToken.Position.Col); //tape.Match(TokenKind.Repeat); return(whileStmt); }
private Exp ParseAssign() { Exp leftExp = ParseNameValueExp(); if (tape.HasCurrent && tape.Current.IsKind(TokenKindSymbol.Assign, TokenKindSymbol.AssignTo)) { ExpAssign assignExp = new ExpAssign(expContext); assignExp.IsAssignTo = (tape.Current.IsKind(TokenKindSymbol.AssignTo)); tape.MoveNext(); Exp rightExp = ParseBinaryLogicExp(); if (!assignExp.IsAssignTo) { assignExp.ToExp = leftExp; assignExp.ValueExp = rightExp; } else { assignExp.ToExp = rightExp; assignExp.ValueExp = leftExp; } return(assignExp); } else { return(leftExp); } }