diff options
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/parser.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/rust/src/parser.rs b/rust/src/parser.rs index c54386c..48ef2e0 100644 --- a/rust/src/parser.rs +++ b/rust/src/parser.rs @@ -54,10 +54,12 @@ pub fn parse(arg: &str) -> Vec<Value> { let tokens = tokenize(arg); let mut parser = Parser { tokens, index: 0 }; let mut result = Vec::new(); - let expr = parse_expression(&mut parser) - .map_err(|e| panic!("Syntax error: {}", e)) - .unwrap(); - result.push(expr); + while parser.index < parser.tokens.len() { + let expr = parse_expression(&mut parser) + .map_err(|e| panic!("Syntax error: {}", e)) + .unwrap(); + result.push(expr); + } result } @@ -248,6 +250,11 @@ mod tests { ); } + #[test] + fn parse_multiple_values() { + assert_eq!(vec![Sym("foo".to_string()), Num(42)], parse("foo 42")); + } + impl Arbitrary for Value { type Parameters = (); type Strategy = BoxedStrategy<Self>; |
