[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA] New package: parsec

From: Junpeng Qiu
Subject: [ELPA] New package: parsec
Date: Tue, 25 Oct 2016 16:17:29 -0400

Hello Emacs,

I've added a new package "parsec" to GNU ELPA (hoping I've not messed up anything). This is a parser combinator library for Emacs Lisp, similar to Haskell's parsec. The work is inspired by John's [emacs-pl]. The main repo of parsec is on GitHub: https://github.com/cute-jumper/parsec.el.

John's [emacs-pl] is awesome, but I found following problems when I tried to use it:
- it only contains a very limited set of combinators
- Some of its functions (combinators) have different behaviors than their Haskell counterparts
- It can't show error messages when parsing fails.

The new library, parsec, contains most of the parser combinators in "Text.Parsec.Combinator" (I'm adding more gradually), and I tried my best to keep their behavior the same as their Haskell counterparts so that programmer with Haskell background could easily use the library. You can see the table listing all of the functions/macros in the README. It's a long list so I'll skip it here. Parsec also comes with a simple error handling mechanism, which may be improved in the future.

To give a short example, the following code extract the "hello" from the comment:

  (parsec-with-input "/* hello */"
    (parsec-string "/*")
    (parsec-many-till-as-string (parsec-any-ch)
                                 (parsec-string "*/"))))

More examples can be found at https://github.com/cute-jumper/parsec.el/tree/master/examples.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]