Sublime Forum

Yet another regex question for build systems

#1

Hey all,

I am trying to get the build system to work properly using CMake and the gfortran compiler. Currently I have:

{ "cmd": "make", "-j3"], "working_dir": "/home/youngmit/opt/mpact-debug", "file_regex": "^(.+):([0-9]+).([0-9]+):.*$", "line_regex": "^Error:\\s(.*)$" }
which is very close to working, but not quite. The issure is that the error message and the file/line/column are on separate lines in the compiler output. Heres and example:

[code]/home/youngmit/…/file.f90:144.79:

CALL UTest_Assert(bool,144,'CALL testCMR%init() %angles%nrays FAILED!')l
                                                                       1    

Error: Syntax error in CALL statement at (1)
[/code]

When I hit F7, it goes through and builds, and the regular expressions detect the error, but hitting F4 just selects the line in the console corresponding to the error message, rather than opening up the offending file. If I remove the line_regex, F4 will take me to the location in the file where the file_regex matches, but this ends up including errors and warnings, when I really only want to cycle through errors. I also tried making a regex for fille_regex that matches the entire multi-line error message, but again, hitting F4 just sends me to the lines in the console that match, rather than to the file of interest. Any ideas?

Thanks!

0 Likes

#2

You may be able to find out more information by entering sublime.log_result_regex(True) in the console.

0 Likes

#3

Thank you for the reply. I tried invoking sublime.log_result_regex(True), and it indicates that i only get valid matches if i only specify the “file_regex” expression. This makes sense, because it was the only one that would take me to the file when i press F4. The issue is that as soon as a specify the “line_regex,” it no longer matches the path, line, column. It does match part of the output from the build command and takes me to that (it hilights the error message), but it doesnt seem to have extracted filename and line number from the file_regex.

Reading the documentation for the build system configurations, i am a little bit confused about the difference between the “file_regex” and “line_regex” values. The etymology does not make a lot of sense to me, or perhaps they are more specific than i may have thought… is the file_regex ONLY for all of the values (filename, line, column, error), with the possibility of the line, column, error message being on a separate line that should be matched with the line_regex? If so, under this paradigm is it possible to match a message that has filename, line and column on one line and the error message on another?

0 Likes

#4

This might be an old man yells at cloud situation, but maybe a more general form could be useful. Perhaps something that takes a similar form to the syntax hilighting format:

{
    "cmd": "make", "-j4"],
    "working_dir": "path",
    "patterns": 
        {
            "match": "^(.+):([0-9]+).([0-9]+):.*$",
            "captures": {
                "1": {"name": "file"},
                "2": {"name": "line"},
                "3": {"name": "column"}
            }
        },
        {
            "match": "^Error:\\s(.*)$",
            "captures": {
                "1": {"name": "message"}
            }
        }
    ]
}
0 Likes