File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,14 @@ use crate::types::*;
1515
1616impl Parser {
1717 /// Construct a new parser from a grammar.
18- pub fn new ( grammar : & Grammar ) -> Parser {
18+ pub fn new ( grammar : & Grammar ) -> Result < Parser , ( ) > {
1919 let ( action_table, goto_table) = tables ( grammar. clone ( ) ) ;
20- Parser {
20+ Ok ( Parser {
2121 action_table,
2222 goto_table,
2323 start_state : 0 ,
2424 grammar : grammar. clone ( ) ,
25- }
25+ } )
2626 }
2727
2828 /// Return all the terminals that could come after this one, regardless of
@@ -573,7 +573,9 @@ mod tests {
573573 ] ,
574574 } ] ,
575575 } ;
576- let parser = Parser :: new ( & grammar) ;
576+ let Ok ( parser) = Parser :: new ( & grammar) else {
577+ panic ! ( )
578+ } ;
577579 assert_eq ! (
578580 parser. next_terminals( & "L_PAREN" . to_string( ) ) ,
579581 vec![ "R_PAREN" . to_string( ) ]
You can’t perform that action at this time.
0 commit comments