在 Visual Studio 中构建时出现 fsyacc 错误

发布于 2025-01-06 11:23:23 字数 1011 浏览 1 评论 0原文

我在 Visual Studio 中使用 fsyacc(使用解析语言入门模板),但生成输出不显示发生错误的行/列(仅:fsyacc 退出,代码为 1)。我必须从命令提示符进行构建才能获取此信息,这在某种程度上抵消了 VS 集成的好处。

有没有办法在输出窗口中显示它?

编辑

以下是输出窗口中未显示的一些错误示例。

Parser.fsy(74,4): error: parse error

building tables
FSYACC: error FSY000: NonTerminal 'query' has no productions

是成功的输出,也很高兴看到:

building tables
computing first function...time: 00:00:00.1318603
building kernels...time: 00:00:00.1027372
building kernel table...time: 00:00:00.0533044
computing lookahead relations.............................
..............time: 00:00:00.0517415
building lookahead table...time: 00:00:00.0207993
building action table...state 29: shift/reduce error on AS
state 49: shift/reduce error on OR
state 49: shift/reduce error on AND
...
time: 00:00:00.1457792
building goto table...time: 00:00:00.0035636
returning tables.
39 shift/reduce conflicts
62 states
11 nonterminals
41 terminals
46 productions
#rows in action table: 62

I'm using fsyacc within Visual Studio (using the Parsed Language Starter template), but the build output doesn't show the line/column where the error occured (only: fsyacc exited with code 1). I have to build from the command prompt to get this information, somewhat negating the benefit of VS integration.

Is there a way to show this in the output window?

EDIT

Here are some examples of errors that aren't shown in the output window.

Parser.fsy(74,4): error: parse error

and

building tables
FSYACC: error FSY000: NonTerminal 'query' has no productions

Here's success output that would be nice to see also:

building tables
computing first function...time: 00:00:00.1318603
building kernels...time: 00:00:00.1027372
building kernel table...time: 00:00:00.0533044
computing lookahead relations.............................
..............time: 00:00:00.0517415
building lookahead table...time: 00:00:00.0207993
building action table...state 29: shift/reduce error on AS
state 49: shift/reduce error on OR
state 49: shift/reduce error on AND
...
time: 00:00:00.1457792
building goto table...time: 00:00:00.0035636
returning tables.
39 shift/reduce conflicts
62 states
11 nonterminals
41 terminals
46 productions
#rows in action table: 62

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨后彩虹 2025-01-13 11:23:23

我没有使用 Parsed Language Starter 模板,而是通过使用 VS 项目属性中的 Build Events 中的 Pre-build event 来构建解析器/词法分析器:

fslex "$(ProjectDir)Lexer.fsl"
fsyacc --module Grammar "$(ProjectDir)Grammar.fsy"

这不是很理想,因为我必须在 Path 环境变量中设置 fsyacc/fslex。每当我不想重建解析器/词法分析器时,我必须在 fsproj 文件中注释掉以下部分:

<PropertyGroup>
  <PreBuildEvent>fslex "$(ProjectDir)Lexer.fsl"
                 fsyacc --module Grammar "$(ProjectDir)Grammar.fsy"
  </PreBuildEvent>
</PropertyGroup>

但是,获胜点很明显。我们在 stdout 中拥有所有消息,包括错误和成功输出,这方便调试。

Instead of using Parsed Language Starter template, I build parser/lexer by using Pre-build event in Build Events from VS Project Properties:

fslex "$(ProjectDir)Lexer.fsl"
fsyacc --module Grammar "$(ProjectDir)Grammar.fsy"

It is not very desirable since I have to set fsyacc/fslex in Path environment variable. Whenever I don't want to rebuild parser/lexer, I have to comment out the following part in fsproj file:

<PropertyGroup>
  <PreBuildEvent>fslex "$(ProjectDir)Lexer.fsl"
                 fsyacc --module Grammar "$(ProjectDir)Grammar.fsy"
  </PreBuildEvent>
</PropertyGroup>

However, the winning point is clear. We have all messages including errors and success output in stdout which is convenient for debugging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文