我在 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
最佳答案
我没有使用 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
中拥有所有消息,包括错误和成功输出,这方便调试。
关于visual-studio-2010 - 在 Visual Studio 中构建时出现 fsyacc 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9332364/