Simplify parsing by introducing an EOF token.

This commit is contained in:
Stephen Chung
2020-04-17 20:01:41 +08:00
parent 5d9a99cefc
commit c5f66e932b
5 changed files with 189 additions and 244 deletions

View File

@@ -23,15 +23,9 @@ fn eprint_error(input: &str, err: EvalAltResult) {
let lines: Vec<_> = input.split('\n').collect();
// Print error
let pos = if err.position().is_eof() {
let last = lines[lines.len() - 1];
Position::new(lines.len(), last.len() + 1)
} else {
err.position()
};
let pos = err.position();
match pos {
p if p.is_eof() => panic!("should not be EOF"),
p if p.is_none() => {
// No position
eprintln!("{}", err);