Macros 如何使用准引号在Nemerle中获得AST?
我尝试使用Nemerle的准引号在Nemerle中获得一个简单代码片段的AST 这是我尝试的代码:Macros 如何使用准引号在Nemerle中获得AST?,macros,metaprogramming,abstract-syntax-tree,quotations,nemerle,Macros,Metaprogramming,Abstract Syntax Tree,Quotations,Nemerle,我尝试使用Nemerle的准引号在Nemerle中获得一个简单代码片段的AST 这是我尝试的代码: def ast() : void { System.Console.WriteLine(<["Test"]>) } 如何解决这些问题?您只需添加Nemerle.Compiler.dll作为项目的参考。此外,一些更复杂的准引号只能在宏中使用 using Nemerle.Compiler; using System.Console; macro Test() { def x
def ast() : void {
System.Console.WriteLine(<["Test"]>)
}
如何解决这些问题?您只需添加Nemerle.Compiler.dll作为项目的参考。此外,一些更复杂的准引号只能在宏中使用
using Nemerle.Compiler;
using System.Console;
macro Test()
{
def x = <[ while (true) WriteLine(4) ]>.ToString();
<[ WriteLine($x) ]>
}
使用Nemerle.Compiler;
使用系统控制台;
宏测试()
{
def x=.ToString();
}
准引号用于宏中。它们需要编译器的上下文。创建宏库项目,并在其中使用准引用
using Nemerle.Compiler;
using System.Console;
macro Test()
{
def x = <[ while (true) WriteLine(4) ]>.ToString();
<[ WriteLine($x) ]>
}