scala.util.parsing.ast.Binders 应该如何使用?

发布于 2024-11-02 22:59:17 字数 227 浏览 5 评论 0原文

我目前正在 Scala 中实现一个小型编译器,当我进行上下文分析组件时,我发现了包 scala.util.parsing.ast 中的特征 Binders (我是使用 Scala 2.9 RC),已记录在解析时启用名称绑定。这听起来很有趣,我已经在谷歌上搜索了很多,但我仍然不知道如何使用它。虽然我当然能够让我的抽象语法源自 Binders,但我不知道如何从那里继续。网上有使用的例子吗?

I am currently implementing a small compiler in Scala and while I was doing the component for context analysis I discovered the trait Binders in package scala.util.parsing.ast (I am using Scala 2.9 RC), which is Documented to enable name binding during parse time. That sounds very interesting and I have been googling around a lot, but I still have no clue how to use it. While I am of course able to let my abstract syntax derrive from Binders I dont see how to proceed from there. Are there any examples of the usage on the net?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑白记忆 2024-11-09 22:59:17

通过谷歌搜索,我发现 此页面,这似乎是包含更多详细信息的文档的开发版本。不幸的是,我无法找到这些文档的在线(我的意思是,在源存储库之外)版本。

但我不确定您是否能在这个图书馆中找到您想要的东西。名称解析是一件相当微妙的事情,在解析过程中进行名称解析似乎是一个值得怀疑的想法。该库本身的文档强调它仅适用于名称解析相对简单的语言,否则可能无法扩展。此外,Scala 存储库中的解析示例都没有使用此类。

我会谨慎地避开这个未知领域,并在单独的后解析过程中设计绑定分析。

By googling a bit I found this page, which seems to be a development version of a documentation with more details. Unfortunately I was not able to find online (I mean, outside a source repository) version of these documentations.

I'm not sure however that you will find what you're looking for in this library. Name resolution is a rather delicate thing, and it smells like a questionable idea to do it during parsing. The documentation of this library itself highlights that it is only suitable for languages where the name resolution is relatively simple, and may not scale otherwise. Besides, none of the parsing examples in the Scala repository make use of this class.

I would cautiously avoid this uncharted territory, and design binding analysis in a separate post-parsing pass.

花辞树 2024-11-09 22:59:17

你不应该使用它。事实上,它最近已被弃用。


弃用候选版本:scala.parsing.ast

You're not supposed to use it. In fact, it has recently been deprecated.

See
deprecation candidate: scala.parsing.ast

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文