0

我创建了一组任务,我想用这些任务编译用 MAD Pascal 编写的程序(用于 6502 处理器的 FreePascal 编译器)通常一切正常,但是我在处理“问题匹配器”时遇到了问题。我不知道为什么,它不想检测错误?我承认,我是第一次在 VSC 中使用任务。我浏览了许多不同的教程,但一切似乎都很好。我的“问题匹配器”配置

"problemMatcher": {
    "source": "Pascal compiler",
    "fileLocation": ["relative", "${workspaceFolder}"],
    "pattern": [
        {
            "regexp": "/^(.+)\\s\\((\\d+),(\\d+)\\):\\s(\\w+):(.+)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    ]
}

我测试了正则表达式的正确性(regex101),它与控制台中的内容正确匹配。控制台内容示例:

Mad Pascal Compiler version 1.6.6 [2021/06/08] for 6502
Compiling kret.pas
kret.pas (19,5) Error: Syntax error, ';' expected but 'identifier' found

有人可以向我指出我做错了什么吗?配置错误在哪里?我将非常感激 - 我非常想在“问题”窗口中看到编译错误:)

4

1 回答 1

0

我创建了一个 .bat 文件来模拟您的 Mad Pascal 编译器输出,如下所示:
“compiler_output.bat”的内容:

@echo off
echo Mad Pascal Compiler version 1.6.6 [2021/06/08] for 6502
echo Compiling kret.pas
echo kret.pas (19,5) Error: Syntax error, ';' expected but 'identifier' found

我在 .vscode 文件夹中创建了以下 tasks.json 文件:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Mockup compile by Pascal compiler",
      "type": "shell",
      "command": "${workspaceFolder}/compiler_output.bat",
      "args": [],
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "shared",
        "showReuseMessage": false,
        "clear": true
      },
      "problemMatcher": {
        "owner": "pascal",
        "fileLocation": [
          "relative",
          "${workspaceFolder}"
        ],
        "pattern": {
          "regexp": "^(.+)\\s\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s(\\w+):(.+)$",
          "file": 1,
          "location": 2,
          "severity": 3,
          "message": 4
        }
      },
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

我的文件夹树如下所示:
在此处输入图像描述

运行此任务后,我得到:
在此处输入图像描述

问题选项卡看起来如预期:
在此处输入图像描述

于 2021-12-14T20:06:38.893 回答