File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,9 @@ where
173173 }
174174 o. push_str ( "}]" ) ;
175175 }
176- for ( esym, e_stidx) in self . edges ( stidx) . iter ( ) {
176+ let mut edges = self . edges ( stidx) . iter ( ) . collect :: < Vec < _ > > ( ) ;
177+ edges. sort_by ( |( _, x) , ( _, y) | x. cmp ( y) ) ;
178+ for ( esym, e_stidx) in edges {
177179 write ! (
178180 o,
179181 "\n {}{} -> {}" ,
Original file line number Diff line number Diff line change @@ -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>] [-q] [-d] <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 and exit" )
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,11 @@ fn main() {
187189 }
188190 } ;
189191
192+ if dump_state_graph {
193+ println ! ( "Stategraph:\n {}\n " , sgraph. pp_core_states( & grm) ) ;
194+ process:: exit ( 0 ) ;
195+ }
196+
190197 if !quiet {
191198 if let Some ( c) = stable. conflicts ( ) {
192199 let formatter = if let Some ( yacc_diagnostic_formatter) = & yacc_diagnostic_formatter {
You can’t perform that action at this time.
0 commit comments