/// <summary> /// 7 <VOpt> ::= <V> <VOpt>; /// <para>8 <VOpt> ::= "|" <V> <VOpt>;</para> /// <para>9 <VOpt ::= null;</para> /// </summary> /// <param name="vlist"></param> /// <param name="candidate"></param> /// <param name="syntaxTree"></param> private static object GetGrammarVOpt(RightSection vlist, ProductionNodeList candidate, SyntaxTree <EnumTokenTypeCG, EnumVTypeCG, TreeNodeValueCG> syntaxTree) {//<VOpt> ::= <V> <VOpt> | "|" <V> <VOpt> | null; // 7 8 9 if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_nullLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_identifierLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_numberLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_constStringLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___constStringLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_lessThan_Leave() ) { var v = GetGrammarV(syntaxTree.Children[0]); candidate.Add(v); return(GetGrammarVOpt(vlist, candidate, syntaxTree.Children[1])); } else if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_or_Leave()) { ProductionNodeList newCandidate = new ProductionNodeList(); vlist.Add(newCandidate); var v = GetGrammarV(syntaxTree.Children[1]); newCandidate.Add(v); return(GetGrammarVOpt(vlist, newCandidate, syntaxTree.Children[2])); } else if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_semicolon_Leave()) { return(GetGrammarnull(syntaxTree.Children[0])); } else { return(string.Format("{0}", syntaxTree.CandidateFunc.ToString())); } }
/// <summary> /// 获取此产生式列表的列表(产生式右部)的复制品 /// </summary> /// <returns></returns> public object Clone() { var result = new RightSection(); foreach (var element in this) { result.Add(element.Clone() as ProductionNodeList); } return(result); }
/// <summary> /// 4 <VList> ::= <V> <VOpt>; /// </summary> /// <param name="syntaxTree"></param> private static RightSection GetGrammarVList(SyntaxTree <EnumTokenTypeCG, EnumVTypeCG, TreeNodeValueCG> syntaxTree) {//<VList> ::= <V> <VOpt>; 4 RightSection vlist = new RightSection(); if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VList___constStringLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VList___tail_constStringLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VList___tail_identifierLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VList___tail_lessThan_Leave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VList___tail_nullLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VList___tail_numberLeave()) { var candidate = new ProductionNodeList(); vlist.Add(candidate); var v = GetGrammarV(syntaxTree.Children[0]); candidate.Add(v); var info = GetGrammarVOpt(vlist, candidate, syntaxTree.Children[1]); } return(vlist); }