Error messages
This commit is contained in:
parent
1b9a3377cb
commit
a88c8e9216
1
examples/val_binding.misti
Normal file
1
examples/val_binding.misti
Normal file
@ -0,0 +1 @@
|
||||
val identifier = 322
|
@ -14,11 +14,12 @@ impl PrintableError for LexError {
|
||||
let whitespace = whitespace.iter().collect::<String>();
|
||||
|
||||
format!(
|
||||
"\n{}\n{}^\n\n{}{}",
|
||||
"\n{}\n{}^\n\n{}{}\n{}",
|
||||
erroneous_code,
|
||||
whitespace,
|
||||
"Invalid character at pos ",
|
||||
self.position + 1,
|
||||
self.reason,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,11 @@ fn next_token(chars: &Chars, current_pos: usize) -> LexResult {
|
||||
.unwrap_or_else(|| {
|
||||
let error = LexError {
|
||||
position: current_pos,
|
||||
reason: format!("Unrecognized character: {}", next_char),
|
||||
reason: format!(
|
||||
"Unrecognized character `{}` (escaped: `{}`)",
|
||||
next_char,
|
||||
next_char.escape_default().to_string(),
|
||||
),
|
||||
};
|
||||
LexResult::Err(error)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user