/// <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> /// 7 <VOpt> ::= <V> <VOpt>; /// <para>8 <VOpt> ::= "|" <V> <VOpt>;</para> /// <para>9 <VOpt ::= null;</para> /// </summary> /// <param name="builder"></param> /// <param name="syntaxTree"></param> private static void GetFormattedVOpt(StringBuilder builder, SyntaxTree <EnumTokenTypeCG, EnumVTypeCG, TreeNodeValueCG> syntaxTree) {//<VOpt> ::= <V> <VOpt> | "|" <V> <VOpt> | null; // 7 8 9 if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___constStringLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_constStringLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_identifierLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_lessThan_Leave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_nullLeave() || syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_numberLeave()) { builder.Append(" "); GetFormattedV(builder, syntaxTree.Children[0]); //builder.Append(" "); GetFormattedVOpt(builder, syntaxTree.Children[1]); } else if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_or_Leave()) { builder.Append(" "); GetFormattedorLeave(builder, syntaxTree.Children[0]); builder.Append(" "); GetFormattedV(builder, syntaxTree.Children[1]); //builder.Append(" "); GetFormattedVOpt(builder, syntaxTree.Children[2]); } else if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_VOpt___tail_semicolon_Leave()) { GetFormattednull(builder, syntaxTree.Children[0]); } }