generated from ElnuDev/rust-project
Cover empty file cases, deal with empty final line
This commit is contained in:
parent
d957816ded
commit
4113accdaa
2 changed files with 5 additions and 2 deletions
|
@ -30,7 +30,10 @@ pub fn parse(script: &str) -> Vec<Vec<Token>> {
|
|||
Rule::EOI => (),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
lines.push(tokens);
|
||||
// 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…
Add table
Reference in a new issue