How to write a multi-line error string?

I want to write an OpenCL parser for a vim-opencl plugin . The OpenCL compiler does weird formatting of output errors. There are two types of errors.

Normal (with a little explanation):

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

And not normal with an explanation of the line in error:

 "/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; ^ 

Thus, the problem lies in combining the two parts of the broken error description in the second case and the normal error handling in the first case.

I use syntastic as a syntax generator. Now I have code like this for this:

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

So, the first and second errors are as follows:

 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; 

This is almost normal (especially in the second case), but I don't know how to do it:

 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 an idea?

UPD Updated error and expect format

+1
source share
1 answer

I don't know a useful way to test this, but you also need to avoid backslash spaces.

I could also put -space after %C so that they match only lines starting with a space.

Finally, for warnings, you ignore some lines and never have %Z (I don’t think you need a minus before Z, but I don’t understand, I don’t use minus myself.

Good luck.

0
source

Source: https://habr.com/ru/post/1215486/


All Articles