fixing tab indentation in error messages and depell not displaying errors
This commit is contained in:
parent
5cce904135
commit
276d1bb0cf
|
@ -55,8 +55,9 @@ unsafe fn compile_and_run(mut fuel: usize) {
|
|||
files
|
||||
};
|
||||
|
||||
let mut ctx = CodegenCtx::default();
|
||||
|
||||
let files = {
|
||||
let mut ctx = hblang::parser::Ctx::default();
|
||||
let paths = files.iter().map(|f| f.path).collect::<Vec<_>>();
|
||||
let mut loader = |path: &str, _: &str, kind| match kind {
|
||||
hblang::parser::FileKind::Module => Ok(paths.binary_search(&path).unwrap() as FileId),
|
||||
|
@ -69,7 +70,7 @@ unsafe fn compile_and_run(mut fuel: usize) {
|
|||
f.path,
|
||||
// since 'free' does nothing this is fine
|
||||
String::from_raw_parts(f.code.as_mut_ptr(), f.code.len(), f.code.len()),
|
||||
&mut ctx,
|
||||
&mut ctx.parser,
|
||||
&mut loader,
|
||||
)
|
||||
})
|
||||
|
@ -77,9 +78,14 @@ unsafe fn compile_and_run(mut fuel: usize) {
|
|||
};
|
||||
|
||||
let mut ct = {
|
||||
let mut ctx = CodegenCtx::default();
|
||||
Codegen::new(&files, &mut ctx).generate(root as FileId);
|
||||
|
||||
if !ctx.parser.errors.borrow().is_empty() {
|
||||
log::error!("{}", ctx.parser.errors.borrow());
|
||||
return;
|
||||
}
|
||||
|
||||
let mut c = Codegen::new(&files, &mut ctx);
|
||||
c.generate(root as FileId);
|
||||
c.assemble_comptime()
|
||||
};
|
||||
|
||||
|
|
|
@ -1167,14 +1167,16 @@ fn report_to(file: &str, path: &str, pos: Pos, msg: &dyn fmt::Display, out: &mut
|
|||
|
||||
let line = &file[file[..pos as usize].rfind('\n').map_or(0, |i| i + 1)
|
||||
..file[pos as usize..].find('\n').map_or(file.len(), |i| i + pos as usize)];
|
||||
col += line.matches('\t').count() * 3;
|
||||
col += line.chars().take_while(|c| c.is_whitespace()).filter(|&c| c == '\t').count() * 3;
|
||||
|
||||
let mut has_non_whitespace = false;
|
||||
for char in line.chars() {
|
||||
if char == '\t' {
|
||||
if char == '\t' && !has_non_whitespace {
|
||||
_ = out.write_str(" ");
|
||||
} else {
|
||||
_ = out.write_char(char);
|
||||
}
|
||||
has_non_whitespace |= !char.is_whitespace();
|
||||
}
|
||||
_ = out.write_char('\n');
|
||||
for _ in 0..col - 1 {
|
||||
|
|
Loading…
Reference in a new issue