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(); } }
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()); } }