How to write multiline errorformat string?

不想你离开。 提交于 2019-12-11 08:43:00

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/13256135/how-to-write-multiline-errorformat-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!