@@ -32,7 +32,7 @@ fn usage(prog: &str, msg: &str) -> ! {
3232 if !msg. is_empty ( ) {
3333 eprintln ! ( "{}" , msg) ;
3434 }
35- eprintln ! ( "Usage: {} [-r <cpctplus|none>] [-y <eco|grmtools|original>] [-q ] <lexer.l> <parser.y> <input file>" , leaf) ;
35+ eprintln ! ( "Usage: {} [-r <cpctplus|none>] [-y <eco|grmtools|original>] [-dq ] <lexer.l> <parser.y> <input file>" , leaf) ;
3636 process:: exit ( 1 ) ;
3737}
3838
@@ -87,6 +87,7 @@ fn main() {
8787 let matches = match Options :: new ( )
8888 . optflag ( "h" , "help" , "" )
8989 . optflag ( "q" , "quiet" , "Don't print warnings such as conflicts" )
90+ . optflag ( "d" , "dump-state-graph" , "Print the parser state graph" )
9091 . optopt (
9192 "r" ,
9293 "recoverer" ,
@@ -109,6 +110,7 @@ fn main() {
109110 usage ( prog, "" ) ;
110111 }
111112
113+ let dump_state_graph = matches. opt_present ( "d" ) ;
112114 let quiet = matches. opt_present ( "q" ) ;
113115
114116 let recoverykind = match matches. opt_str ( "r" ) {
@@ -187,6 +189,10 @@ fn main() {
187189 }
188190 } ;
189191
192+ if dump_state_graph {
193+ println ! ( "Stategraph:\n {}\n " , sgraph. pp_core_states( & grm) ) ;
194+ }
195+
190196 if !quiet {
191197 if let Some ( c) = stable. conflicts ( ) {
192198 let formatter = if let Some ( yacc_diagnostic_formatter) = & yacc_diagnostic_formatter {
@@ -213,7 +219,7 @@ fn main() {
213219 if pp_sr {
214220 println ! ( "{}" , c. pp_sr( & grm) ) ;
215221 }
216- if pp_rr || pp_sr {
222+ if ( pp_rr || pp_sr) && !dump_state_graph {
217223 println ! ( "Stategraph:\n {}\n " , sgraph. pp_core_states( & grm) ) ;
218224 }
219225 formatter. handle_conflicts :: < DefaultLexerTypes < u32 > > (
0 commit comments