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,8 +30,11 @@ pub fn parse(script: &str) -> Vec<Vec<Token>> {
|
||||||
Rule::EOI => (),
|
Rule::EOI => (),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
// TODO: For some a blank final line is always parsed
|
||||||
|
if tokens.len() > 0 {
|
||||||
lines.push(tokens);
|
lines.push(tokens);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lines
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,4 @@ COMMENT = _{ "#" ~ char* }
|
||||||
// lines are comprised of a statement
|
// lines are comprised of a statement
|
||||||
line = { token+ }
|
line = { token+ }
|
||||||
|
|
||||||
file = { SOI ~ line ~ (NEWLINE+ ~ line)* ~ NEWLINE* ~ EOI }
|
file = { SOI ~ (line ~ (NEWLINE+ ~ line)*)? ~ NEWLINE* ~ EOI }
|
Loading…
Add table
Reference in a new issue