Antlr4 C#的目标和生成文件的输出路径 [英] Antlr4 C# targets and output path of generated files

查看:1514
本文介绍了Antlr4 C#的目标和生成文件的输出路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与Antlr3语法文件一个C#的解决方案,我试图升级到Anltr4。原来,语法是比较容易的部分(它变得更好,三分之一的大小!)。生成横空出世解析器是棘手的部分。

I have a C# solution with an Antlr3 grammar file, and I'm trying to upgrade to Anltr4. It turns out the grammar was the easy part (it became better, and one third the size!). Generating the parser turned out to be the tricky part.

在旧的解决方案,我只是跑AntlrWorks更新词法和语法分析器的.cs文件时语法文件改变。词法分析器和语法分析器都在同一个项目的语法让周围的解析器框架可以使直接利用它们直接计入。

In the old solution I merely ran AntlrWorks to update the lexer and parser .cs files when the grammar file changed. The lexer and parser were included directly in the same project as the grammar so the framework around the parser could make use of them directly.

随着Antlr4目标C#我注意到(至少由默认值)所产生的分析器的C#类的输出路径处于中间目录,例如obj\Debug。这意味着我不能在同一个项目中直接使用的解析器。我是不是应该,如果我想在我的SLN可用生成的源来改变输出路径?不要我希望它在我的SLN?

With the Antlr4 targets for C# I noticed that (at least by default) the output path of the generated Parser C# classes is in the intermediate directory, e.g. obj\Debug. This means I can't use the parser directly in the same project. Am I supposed to change the output path if I want the generated source usable in my sln? Don't I want it in my sln?

我试图使一个单独的项目解析器产生,即包含一个项目的只有的语法文件。当这个项目使用Antlr4目标建成,产生的组件可从需要解析器类项目引用。但是,如果这个项目是包含在解决方案,我还没有得到在Visual Studio中的任何智能感知,因为它立足其加载的项目源文件的智能感知,所以还是不太有用。我能得到的唯一方式,正常工作是建立再卸载解析器项目,并有其他的项目中引用它作为一个汇编文件,而不是一个项目。

I tried making a separate project for the parser generation, that is, a project containing only the grammar file. When this project is built using the Antlr4 targets, the resulting assembly can be referenced from projects needing the parser classes. However, if this project is included in the solution I still don't get any intellisense in visual studio since it bases its intellisense on source files for loaded projects, so it is still not quite usable. The only way I could get it working properly was to build then unload the parser project, and have other projects reference it as an assembly file rather than a project.

编辑:

望ANTLR利益名单后,我发现这个线程表明随着智能感知问题可能是Resharpers故障。如果是这样的话,那么我的问题是在于如何在我的解决方案同时使用Antlr4和ReSharper的保持?
https://groups.google.com/forum/#!topic/antlr-讨论/ QSuJXphaBDg

After looking on the antlr-interest list I found this thread indicating that the problem with intellisense may be Resharpers fault. If this is the case, then my question is rather how to keep using both Antlr4 and Resharper in my solution? https://groups.google.com/forum/#!topic/antlr-discussion/QSuJXphaBDg

推荐答案

您遇到一个已知的bug与ReSharper的。的ANTLR 3和ANTLR 4℃#构建整合是可靠的,并使用该微软与其他语言和代码生成任务使用长期建立的模式。你的选择是:

You are encountering a known bug with ReSharper. The ANTLR 3 and ANTLR 4 C# build integration is reliable, and uses long-established patterns that Microsoft uses with other languages and code generation tasks. Your options are:


  1. 停止使用ReSharper的

  2. 获得ReSharper的作者,以解决缺乏支持此功能,或

  3. 修改ANTLR 4的目标来解决在ReSharper的限制,这会引入其他问题到可能会或可能不会对你的使用可以接受的版本。

选项1肯定是最便宜,最有可能为您的项目长期可靠的支持。

Option 1 is certainly the least expensive, and most likely to provide reliable long-term support for your projects.

这篇关于Antlr4 C#的目标和生成文件的输出路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆