Ruby 有类似于 Perl 6 语法的插件吗?

发布于 2024-08-09 00:57:11 字数 80 浏览 5 评论 0原文

多年来,Perl 一直是我首选的编程语言工具之一。 Perl 6 语法看起来是一个很棒的语言功能。我想知道是否有人为 Ruby 开始了类似的事情。

Perl has been one of my go-to programming language tools for years and years. Perl 6 grammars looks like a great language feature. I'd like to know if someone has started something like this for Ruby.

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

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

发布评论

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

评论(3

苏佲洛 2024-08-16 00:57:11

不知道 Ruby 是否有类似的情况。

然而 Perl5 也有类似的东西,请参阅 Regexp::Grammars< /a>

Don't know of anything similar for Ruby.

However there is something similar for Perl5, see Regexp::Grammars

苦行僧 2024-08-16 00:57:11

不。而且,由于 Perl6 语法是一种语言功能,而 Ruby 不允许扩展该语言,因此实际上不可能在“插件”中实现此功能。

然而,Ruby 有许多库可以实现不同类型的解析或语法系统。标准库已经包含 racc,它是一个 LALR(1) 解析器生成器(与古老的 yacc 相当并在某种程度上兼容)。然后是 ANTLR 解析器生成器,它有一个 Ruby 后端(尽管我不确定它是否真的有效)。

Ruby 中最接近 Perl6 语法的是 Ruby-OMeta 项目(请确保也看看 Ryan Davis 的分支),不幸的是它仍在开发中。 (或者更确切地说,不再处于积极开发中。)

因此,保留实际存在的内容,我建议您查看 语法项目Treetop

No. And, since Perl6 grammars are a language feature, and Ruby doesn't allow the language to be extended, it is actually impossible to implement this in an "addon".

However, there are numerous libraries for Ruby which implement different kinds of Parsing or Grammar Systems. The standard library already contains racc, which is an LALR(1) parser generator (comparable to and somewhat compatible with the venerable yacc). Then there is the ANTLR parser generator, which has a Ruby backend (although I am not sure whether that actually works).

The closest thing to Perl6 grammars in Ruby would be the Ruby-OMeta project (make sure to also take a look at Ryan Davis's fork), which unfortunately ist still under development. (Or rather, no longer under active development.)

So, keeping to stuff that actually exists, I recommend you take a look at the Grammar project and Treetop.

洒一地阳光 2024-08-16 00:57:11

If you want to use actual Perl 6 grammars in Ruby, your best bet is going to be Cardinal, a ruby compiler on Parrot. It's currently unfinished and VERY SLOW, but I'm quite hopeful about it being a viable ruby implementation eventually. It's currently mostly-inactive, pending some infrastructure changes in Parrot to support improved parsing speed and additional features.

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