2017-01-29 4 views
0

私のRegexでrustcのビルド出力を解析する際に問題が発生しています。Visual Studioコードのタスクの正規表現がビルドエラーの出力をキャプチャしない

出力は、現時点では

Compiling svd2rust v0.2.1 (file:///C:/trust/svd2rust) 
error: expected one of `=>`, `@`, `if`, or `|`, found `Some` 
    --> src\main.rs:56:9 
    | 
56 |   Some("all") => 
    |   ^^^^ 
error: aborting due to previous error 
error: Could not compile `svd2rust`. 
To learn more, run the command again with --verbose. 

私の仕事のように見えますが、以下のようになります。

{ 
    "version": "0.1.0", 
    "command": "cargo", 
    "isShellCommand": true, 
    "args": ["build"], 
    "problemMatcher": { 
     "owner": "build", 
     "fileLocation": ["relative", "${workspaceRoot}"], 
     "pattern": { 
      "regexp": "(error):(.*)\\s+-->\\s+(.*):(\\d+):(\\d+)", 
      "file": 3, 
      "line": 4, 
      "column": 5, 
      "severity": 1, 
      "message": 2 
     } 
    } 
} 

According to regex101正規表現が適切なセクションと一致する必要がありますように、それが見えます。

+0

を私が知っているから、 '\のS'はCRをキャッチしない場合があります。 '\ s'を' [\ s \ r] '([demo](https://regex101.com/r/pgGndx/1))に置き換えてみてください。 –

+0

'。*'の代わりに '。*?'(非貪欲なマッチ)を使ってみてください。また、ドット '.'は改行にマッチしないかもしれません。 – kennytm

答えて

0

VS Code documentationによれば、マルチライン問題マッチャーが必要です。これは機能するかもしれません。私はそれをテストしていない:

{ 
    "version": "0.1.0", 
    "command": "cargo", 
    "isShellCommand": true, 
    "args": ["build"], 
    "problemMatcher": { 
     "owner": "build", 
     "fileLocation": ["relative", "${workspaceRoot}"], 
     "pattern": [{ 
      "regexp": "(error):(.*)", 
      "severity": 1, 
      "message": 2 
     },{ 
      "regexp": "-->\\s+([^:]*):(\\d+):(\\d+)", 
      "file": 1, 
      "line": 2, 
      "column": 3 
     }] 
    } 
} 
0

ラストv1.20.0の正しい正規表現:

"pattern": [{ 
    "regexp": "(error(?:\\[E\\d{4}\\])?|warning):\\s(.*)", 
    "severity": 1, 
    "message": 2 
},{ 
    "regexp": "-->\\s+([^:]*):(\\d+):(\\d+)", 
    "file": 1, 
    "line": 2, 
    "column": 3 
}] 
関連する問題