public static string printGrammar( Grammar grammar )
        {
            using( StringWriter str = new StringWriter() ) {
            ExpPrinter printer = new ExpPrinter(str,-1,false);
            str.Write("(start): ");
            grammar.exp.Visit(printer);
            str.Write("\n");

            foreach( ReferenceExp exp in grammar.NamedPatterns ) {
                str.Write(exp.name);
                str.Write(" : ");
                exp.exp.Visit(printer);
                str.Write("\n");
            }

            return str.ToString();
            }
        }
Пример #2
0
        public static string printGrammar(Grammar grammar)
        {
            using (StringWriter str = new StringWriter()) {
                ExpPrinter printer = new ExpPrinter(str, -1, false);
                str.Write("(start): ");
                grammar.exp.Visit(printer);
                str.Write("\n");

                foreach (ReferenceExp exp in grammar.NamedPatterns)
                {
                    str.Write(exp.name);
                    str.Write(" : ");
                    exp.exp.Visit(printer);
                    str.Write("\n");
                }

                return(str.ToString());
            }
        }