Scala 解析器组合器与 Haskell 的 Parsec 相比如何?

发布于 2024-08-24 19:26:13 字数 1436 浏览 4 评论 0原文

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

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

发布评论

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

评论(2

︶ ̄淡然 2024-08-31 19:26:13

你有很多问题!

将parsec(这只是众多Haskell解析器组合器库之一)与parsec的Scala实现进行比较

没有人在这里进行比较,因为 Scala 代码相当新,但请检查文档:

请注意,Haskell 还有许多其他解析器组合器库,如果您对这种方法感兴趣,例如

与 Haskell 相比,Scala 的解析器组合器实现有哪些优点/缺点?

Haskell 代码已有十多年的历史,很好理解,并且有很多示例、大量文档和用户案例。 Scala 的东西相对较新。

Packrat 解析

Packrat 解析完全不同。最初的 Packrat 论文是用 Haskell 开发的,但后来变得更加广泛。

是否有网页或其他资源可以显示一种语言实现中的不同运算符/函数/DSL-sugar 如何映射到另一种语言的实现?

不,但那会很酷。然而,几乎所有(?)解析器组合器库都基于开创性的秒差距实现,因此它们与原始秒差距有很多共享。

You have many questions!

Comparing parsec (which is only one of many Haskell parser combinator libraries) to the Scala implementation of parsec

No one has made comparisons here, as the Scala code is fairly new, but check the documentation:

Note that Haskell has many other parser combinator libraries, if you're interested in this approach, e.g.

What are some strengths/weaknesses of Scala's implementation of parser combinators, vs Haskell's?

The Haskell code is more than a decade old, well understood, and there are many examples, lots of documentation and user cases. Scala's stuff is relatively new.

packrat parsing

packrat parsing is different entirely. The original packrat paper was developed in Haskell, but has since become more widespread.

Is there a webpage or some other resource that shows how different operators/functions/DSL-sugar from one language's implementation maps onto the other's?

No, but that would be cool. However, almost all(?) parser combinator libraries are based on the pioneering parsec implementation, so they share a lot with the original parsec.

寂寞笑我太脆弱 2024-08-31 19:26:13

还有以下技术报告:

Scala 中的解析器组合器

解析器组合器在 Haskell 等函数式编程语言中众所周知。在本文中,我们描述了如何在 Scala(一种函数式面向对象语言)中将它们实现为库。由于 Scala 灵活的语法,我们能够非常接近专用解析器生成器支持的 EBNF 表示法。对于外行来说,我们首先通过从头开始开发一个最小的库来解释解析器组合器的概念。然后,我们详细描述现有的 Scala 库,包括它对将变量绑定表示为语法一部分的支持。我们提供了几个现实的例子来说明我们库的实用性。

report.pdf (324K)

There's also the following technical report:

Parser combinators in Scala

Parser combinators are well-known in functional programming languages such as Haskell. In this paper, we describe how they are implemented as a library in Scala, a functional object-oriented language. Thanks to Scala's flexible syntax, we are able to closely approximate the EBNF notation supported by dedicated parser generators. For the uninitiated, we first explain the concept of parser combinators by developing a minimal library from scratch. We then turn to a detailed description of the existing Scala library, including its support for denoting variable binding as part of the syntax. We provide several realistic examples to illustrate the utility of our library.

report.pdf (324K)

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