Home Download Buy Blog Forum Support

file_regex parse error

file_regex parse error

Postby shagwana on Sun Jan 15, 2012 2:41 pm

I am currently trying to create a build system however I am now a little stumped, when my build system fails to compile the code I get an error not unlike ..

Compile Error: Missing Type specifier
[C:/Users/user account/Desktop/Test/TestMessage2.bmx;3;16]
Build Error: failed To compile C:/Users/user account/Desktop/Test/TestMessage2.bmx

Now I have managed to whip up a snippet of regex that can pick out the file like so;

"file_regex": "(?<=\[)(.*?)(?=\;)"

This selects the file from (but not including) [ upto the ; (not including as well)

If I drop that in the file_regex of the build system I am working on it fails to work, report 'Error trying to parse, invalid escape' when I try and build the file that causes an issue.

Any idea what I am doing wrong?
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Re: file_regex parse error

Postby facelessuser on Sun Jan 15, 2012 2:57 pm

Keep in mind that strings require escaping and regex requires escaping.

"\[" will never make it to the regex and it means nothing to the string?.

You need to escape your string escapes to have them make it to the regex parsing.

Code: Select all
(?<=\\[)(.*?)(?=\\;)


That should get you heading in the right direction.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: file_regex parse error

Postby shagwana on Sun Jan 15, 2012 4:05 pm

Sweet, thats what it was, just needed to escape it!. Many Thanks.

Now once a error occurs I tap F4 and the correct file opens with the above snippet. However its not putting the cursor at the right point

using

((?<=\\[)(.*?)(?=\\;))|((?<=\\;)(.*?)(?=\\;))|((?<=\\;)(.*?)(?=\\]))

will let me select the file, line then column however I can not seem to get it to work as expected
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Re: file_regex parse error

Postby shagwana on Sun Jan 15, 2012 4:30 pm

I thought (maybe very wrongly!) that in order to have the goto error working you needed to specify line and column in the same file_regex ?
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Re: file_regex parse error

Postby shagwana on Sun Jan 15, 2012 4:49 pm

Ahaa!

got it to work with!

"file_regex": "((?<=\\[).*?(?=\\;))\\;([0-9]+)\\;([0-9]+)\\]"
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Re: file_regex parse error

Postby shagwana on Sun Jan 15, 2012 5:37 pm

Right after much more playing around I have get this to work

"file_regex": "((?<=\\[).*?(?=\\;))\\;([0-9]+)\\;([0-9]+)",

All good and dandy, as I expect group 1 = filename, group 2 = line number, group 3 = column
Now trying to get the error message is proving beyond my current ability.


An example of the error message is;

Compile Error: Missing Type specifier
[C:/Users/user account/Desktop/Test/TestMessage2.bmx;3;16]
Build Error: failed To compile C:/Users/user account/Desktop/Test/TestMessage2.bmx

I tried to make group 4 yank the error message by doing ... ((?<=\\[).*?(?=\\;))\\;([0-9]+)\\;([0-9]+)|(compile error: .*) but that does not work

any pointers on how to get the error to group 4?
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Re: file_regex parse error

Postby facelessuser on Sun Jan 15, 2012 8:43 pm

Well, first off, regex is case sensitive by default...so

compile error: != Compile Error:
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: file_regex parse error

Postby shagwana on Mon Jan 16, 2012 7:08 am

((?<=\\[).*?(?=\\;))\\;([0-9]+)\\;([0-9]+)|(Compile Error: .*)

Yep your right, correcting the case of the compile error still does not do what I want it too.
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Re: file_regex parse error

Postby facelessuser on Mon Jan 16, 2012 2:38 pm

Can you post an example of the entire thing you are trying to target with regex? I kind of would need to see the error in context with everything else you are targeting to be any real help.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: file_regex parse error

Postby shagwana on Mon Jan 16, 2012 6:13 pm

The build system I am trting to make is for BlitzMax (http://www.blitzmax.com)


the build file is as;
Code: Select all
{
   "cmd": ["bmk.bat", "release", "single", "fast", "console", "$file"],
     "file_regex": "((?<=\\[).*?(?=\\;))\\;([0-9]+)\\;([0-9]+)",
     "selector": "source.BlitzMax"
}   

The above calls a .bat file to compile (and run) the application, should an error occur when its compiled the output in the console looks like;
Code: Select all
Compiling:TestProg2.bmx

Compile Error: Missing type specifier
[C:/Users/user account/My Projects/Sandbox/Sublime Text 2 blitzmax plugin/Example bmx Source/CompileTest/TestProg2.bmx;3;16]
Build Error: failed to compile C:/Users/user account/My Projects/Sandbox/Sublime Text 2 blitzmax plugin/Example bmx Source/CompileTest/TestProg2.bmx[Finished]


The regex I provided above does work a treat. When the error occurs after I build I can press F4 and the edit cursor is moved to the error in question.

As I understand it;
Group 1 of the file_regex shows the filename of the error
Group 2 of the file_regex shows the line number in that file
Group 3 of the file_regex shows the column in that file
Group 4 is the error message

Providing group 4 on the end like so;
Code: Select all
     "file_regex": "((?<=\\[).*?(?=\\;))\\;([0-9]+)\\;([0-9]+)|(Compile Error: .*)",

Does not work as I expected it too.

Break down of the groups..
Code: Select all
Group 1 = ((?<=\\[).*?(?=\\;))
Group 2 = ([0-9]+)
Group 3 = ([0-9]+)
Group 4 = (Compile Error: .*)


Any idea how I can get the error message working.

As I understand it, when Group 4 is working as expected I should see the error message in the Status Bar of Sublime Text 2 when I press F4
shagwana
 
Posts: 17
Joined: Mon Jul 11, 2011 8:37 pm

Next

Return to Plugin Development

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 7 guests