我尝试使用Nemerle的准引号,在Nemerle中获得一个简单代码片段的AST。
这是我尝试过的代码:
def ast() : void {
System.Console.WriteLine(<["Test"]>)
}我在IdeOne (ncc 0.9.3)上运行它,得到以下错误:
prog.nem:2:30:2:36: error: unbound name `Literal.String'
prog.nem:2:30:2:36: error: unbound name `PExpr.Literal'如何解决这些问题?
发布于 2012-05-13 10:50:05
您只需要将Nemerle.Compiler.dll作为引用添加到您的项目中。此外,一些更复杂的准引号只能在宏中使用。
using Nemerle.Compiler;
using System.Console;
macro Test()
{
def x = <[ while (true) WriteLine(4) ]>.ToString();
<[ WriteLine($x) ]>
}发布于 2012-05-14 04:08:38
准引号旨在用于宏中。他们需要一个编译器的上下文。创建一个宏库项目,并在其中使用准引用。
https://stackoverflow.com/questions/10567164
复制相似问题