Handmade Hero»Forums»Code
8 posts
None
Building with Sublime: highlighting errors
Edited by Saticmotion on
So I've been following the guide for Sublime. At some point we are supposed to create a build script for Sublime that calls the .bat file:

1
2
3
4
{
    "shell_cmd": "build",
    "file_regex": "^ *([A-z]:.*)[(]([0-9]+)[)]"
}


According to that guide I should be able to cycle between errors with F4. But this requires the file_regex in the build script above to work on the output cl.exe generates. And this is where I hit a wall. The best regex I could write was:

1
^(..[A-z0-9_.]*)\n.*[(]([0-9]*)


which can catch exactly 1 error. The first group catches the file name, the second catches the line number.

Does anyone have a working regex for cl.exe output?

For reference, here is some output of my build:

1
2
3
4
5
6
7
win32_proceduralmusic.cpp
..\win32_proceduralmusic.cpp(62) : error C2065: 'CS_USEDEFAULT' : undeclared identifier
..\win32_proceduralmusic.cpp(63) : error C2065: 'CS_USEDEFAULT' : undeclared identifier
..\win32_proceduralmusic.cpp(64) : error C2065: 'CS_USEDEFAULT' : undeclared identifier
..\win32_proceduralmusic.cpp(65) : error C2065: 'CS_USEDEFAULT' : undeclared identifier
..\win32_proceduralmusic.cpp(72) : error C2059: syntax error : '='
[Finished in 0.4s]




EDIT: Getting closer. I randomly deleted part of the regex, and now I'm matching all errors. They also get highlighted. But when I use F4 to cycle between them, It opens a different file which is at W:\in32_proceduralmusic.cpp instead of W:\win32_proceduralmusic.cpp.

1
(.*)[(]([0-9]*)
Mike T
27 posts
Building with Sublime: highlighting errors
Edited by Mike T on
You could try something like this:

1
^ *([A-z0-9.]*)\(([0-9]+)\)


It's loosely based on the original one, and I'm not 100% sure what the spec is here, but it seems to capture the right stuff from your example.

See https://regex101.com/r/pI2tZ4/2
8 posts
None
Building with Sublime: highlighting errors
Edited by Saticmotion on
No idea what's wrong with the regex, but it crashes Sublime. I'm going to figure out what it does exactly and find a regex that doesn't crash. Thanks!

EDIT: With that regex tester, my regex captures the exact same as yours, so it should be working in Sublime. Hmm...
8 posts
None
Building with Sublime: highlighting errors
Turns out the problem was the relative file paths. In episode 4 Casey turns on full paths in the compiler, and now it works perfectly.