示例#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>
        /// 获取此产生式列表的列表(产生式右部)的复制品
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var result = new RightSection();

            foreach (var element in this)
            {
                result.Add(element.Clone() as ProductionNodeList);
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 4 &lt;VList&gt; ::= &lt;V&gt; &lt;VOpt&gt;;
        /// </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);
        }