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