How to write multiline errorformat string?
Asked Answered
A

1

1

I want to write OpenCL syntax checker for vim-opencl plugin. OpenCL compiler do some strange formatting of output errors. There are two types of errors.

Normal (with small error explanation):

"/tmp/OCLUKvOsF.cl", line 143: error: expression must have integral type
        rec_table[PRIME_P - ri] = PRIME_P - i;
                  ^

And not-normal with line-break in error explanation:

"/tmp/OCLUKvOsF.cl", line 148: error: a value of type "uint16" cannot be used
          to initialize an entity of type "uint"
    uint a = value, b = PRIME_P, u = 0, v = 0;
             ^

So trouble is in concatenation of two parts of broken error explanation in second case and normal error handling in first case.

I'm using syntastic as generel syntax checker. Now I have such code for it:

let errorformat = '%E"%f"\, line %l: error: %m,%+C%.%#,%-Z%p^,'.
                  \'%W"%f"\, line %l: warning: %m,%-C%.%#,'.
                  \'%-G%.%#'

So first and second errors look following:

program.cl|143 error| expression must have integral type rec_table[PRIME_P - ri] = PRIME_P - i; ^
program.cl|148 col 14 error| a value of type "uint16" cannot be used to initialize an entity of type "uint" uint a = value, b = PRIME_P, u = 0, v = 0;

It almost ok (especially in second case), but I don't know how to make it like this:

program.cl|143 col 19 error| expression must have integral type
program.cl|148 col 14 error| a value of type "uint16" cannot be used to initialize an entity of type "uint"

Or at least like this:

program.cl|143 col 19 error| expression must have integral type rec_table[PRIME_P - ri] = PRIME_P - i;
program.cl|148 col 14 error| a value of type "uint16" cannot be used to initialize an entity of type "uint" uint a = value, b = PRIME_P, u = 0, v = 0;

Do you have some idea?

UPD. Updated errorformat and expectations

Alcaeus answered 6/11, 2012 at 17:22 Comment(0)
S
0

I don't know of a useful way to test this but you need to escape your spaces with a backslash too.

I might also put a -space after the %Cs so that they only match lines starting with a space.

Finally for warnings you're ignoring some lines and never have a %Z anywhere. (I don't think you need the minus in front of the Z but I'm not clear on that; I don't use the minus myself.

Good luck.

Spill answered 8/11, 2012 at 0:46 Comment(2)
Thanks for your comment! It's no need to escape spaces according to syntastic help: github.com/scrooloose/syntastic/blob/master/doc/…Alcaeus
I will make experiment with %Z and space before %CAlcaeus

© 2022 - 2024 — McMap. All rights reserved.