emacs-devel
[Top][All Lists]
Advanced

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

Re: [ELPA] New package: parsec


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

Sorry. I seemed to paste the wrong URL for John's emacs-pl. Here you go:

[emacs-pl]: https://github.com/jwiegley/emacs-pl

Thanks,
-Junpeng

On Tue, Oct 25, 2016 at 4:17 PM, Junpeng Qiu <address@hidden> wrote:
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-try
                                 (parsec-string "*/"))))

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

Thanks,
-Junpeng


reply via email to

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