From a97cce184ccf178dc34a0f0489c9df6f3ba4ee5c Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 24 Jul 2015 02:08:55 -0700 Subject: [PATCH] Empty program is valid too --- src/parser.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index 8d985c1..3825989 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -52,6 +52,10 @@ pub fn parse(input: Vec) -> ParseResult { let mut tokens: Tokens = input.iter().peekable(); + if let Some(&&EOF) = tokens.peek() { + return ParseResult::Ok(AST::Statements(vec!())); + } + match statements(&mut tokens) { ok@ParseResult::Ok(_) => { expect!(EOF, &mut tokens);