Scala解析器组合器与Haskell的Parsec相比如何? [英] How do Scala parser combinators compare to Haskell's Parsec?

查看:175
本文介绍了Scala解析器组合器与Haskell的Parsec相比如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经读过哈斯克尔分析器组合器(在Parsec中)可以解析上下文敏感的语法。对于Scala解析器组合器,这也是如此吗?如果是这样,这是入(又名>>)功能是什么?



Scala的解析器组合器的实现有哪些优势/弱点,vs Haskell的?他们接受同一类语法吗?是否更容易产生错误信息或其他有用的东西?



Packrat解析(在Scala 2.8中引入)如何适合这张图片?



是否有网页或其他资源显示来自一种语言实现的不同操作符/函数/ DSL糖如何映射到另一种语言的操作符?




比较parsec(这是唯一的一个Haskell解析器组合库中的一个)到parsec的Scala实现


这里没有人进行比较,因为Scala代码是公平的新的,但检查文档:


  • http://hackage.haskell.org/package/parsec

  • http://www.scala-lang.org/api/current/index.html#scala.util.parsing.combinator.Parsers


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






    Haskell的代码已经有十多年的历史了,我们很清楚,Haskell的代码已经超过十年了,有很多例子,大量的文档和用户案例。


    packrat解析




    packrat解析完全不同。最初的 packrat paper 是在Haskell中开发的,但后来变得更加广泛的。



    是否有网页或其他资源显示来自一种语言实现的不同运算符/函数/ DSL糖如何映射到其他的?


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


    I have read that Haskell parser combinators (in Parsec) can parse context sensitive grammars. Is this also true for Scala parser combinators? If so, is this what the "into" (aka ">>") function is for?

    What are some strengths/weaknesses of Scala's implementation of parser combinators, vs Haskell's? Do they accept the same class of grammars? Is it easier to generate error messages or do other miscellaneous useful things with one or the other?

    How does packrat parsing (introduced in Scala 2.8) fit into this picture?

    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?

    解决方案

    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.

    这篇关于Scala解析器组合器与Haskell的Parsec相比如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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