diff --git a/src/lib.rs b/src/lib.rs index 0dfeb54..0e8fe86 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,7 +30,10 @@ pub fn parse(script: &str) -> Vec> { Rule::EOI => (), _ => unreachable!(), } - lines.push(tokens); + // TODO: For some a blank final line is always parsed + if tokens.len() > 0 { + lines.push(tokens); + } } lines } diff --git a/src/rpy.pest b/src/rpy.pest index 060253c..5600fa6 100644 --- a/src/rpy.pest +++ b/src/rpy.pest @@ -41,4 +41,4 @@ COMMENT = _{ "#" ~ char* } // lines are comprised of a statement line = { token+ } -file = { SOI ~ line ~ (NEWLINE+ ~ line)* ~ NEWLINE* ~ EOI } \ No newline at end of file +file = { SOI ~ (line ~ (NEWLINE+ ~ line)*)? ~ NEWLINE* ~ EOI } \ No newline at end of file