private ProcNameRaw ParseProcName() { ProcNameRaw procName = new ProcNameRaw(); while (tape.HasCurrent) { if (tape.Current.IsKind(TokenKindSymbol.LBS)) { var bck = ParseProcBracket(); if (bck != null) { procName.NameTerms.Add(bck); } } else if (tape.Current.IsKind(TokenKindKeyword.Ident)) { ProcNameRaw.NameText pt = new ProcNameRaw.NameText(); pt.TextToken = (LexTokenText)tape.Current; procName.NameTerms.Add(pt); tape.MoveNext(); } else if (tape.Current.IsKind(TokenKindSymbol.Colon)) { break; } else { tape.error("错误的过程名称"); break; } } return(procName); }
//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 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 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 Exp ParseNameValueExp() { Exp leftExp = ParseBinaryLogicExp(); if (tape.HasCurrent && tape.Current.IsKind(TokenKindSymbol.Colon)) { tape.MoveNext(); Exp rightExp = ParseBinaryLogicExp(); if (leftExp is ExpChain) { ExpChain chainExp = leftExp as ExpChain; if (chainExp.SubCount == 1) { object varobj = chainExp.RawElements[0]; if (varobj is LexTokenText) { LexTokenText textToken = (varobj as LexTokenText); ExpNameValue expNameValue = new ExpNameValue(this.expContext, textToken, rightExp); return(expNameValue); } else { tape.error("参数名称错误"); return(rightExp); } } else { tape.error("参数名称的长度不是1"); return(rightExp); } } else if (leftExp is ExpVarBase) { ExpVarBase leftVarExp = (leftExp as ExpVarBase); LexToken varToken = leftVarExp.VarToken; ExpNameValue expNameValue = new ExpNameValue(this.expContext, varToken, rightExp); return(expNameValue); } else { tape.error("调用过程时指定的参数名称只能是标识符"); return(rightExp); } } else { return(leftExp); } }
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 ExpRaw ParseRawExpLine() { ExpRaw rexp = new ExpRaw(); //int line = tape.Current.Line; int bracketCount = -1; while (currLineTokenTape.HasCurrent) { if (currLineTokenTape.Current.IsKind(TokenKindSymbol.LBS)) { rexp.RawTokens.Add(currLineTokenTape.Current); if (bracketCount == -1) { bracketCount = 0; } bracketCount++; currLineTokenTape.MoveNext(); } else if (currLineTokenTape.Current.IsKind(TokenKindSymbol.RBS)) { if (bracketCount <= 0) { currLineTokenTape.error("多余的右括号"); } else { bracketCount--; rexp.RawTokens.Add(currLineTokenTape.Current); } currLineTokenTape.MoveNext(); } else if (currLineTokenTape.Current.IsKind(TokenKindSymbol.Comma)) { if (bracketCount == -1) { //rexp.RawTokens.Add(currLineTokenTape.Current); //currLineTokenTape.MoveNext(); break; } else if (bracketCount == 0) { //currLineTokenTape.MoveNext(); break; } else if (bracketCount > 0) { rexp.RawTokens.Add(currLineTokenTape.Current); currLineTokenTape.MoveNext(); } } else { rexp.RawTokens.Add(currLineTokenTape.Current); currLineTokenTape.MoveNext(); } //if (tape.CurrentKind == TokenKind.Semi) //{ // break; //} } return(rexp); }