gpt4 book ai didi

macros - 我如何使用准引语在 Nemerle 中获得 AST?

转载 作者:行者123 更新时间:2023-12-02 05:43:46 25 4
gpt4 key购买 nike

我尝试使用 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'

我该如何解决这些问题?

最佳答案

您只需添加Nemerle.Compiler.dll 作为对您项目的引用。此外,一些更复杂的准引号只能在宏中使用。

using Nemerle.Compiler;
using System.Console;

macro Test()
{
def x = <[ while (true) WriteLine(4) ]>.ToString();
<[ WriteLine($x) ]>
}

关于macros - 我如何使用准引语在 Nemerle 中获得 AST?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10567164/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com