不能 运行 yacc 或 flex 命令 VS Code

Cant run yacc nor flex commands VS Code

我在 Visual Studio 代码中安装了 Lex Flex Yacc Bison 扩展,创建了一个示例项目,导航到终端中的文件夹,但是当我 运行 yacc -d syntax.y 时,终端无法识别 yacc 命令。第 1 行以 %{ 开头。似乎唯一有效的命令是 ls 列出当前目录中的文件。

yacc : The term 'yacc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was 
included, verify that the path is correct and try again.
At line:1 char:1
+ yacc -d syntax.y
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (Yacc:String) [], 
      CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Lex Flex Yacc Bison 扩展只为这些工具的输入文件提供语法高亮显示;它不包括工具本身。

在 Windows 上,获取它们的最简单方法可能是安装 Cygwin。 Cygwin 有 flexyaccbison。 Cygwin 没有 lex 的端口。我建议使用 flex 进行词法分析,使用 bison 进行语法分析,因为它们是 lexyacc.

的积极维护后继者

如果您正在使用 windows,您可以安装 devc++ 应用程序,因为我知道它支持 yacc 和 lex 文件,它会自动创建文件而不需要太多努力,但我不知道任何其他应用程序的扩展名visual studio 代码仅用于语法高亮显示。