diff --git a/renrs/src/lib.rs b/renrs/src/lib.rs index d451396..0b6fd56 100644 --- a/renrs/src/lib.rs +++ b/renrs/src/lib.rs @@ -140,6 +140,11 @@ fn parse_file(file_path: PathBuf) -> Vec { let token_lines = tokenize_file(file_path); let mut commands = Vec::new(); for line in token_lines { + macro_rules! unknown { + () => { + panic!("Unknown command {}", describe_line(&line)) + }; + } commands.push(match line.as_slice() { [Str(text)] => Say { name: None, @@ -153,10 +158,10 @@ fn parse_file(file_path: PathBuf) -> Vec { food: food.to_owned(), politely: match tail { [Boolean(politely)] => *politely, - _ => false, + _ => unknown!(), }, }, - _ => panic!("Unknown command {}", describe_line(&line)), + _ => unknown!(), }); } commands