summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNanoTech2016-12-06 03:43:13 -0600
committerNanoTech2017-03-10 23:48:27 -0600
commit90d81dae221318072ddb5c7d85f63b1a55844923 (patch)
tree7e96c9d020500e0019a855ae327f4b480d285e15 /src
parent84c7ec41455e9f7b9bdd7a7336a877fb04e4bd3a (diff)
Report the offset of errors
Diffstat (limited to 'src')
-rw-r--r--src/lexer.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lexer.rs b/src/lexer.rs
index f141f81..e8ef2ac 100644
--- a/src/lexer.rs
+++ b/src/lexer.rs
@@ -55,7 +55,7 @@ pub enum Tok {
#[derive(Debug)]
pub enum LexicalError {
- Error(nom::simple_errors::Err<u32>),
+ Error(usize, nom::simple_errors::Err<u32>),
Incomplete(nom::Needed),
}
@@ -210,8 +210,9 @@ impl<'input> Iterator for Lexer<'input> {
Some(Ok((start, t, self.offset)))
}
Error(e) => {
+ let offset = self.offset;
self.offset = self.input.len();
- Some(Err(LexicalError::Error(e)))
+ Some(Err(LexicalError::Error(offset, e)))
}
Incomplete(needed) => {
Some(Err(LexicalError::Incomplete(needed)))