Acessibilidade / Reportar erro

Mímico: a monadic combinator parser generator

Abstract

This article describes a compiler generator, called Mímico, that outputs code based on the use of monadic combinators. Mímico can parse infinite look-ahead and left-recursive context free grammars and defines a scheme for handling the precedence and associativity of binary infix operators, and monadic code in semantic rules. Mímico provides an easy way of specifying the syntax and semantics of languages, and generates readable output in the form of Haskell programs. The article presents Mímico's general principles, its formal syntax and semantics, its limitations and illustrative examples of its behaviour.

Compiler generation; monadic parsing


Full text available only in PDF format

Mímico: a monadic combinator parser generator

Carlos CamarãoI; Lucilia FigueiredoII; Hermann RodriguesIII

IUniversidade Federal de Minas Gerais, 31270-010 - Belo Horizonte, MG-Brasil, camarao@dcc.ufmg.br

IIUniversidade Federal de Ouro Preto 35100-000 -Ouro Preto, MG-Brasil lucilia@dcc.ufmg.br

IIIUniversidade Federal de Minas Gerais 31270-010 - Belo Horizonte, MG-Brasil hennann@dcc.ufmg.br

ABSTRACT

This article describes a compiler generator, called Mímico, that outputs code based on the use of monadic combinators. Mímico can parse infinite look-ahead and left-recursive context free grammars and defines a scheme for handling the precedence and associativity of binary infix operators, and monadic code in semantic rules. Mímico provides an easy way of specifying the syntax and semantics of languages, and generates readable output in the form of Haskell programs. The article presents Mímico's general principles, its formal syntax and semantics, its limitations and illustrative examples of its behaviour.

Keywords: Compiler generation, monadic parsing

  • [1] Ravi Sethi Alfred V. Aho and Jeffrey D. Ull-man. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1986.
  • [2] Richard Bird. Introduction to Functional Programming using Haskell. Prentice-Hall, 1998. 2nd ed.
  • [3] Carlos Camarão and Lucília Figueiredo. A Monadic Combinator Compiler Compiler. In Proc. SBLP'2001 (V Brazilian Symposium on Programming Languages), pages 64-79, 2001.
  • [4] M.T. Chakravarty. Lazy Lexing is Fast. In Fourth Fuji International Symposium on Functional and Logic Programming (LNCS 1722, Springer-Verlag), 1999.
  • [5] Andy Gill and Simon Marlow. Happy: The Parser Generator for Haskell. http://haskell.org/happy/, 2000.
  • [6] Graham Hutton. Higher-order functions for parsing. Journal of Functional Programming, 2:232-343, 1992.
  • [7] Graham Hutton and Erik Meijer. Monadic parser combinators. Tech. rep. NOTTCS-TR-96-4, 1996.
  • [8] P. Lee. Realistic Compiler Generation. MIT Press, 1989.
  • [9] Daan Leijen. Parsec. http://www.cs.ruu.nl/~daan/parsec.html.
  • [10] John R. Levine, Tony Mason, and Doug Brown. Lex & Yacc. O'Reilly k Associates, 1992.
  • [11] Alexandre Macedo and Hermano Moura. Investigating Compiler Generation Systems. In Proc. SBLP'2000 (IV Brazilian Symposium on Programming Languages), pages 259-266, 2000.
  • [12] Terence Parr and Russell Quong. Adding semantic and syntactic predicates to ll(k): pred-ll(k). In Proceeding of the International Conference on Compiler Construction, 1994.
  • [13] Terence Parr and Russell Quong. Antlr: A predictive-ll(k) parser generator. Software — Practice and Experience, 25(7):789-810, 1995.
  • [14] S.D. Swierstra. Parser Combinators, from Toys to Tools. In ACM SIGPLAN Haskell Workshop, pages 113-128, 2000.
  • [15] Simon Thompson. Haskell: The Craft of Functional Programming. Addison-Wesley, 1999. second edition.
  • [16] Philip Wadler. How to replace a failure with a list of successes. In Functional Programming Languages and Architecture, LNCS 201, pages 113-128, 1985.
  • [17] Philip Wadler. Comprehending Monads. Mathematical Structures in Computer Science, 2(4):461-493, 1990.
  • [18] Philip Wadler. Monads for Functional Programming. Computer and Systems Sciences, 118, 1992.

Publication Dates

  • Publication in this collection
    14 Sept 2004
  • Date of issue
    Nov 2003
Sociedade Brasileira de Computação Sociedade Brasileira de Computação - UFRGS, Av. Bento Gonçalves 9500, B. Agronomia, Caixa Postal 15064, 91501-970 Porto Alegre, RS - Brazil, Tel. / Fax: (55 51) 316.6835 - Campinas - SP - Brazil
E-mail: jbcs@icmc.sc.usp.br