Skip to content

Commit

Permalink
Better error reporting for missing semicolon in code clock
Browse files Browse the repository at this point in the history
cc #33 #53
  • Loading branch information
Kogia-sima committed Apr 6, 2021
1 parent f0ef8e4 commit 9bf4090
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sailfish-compiler/src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ impl SourceBuilder {
fn write_text<'a>(&mut self, token: &Token<'a>) -> Result<(), Error> {
use std::fmt::Write;

// if error has occured at the first byte of `render_text!` macro, it
// will be mapped to the first byte of text
self.source_map.entries.push(SourceMapEntry {
original: token.offset(),
new: self.source.len(),
length: 1,
});

self.source.push_str("__sf_rt::render_text!(__sf_buf, ");
// write text token with Debug::fmt
write!(self.source, "{:?}", token.as_str()).unwrap();
Expand Down

0 comments on commit 9bf4090

Please sign in to comment.