如何在Scala中打印展开的宏? [英] How do I print an expanded macro in Scala?

查看:76
本文介绍了如何在Scala中打印展开的宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Scala中编写宏,但是当我调用它时,我收到一条错误消息,提示"Double not not parameters".显然,宏如何构建AST有点问题.那我怎么看扩展的宏呢?有没有办法在运行时调用宏实现?

I am writing a macro in Scala, but when I call it I get an error message saying "Double does not take parameters". Clearly there is something wrong with how the macro builds the AST. So how can I see the expanded macro? Is there a way to call the macro implementation at runtime?

推荐答案

为编译器提供-Ymacro-debug-lite-Ymacro-debug-verbose选项.

Provide -Ymacro-debug-lite or -Ymacro-debug-verbose option to the compiler.

在我的头上,打印的AST的报废行为由-Yshow-trees-compact-Yshow-trees-stringified-Xprint-types-uniqid-Yshow-symkinds控制.您可以通过运行scala -Xscala -Y(或在

Off the top of my head, detalization of printed ASTs is governed by -Yshow-trees-compact, -Yshow-trees-stringified, -Xprint-types, -uniqid and -Yshow-symkinds. You can find other gems by running scala -X and scala -Y (or inspecting the sources of scala settings at https://github.com/scala/scala/blob/2.10.x/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala).

尽管本质上是一个宏,但它却具有自己的跟踪机制,可以由-Yreify-copypaste-Yreify-debug进行配置.

Also, despite being essentially a macro, reification has its own tracing mechanism that can be configured by -Yreify-copypaste and -Yreify-debug.

这篇关于如何在Scala中打印展开的宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆