如何编写多行错误格式字符串?

时间:2012-11-06 17:22:03

标签: syntax-error opencl vim errorformat

我想为vim-opencl plugin编写OpenCL语法检查程序。 OpenCL编译器对输出错误进行了一些奇怪的格式化。有两种类型的错误。

正常(有小错误说明):

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

错误说明中的换行符不正常:

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

所以麻烦在于第二种情况下破解错误解释的两个部分和第一种情况下的正常错误处理的连接。

我正在使用syntastic作为generel语法检查程序。现在我有这样的代码:

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

所以第一和第二个错误看起来如下:

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;

几乎没问题(特别是在第二种情况下),但我不知道怎么做到这样:

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"

或至少像这样:

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;

你有什么想法吗?

UPD。更新了错误格式和期望

1 个答案:

答案 0 :(得分:0)

我不知道测试它的有用方法,但你也需要用反斜杠来逃避空间。

我也可以在%C之后添加一个空格,以便它们只匹配以空格开头的行。

最后,对于警告,你忽略了一些行,并且从不在任何地方都有%Z。 (我认为你不需要Z前面的减号,但我不清楚;我自己不使用减号。

祝你好运。

相关问题