如何编写多行错误格式字符串? [英] How to write multiline errorformat string?

查看:50
本文介绍了如何编写多行错误格式字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为 vim-opencl 插件编写 OpenCL 语法检查器.OpenCL 编译器对输出错误做了一些奇怪的格式化.有两种类型的错误.

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.

我使用 syntastic 作为通用语法检查器.现在我有这样的代码:

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"

或者至少像这样:

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. Updated errorformat and expectations

推荐答案

我不知道有什么有用的方法来测试这个,但你也需要用反斜杠来转义空格.

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

我也可能在 %C 之后放置一个 -space,以便它们只匹配以空格开头的行.

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

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

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.

祝你好运.

这篇关于如何编写多行错误格式字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆