Esempio n. 1
0
 private static void _GetFormattedSourceCode(StringBuilder builder, SyntaxTree <EnumTokenTypeCG, EnumVTypeCG, TreeNodeValueCG> tree)
 {
     if (tree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_Start___tail_lessThan_Leave())
     {//<Start> ::= <Vn> "::=" <VList> ";" <PList>; 1
         GetFormattedVn(builder, tree.Children[0]);
         builder.Append(" ");
         GetFormattedpointToLeave(builder, tree.Children[1]);
         builder.Append(" ");
         GetFormattedVList(builder, tree.Children[2]);
         GetFormattedsemicolonLeave(builder, tree.Children[3]);
         builder.AppendLine();
         GetFormattedPList(builder, tree.Children[4]);
     }
     else
     {
         builder.Append(string.Format("error: ProductionNodeList {0} not found", tree.CandidateFunc));
     }
 }
Esempio n. 2
0
        private static ContextfreeGrammar _GetGrammar(SyntaxTree <EnumTokenTypeCG, EnumVTypeCG, TreeNodeValueCG> syntaxTree)
        {
            ContextfreeGrammar result = null;

            if (syntaxTree.CandidateFunc == LL1SyntaxParserCG.GetFuncParsecase_Start___tail_lessThan_Leave())
            {//<Start> ::= <Vn> "::=" <VList> ";" <PList>; 1
                result = new ContextfreeGrammar();

                var startProduction = new ContextfreeProduction();
                result.ProductionCollection.Add(startProduction);

                var left = GetGrammarVn(syntaxTree.Children[0]);
                startProduction.Left = left;
                result.GrammarName   = left.NodeName;

                var vlist = GetGrammarVList(syntaxTree.Children[2]);
                startProduction.RightCollection = vlist;

                GetGrammarPList(result.ProductionCollection, syntaxTree.Children[4]);
            }

            return(result);
        }