Cover empty file cases, deal with empty final line

main
Elnu 2 years ago
parent d957816ded
commit 4113accdaa

@ -30,8 +30,11 @@ pub fn parse(script: &str) -> Vec<Vec<Token>> {
Rule::EOI => (),
_ => unreachable!(),
}
// TODO: For some a blank final line is always parsed
if tokens.len() > 0 {
lines.push(tokens);
}
}
lines
}

@ -41,4 +41,4 @@ COMMENT = _{ "#" ~ char* }
// lines are comprised of a statement
line = { token+ }
file = { SOI ~ line ~ (NEWLINE+ ~ line)* ~ NEWLINE* ~ EOI }
file = { SOI ~ (line ~ (NEWLINE+ ~ line)*)? ~ NEWLINE* ~ EOI }
Loading…
Cancel
Save