Sublime Forum

Build system regex captures - help needed

#1

hello, I am new to build systems. I have it set up correctly and it builds all ok. Now I want to show only the important part on my console output. An example output is as below:

VHDL/Verilog/EDIF/SystemC Simulator build 10.3.3558.6081 

(c) 1997-2016 Aldec, Inc. All rights reserved.

License Number 0

 Welcome to VSIMSA!
 This message was printed from `startup.do' macro file.

# creating library
alib work
ALIB: Library `work' attached.

Compile success 0 Errors 0 Warnings  Analysis time :  31.0 [ms]
Compile Package "BT601_cfg"
Compile success 0 Errors 0 Warnings  Analysis time :  15.0 [ms]
# starting simulation with tb_top as the top level module
# asim fpc_tb
# running the simulation
# run 1000us
echo hi
hi
quit

To get started I want to pick these lines:
Compile success 0 Errors 0 Warnings Analysis time : 15.0 [ms]

my regex is as follows:

^Compile success [0-9]+ Errors [0-9]+ Warnings Analysis time : [0-9]+.[0-9]+ [ms]

how can I use this in my “file_regex”: “” ?

thank you

0 Likes

#2

and, what is the difference in file_regex and line_regex?

0 Likes

#3

Build systems always display everything that the build sent to stdout and stderr, so if your ultimate goal is to only display a part of the build output in the Sublime build panel the easiest way to do that would be to have your build run a batch file or shell script (depending on your platform) that does the filtering for you.

Such a script would run what your current build is now running, but filter the output and block anything that you don’t want displayed in the panel.

The file_regex and line_regex are used to capture build errors so that you can navigate between errors from directly within Sublime.

file_regex supports up to four captures that provide information on the filename, error line, error column and error message, respectively.

line_regex only supports three captures, error line, error column and error message.

The difference is due to the fact that some compilers/tools don’t provide all of that information all in one line and instead might tell you the name of the file on one line and the error message and location on another.

If you’re building with such a tool, then you need to use both regular expressions. Whenever there is a match on the line_regex expression, Sublime searches backwards from that point in the buffer to find a match for the file_regex so that it can fill out the rest of the information from there.

If your tool generates all of the fields in one line, you don’t need to use line_regex at all.

More information is available in both the official and unofficial documentation.

1 Like

#4

Thank you this was very helpful.

This is an example of my error messages, all captures are present in a single line, in the right order

Error: COMP96_0111: D:\Projekte\example\sim\wrapper\ActiveHDL\..\..\..\src\hdl\BT601_pkg.vhd : (91, 13): Labels do not match.

I read elsewhere I use (? in the regex for the parts that i do not want to match, and use groups for each capture.

so I have now 6 groups:

^(?Error: )
(?.*?: )
(?.*.\\)
([a-Z0-9_]*.vhd)        <- filename
(\([0-9]+)                   <- error line
(, [0-9]+)                   <- error column
todo: error message

aside from any optimization, is this somewhat the right direction?

Still unsure about the following:

  • filename does not include path?
  • how can I consume unwanted characters in my regex?

thank you

0 Likes

#5

I made it. filename capture includes the path.
:slight_smile:

1 Like

#6

Without going into too much detail on regular expressions and how they work (for that I would recommend something like this site), your regex:

  1. Has to match enough of the string to satisfy the requirements of providing at least a file name and a line number (so that Sublime can open the file and position the cursor)
  2. Should contain no more than four captures (although presumably any captures above four are just ignored)
  3. Needs to capture the items in the order presented above

You’re headed in the right direction, but there should be no more than four captures. The regex consumes unwanted characters by matching them without specifying that you specifically want to capture them.

So an example of a regex that satisfies this is the following:

^Error: .*?: (.*\.vhd) : \((\d+), (\d+)\): (.*)

The file name that you capture will be assumed to be relative to the folder set by the working_dir in the build system, so it doesn’t need to be a full path. If I recall correctly if the file name you capture is a complete path such as in your example, it’s just used directly.

0 Likes