Monadic parsing in Haskell

Monadic parsing in Haskell
复制标题

Haskell 中的 Monadic 解析

DOI:
10.1017/s0956796898003050
复制
发表时间:
1998
影响因子:
1.1
通讯作者:
Erik Meijer
Erik Meijer
中科院分区:
计算机科学2区
文献类型:
--
作者:
Graham Hutton;Erik Meijer

文献摘要

被引文献

相似文献

本文是针对Haskell定义递归血统解析器的教程。本着一站式购物的精神,该纸将三个区域的材料结合在一起。这三个领域是功能解析器(Burge,1975; Wadler,1985; Hutton,1992; Fokker,1995年),使用单子来构建功能程序(Wadler,1990,1992a,1992b),以及用于Monadicax的使用Sonadicax Haskell的计划(Jones,1995; Peterson等,1996)。更具体地说,该论文显示了如何使用Haskell中的DO指定来定义Monadic解析器。当然,手动定义的递归下降解析器缺乏机器产生的自下而上解析器的效率(Aho等,1986; Mogensen,1993; Gill和Marlow,1995)。但是,对于许多研究应用,简单的递归下降解析器就足够了。此外,虽然解析器发生器通常提供一组固定的组合器来描述语法,但此处描述的方法是完全可扩展的:解析器是一流的值,我们拥有Haskell的全部功能,可用于为特殊应用定义新组合。该方法也很好地说明了功能编程的优雅性。
This paper is a tutorial on defining recursive descent parsers in Haskell. In the spirit of one-stop shopping, the paper combines material from three areas into a single source. The three areas are functional parsers (Burge, 1975; Wadler, 1985; Hutton, 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler, 1990, 1992a, 1992b), and the use of special syntax for monadic programs in Haskell (Jones, 1995; Peterson et al., 1996). More specifically, the paper shows how to define monadic parsers using do notation in Haskell. Of course, recursive descent parsers defined by hand lack the efficiency of bottom-up parsers generated by machine (Aho et al., 1986; Mogensen, 1993; Gill and Marlow, 1995). However, for many research applications, a simple recursive descent parser is perfectly sufficient. Moreover, while parser generators typically offer a fixed set of combinators for describing grammars, the method described here is completely extensible: parsers are first-class values, and we have the full power of Haskell available to define new combinators for special applications. The method is also an excellent illustration of the elegance of functional programming.