| ... | ... | @@ -375,28 +375,21 @@ fn printErrMsgToFile( |
| 375 | 375 | const text = text_buf.toOwnedSlice(); |
| 376 | 376 | |
| 377 | 377 | const stream = &file.outStream().stream; |
| 378 | | if (!color_on) { |
| 379 | | try stream.print( |
| 380 | | "{}:{}:{}: error: {}\n", |
| 381 | | path, |
| 382 | | start_loc.line + 1, |
| 383 | | start_loc.column + 1, |
| 384 | | text, |
| 385 | | ); |
| 386 | | return; |
| 387 | | } |
| 378 | try stream.print( "{}:{}:{}: error: {}\n", path, start_loc.line + 1, start_loc.column + 1, text); |
| 388 | 379 | |
| 389 | | try stream.print( |
| 390 | | "{}:{}:{}: error: {}\n{}\n", |
| 391 | | path, |
| 392 | | start_loc.line + 1, |
| 393 | | start_loc.column + 1, |
| 394 | | text, |
| 395 | | tree.source[start_loc.line_start..start_loc.line_end], |
| 396 | | ); |
| 380 | if (!color_on) return; |
| 381 | |
| 382 | // Print \r and \t as one space each so that column counts line up |
| 383 | for (tree.source[start_loc.line_start..start_loc.line_end]) |byte| { |
| 384 | try stream.writeByte(switch (byte) { |
| 385 | '\r', '\t' => ' ', |
| 386 | else => byte, |
| 387 | }); |
| 388 | } |
| 389 | try stream.writeByte('\n'); |
| 397 | 390 | try stream.writeByteNTimes(' ', start_loc.column); |
| 398 | 391 | try stream.writeByteNTimes('~', last_token.end - first_token.start); |
| 399 | | try stream.write("\n"); |
| 392 | try stream.writeByte('\n'); |
| 400 | 393 | } |
| 401 | 394 | |
| 402 | 395 | export fn stage2_DepTokenizer_init(input: [*]const u8, len: usize) stage2_DepTokenizer { |