我正在尝试在我的 Mac 上为 Mono C# 编译器设置构建环境。目的是扩展研究项目的语法。我一直在努力设置构建。我确信答案很简单,但到目前为止我找不到任何有用的信息。
我更愿意在 MonoDevelop 中有一个解决方案,语法是其中的一部分,并且在项目编译时考虑语法的任何更改。
到目前为止,我发现的解决方案文件包括一个 cs-parser.cs 文件,该文件在我从项目页面获得的源代码中不存在。我猜这个文件是在 cs-parser.jay 上运行解析器生成器的结果,但我找不到有关如何将其设置为构建步骤的信息(或为此手动运行解析器生成器)
有关如何使用 mcs 的演练教程的链接将不胜感激,或者提供简单的逐步指导
最佳答案
来自 README.makefiles :
If your program has 'built sources', that is, source files generated from other files (say, generated by jay), define a variable called BUILT_SOURCES and do not list the sources in $(PROGRAM).sources:
======================================== PROGRAM = myprogram.exe LOCAL_MCS_FLAGS = /r:System.Xml.dll BUILT_SOURCES = parser.cs CLEAN_FILES = y.output include ../build/executable.make parser.cs: parser.jay $(topdir)/jay/jay $< > $@ ========================================
executable.make will automatically delete the $(BUILT_SOURCES) files on 'make clean'. Since this situation is a common occurrence and jay happens to leave behind y.output files, you can also define a variable called $(CLEAN_FILES) that lists extra files to be deleted when 'make clean' is called. (That's in addition to your executable and the built sources).
因此,cs-parser.cs 正是以这种方式制作的:
[mono] ~/custom/MONO/mono/mcs/jay @ make
/usr/bin/make all-local
make[1]: Entering directory `/home/sehe/custom/MONO/mono/mcs/jay'
make[1]: Nothing to be done for `all-local'.
make[1]: Leaving directory `/home/sehe/custom/MONO/mono/mcs/jay'
[mono] ~/custom/MONO/mono/mcs/jay @ cd ../mcs
[mono] ~/custom/MONO/mono/mcs/mcs @ make
/usr/bin/make all-local
make[1]: Entering directory `/home/sehe/custom/MONO/mono/mcs/mcs'
./../jay/jay -cv < ./../jay/skeleton.cs cs-parser.jay > jay-tmp.out && mv jay-tmp.out cs-parser.cs
./../jay/jay: 9 shift/reduce conflicts.
(减少输出)
它在 cs-parser.cs 中产生了 10470 行不可由用户维护的代码
替代方案,跳出框框思考:
只是一个想法,你能不使用预处理 c# -> c# 转换器吗?这具有额外的好处,您可以使其与任何 C# 工具/编译器一起使用。考虑使用
#line
pragmas 映射回调试信息的原始源此外,还有许多用于 C#/.NET 的面向方面的代码编织器。您可能会利用 1. 和 2. 的组合来获得您想要的功能?
关于c# - Jay,单声道 C# 编译器和更改语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7944695/