Пример #1
0
        /// <summary>
        /// 7 &lt;VOpt&gt; ::= &lt;V&gt; &lt;VOpt&gt;;
        /// <para>8 &lt;VOpt&gt; ::= "|" &lt;V&gt; &lt;VOpt&gt;;</para>
        /// <para>9 &lt;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()));
            }
        }
Пример #2
0
 /// <summary>
 /// 7 &lt;VOpt&gt; ::= &lt;V&gt; &lt;VOpt&gt;;
 /// <para>8 &lt;VOpt&gt; ::= "|" &lt;V&gt; &lt;VOpt&gt;;</para>
 /// <para>9 &lt;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]);
     }
 }