Abstract
We present a novel but remarkably simple formulation of formal language grammars in Haskell as functions mapping a record of pro- duction parsers to itself. Thus formulated grammars are first-class objects, composable and reusable. We also provide a simple parser implementation for them, based on an improved packrat algorithm. In order to make the grammar manipulation code reusable, we introduce a set of type classes mirroring the existing type classes from Haskell base library, but whose methods have rank-2 types.
- John W Backus. 1959. The syntax and semantics of the proposed international algebraic language of the Zurich ACM-GAMM conference. Proceedings of the International Comference on Information Processing, 1959 (1959).Google Scholar
- Mario Blažević. 2013. Adding structure to monoids. ACM SIGPLAN NOTICES 48, 12 (2013), 37–45. Google Scholar
Digital Library
- Mario Blažević. 2013. monoid-subclasses. http://hackage.haskell.org/package/ monoid-subclasses . (2013).Google Scholar
- Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. 2009. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming 19, 05 (2009), 509–543. Google Scholar
Digital Library
- Noam Chomsky. 1956. Three models for the description of language. IRE Transactions on information theory 2, 3 (1956), 113–124.Google Scholar
Cross Ref
- Nils Anders Danielsson. 2010. Total Parser Combinators. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP ’10) . ACM, New York, NY, USA, 285–296. DOI: Google Scholar
Digital Library
- Edsko de Vries and Andres Löh. 2014. True Sums of Products. In Proceedings of the 10th ACM SIGPLAN Workshop on Generic Programming (WGP ’14) . ACM, New York, NY, USA, 83–94. DOI: Google Scholar
Digital Library
- Dominique Devriese. 2010. The grammar-combinators package. http://hackage. haskell.org/package/grammar-combinators . (2010).Google Scholar
- Dominique Devriese and Frank Piessens. 2011. Explicitly Recursive Grammar Combinators: A Better Model for Shallow Parser DSLs. In Proceedings of the 13th International Conference on Practical Aspects of Declarative Languages (PADL’11) . Springer-Verlag, Berlin, Heidelberg, 84–98. http://dl.acm.org/citation.cfm?id= 1946313.1946326 Google Scholar
Digital Library
- Dominique Devriese and Frank Piessens. 2012. Finally tagless observable recursion for an abstract grammar model. Journal of Functional Programming 22, 06 (2012), 757–796. Google Scholar
Digital Library
- Dominique Devriese, Ilya Sergey, Dave Clarke, and Frank Piessens. 2013. Fixing idioms: a recursion primitive for applicative DSLs. In Proceedings of the ACM SIGPLAN 2013 workshop on Partial evaluation and program manipulation . ACM, 97–106. Google Scholar
Digital Library
- Mathias Doenitz. 2010. A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions. GitHub. (2010). https://github. com/sirthias/pegdown .Google Scholar
- Jay Earley. 1970. An efficient context-free parsing algorithm. Commun. ACM 13, 2 (1970), 94–102. Google Scholar
Digital Library
- Levent Erkök and John Launchbury. 2000. Recursive monadic bindings. In ACM SIGPLAN Notices , Vol. 35. ACM, 174–185. Google Scholar
Digital Library
- Levent Erkök and John Launchbury. 2002. A recursive do for Haskell. In Proceedings of the 2002 ACM SIGPLAN workshop on Haskell . ACM, 29–37. Google Scholar
Digital Library
- Bryan Ford. 2002. Packrat parsing:: simple, powerful, lazy, linear time, functional pearl. In ACM SIGPLAN Notices, Vol. 37. ACM, 36–47. Google Scholar
Digital Library
- Bryan Ford. 2004. Parsing expression grammars: a recognition-based syntactic foundation. SIGPLAN Not. 39, 1 (2004), 111–122. DOI: Google Scholar
Digital Library
- Olle Fredriksson. 2011. The Grempa package. http://hackage.haskell.org/package/ Grempa . (2011).Google Scholar
- Olle Fredriksson. 2014. The Earley package. http://hackage.haskell.org/package/ Earley . (2014).Google Scholar
- Robert Grimm. 2004. Practical packrat parsing. Technical Report. Dept. of Computer Science, New York University.Google Scholar
- Robert Grimm. 2006. Better extensibility through modular syntax. In ACM SIGPLAN Notices , Vol. 41. ACM, 38–51. Google Scholar
Digital Library
- Anastasia Izmaylova, Ali Afroozeh, and Tijs van der Storm. 2016. Practical, general parser combinators. In Proceedings of the 2016 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation . ACM, 1–12. Google Scholar
Digital Library
- Stephen C. Johnson. 1975. Yacc: Yet another compiler-compiler. Vol. 32. Bell Laboratories Murray Hill, NJ.Google Scholar
- Daan Leijen and Erik Meijer. 2001. Parsec: Direct style monadic parser combinators for the real world . Technical Report. Department of Computer Science, Utrecht University.Google Scholar
- Conor McBride. 2011. Functional pearl: Kleisli arrows of outrageous fortune. Journal of Functional Programming (to appear) (2011).Google Scholar
- John Meacham. 2006. The Frisby package. http://hackage.haskell.org/package/ frisby . (2006).Google Scholar
- Matthew Might, David Darais, and Daniel Spiewak. 2011. Parsing with derivatives: a functional pearl. In ACM SIGPLAN notices, Vol. 46. ACM, 189–195. Google Scholar
Digital Library
- Bruno C d S Oliveira and Andres Löh. 2013. Abstract syntax graphs for domain specific languages. In Proceedings of the ACM SIGPLAN 2013 workshop on Partial evaluation and program manipulation . ACM, 87–96. Google Scholar
Digital Library
- Roman R Redziejowski. 2009. Mouse: from parsing expressions to a practical parser. In Concurrency Specification and Programming Workshop. Citeseer.Google Scholar
- S Doaitse Swierstra. 2009. Combinator parsing: A short tutorial. In Language Engineering and Rigorous Software Development . Springer, 252–300. Google Scholar
Digital Library
- Marcos Viera, Doaitse Swierstra, and Atze Dijkstra. 2012. Grammar fragments fly first-class. In Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications . ACM, 5. Google Scholar
Digital Library
- Marcos Viera, S. Doaitse Swierstra, and Eelco Lempsink. 2008. Haskell, Do You Read Me?: Constructing and Composing Efficient Top-down Parsers at Runtime. SIGPLAN Not. 44, 2 (Sept. 2008), 63–74. DOI: Google Scholar
Digital Library
- Philip Wadler. 1985. How to Replace Failure by a List of Successes. In Proc. Of a Conference on Functional Programming Languages and Computer Architecture . Springer-Verlag New York, Inc., New York, NY, USA, 113–128. http://dl.acm.org/ citation.cfm?id=5280.5288 Google Scholar
Digital Library
- Alexey Rodriguez Yakushev, Stefan Holdermans, Andres Löh, and Johan Jeuring. 2009. Generic programming with fixed points for mutually recursive datatypes. In ACM SIGPLAN Notices, Vol. 44. ACM, 233–244. Google Scholar
Digital Library
Index Terms
Packrats parse in packs
Recommendations
Packrats parse in packs
Haskell 2017: Proceedings of the 10th ACM SIGPLAN International Symposium on HaskellWe present a novel but remarkably simple formulation of formal language grammars in Haskell as functions mapping a record of pro- duction parsers to itself. Thus formulated grammars are first-class objects, composable and reusable. We also provide a ...
Packrat parsing:: simple, powerful, lazy, linear time, functional pearl
Packrat parsing is a novel technique for implementing parsers in a lazy functional programming language. A packrat parser provides the power and flexibility of top-down parsing with backtracking and unlimited lookahead, but nevertheless guarantees ...
Packrat parsing:: simple, powerful, lazy, linear time, functional pearl
ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programmingPackrat parsing is a novel technique for implementing parsers in a lazy functional programming language. A packrat parser provides the power and flexibility of top-down parsing with backtracking and unlimited lookahead, but nevertheless guarantees ...







Comments