Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macros 如何使用准引号在Nemerle中获得AST?_Macros_Metaprogramming_Abstract Syntax Tree_Quotations_Nemerle - Fatal编程技术网

Macros 如何使用准引号在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

我尝试使用Nemerle的准引号在Nemerle中获得一个简单代码片段的AST

这是我尝试的代码:

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) ]>
}