Looking for parser generator library

1,060 views
Skip to first unread message

Roman Perepelitsa

unread,
Jan 28, 2012, 10:19:11 AM1/28/12
to clo...@googlegroups.com
I'm looking for a parser generator library. I stumbled upon fnparse, but unfortunately it doesn't work with clojure 1.3.

Roman Perepelitsa.

Richard Lyman

unread,
Jan 28, 2012, 12:51:34 PM1/28/12
to clo...@googlegroups.com
Have you looked at amotoen?

https://github.com/richard-lyman/amotoen

I'm not sure what your needs are...

-Rich

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Chris Perkins

unread,
Jan 28, 2012, 2:15:42 PM1/28/12
to clo...@googlegroups.com
Here is one I wrote a while ago.

https://github.com/grammati/imparsonate 

It's not "finished" (is open-source software ever really finished?), so I don't know whether it will do what need it to.

- Chris

Jack Moffitt

unread,
Jan 28, 2012, 2:21:10 PM1/28/12
to clo...@googlegroups.com
> I'm looking for a parser generator library. I stumbled upon fnparse, but
> unfortunately it doesn't work with clojure 1.3.

I ended up just using ANTLR and it works pretty well from Clojure.
Most of my time was spent on the grammar and implementation, not the
ANTLR integration bits.

I started from this example:

http://briancarper.net/blog/554/antlr-via-clojure

jack.

Roman Perepelitsa

unread,
Jan 28, 2012, 1:04:07 PM1/28/12
to clo...@googlegroups.com
Thanks, I didn't look at amotoen yet. Will do!

A library based on parser combinators would be ideal, something like parsec in haskell. Although if in clojure world people usually take a different approach, I'm open to trying it.

2012/1/28 Richard Lyman <richar...@gmail.com>

Lars Nilsson

unread,
Jan 29, 2012, 12:20:07 AM1/29/12
to clo...@googlegroups.com
On Sat, Jan 28, 2012 at 1:04 PM, Roman Perepelitsa
<roman.pe...@gmail.com> wrote:
> A library based on parser combinators would be ideal, something like parsec
> in haskell. Although if in clojure world people usually take a different
> approach, I'm open to trying it.

Two projects attempting to bring Parsec-style parsing (to some extent
anyway) to Clojure are

https://github.com/youngnh/parsatron
https://github.com/mmikulicic/clarsec

I couldn't say whether they're close enough to what you're looking for
or anything though.

Lars Nilsson

Roman Perepelitsa

unread,
Jan 29, 2012, 3:44:20 AM1/29/12
to clo...@googlegroups.com
Thanks for all the suggestions! They'll keep me going for a weekend.

Roman Perepelitsa.

Meikel Brandmeyer (kotarak)

unread,
Jan 30, 2012, 1:52:50 AM1/30/12
to clo...@googlegroups.com
Hi,

parsley by Christophe hasn't been mentioned, yet.

https://github.com/cgrand/parsley

Sincerely
Meikel

Evan Gamble

unread,
Feb 7, 2012, 5:12:41 AM2/7/12
to Clojure
fnparse has been forked by John Poplett and updated to work with
clojure 1.3.

On Clojars it's at https://clojars.org/org.clojars.jpoplett/fnparse.

On Github it's at https://github.com/John-Poplett/fnparse

- Evan

On Jan 28, 7:19 am, Roman Perepelitsa <roman.perepeli...@gmail.com>
wrote:

Roman Gonzalez

unread,
Feb 7, 2012, 5:46:42 PM2/7/12
to clo...@googlegroups.com
I released yesterday zetta-parser (http://github.com/van-clj/zetta-parser) through the van-clj group (http://van-clj.github.com), this library is a port of Haskell's attoparsec.

The difference between this and the ones I've seen so far is that zetta allows you to use a parser without having all the input available, you can put the input that is available now, and you'll get back a continuation function that will receive the remaining input later on.

It uses internally the clojure's algo.monads library, and also provides an Applicative Functor interface, has plenty of tests, some examples and all combinators are documented. It's a little rough over the edges, but is ready for a trial if you are interested. We over the van-clj group will try to use as much as we can for our problems.

Cheers.

rg.-

Cedric Greevey

unread,
Feb 7, 2012, 6:00:00 PM2/7/12
to clo...@googlegroups.com
On Tue, Feb 7, 2012 at 5:46 PM, Roman Gonzalez <roman...@gmail.com> wrote:
> I released yesterday zetta-parser (http://github.com/van-clj/zetta-parser)
> through the van-clj group (http://van-clj.github.com), this library is a
> port of Haskell's attoparsec.

Haskell has a parser library named for a distance of approximately
three centimetres? :)

Sanjay Dasgupta

unread,
Feb 7, 2012, 12:18:00 PM2/7/12
to Clojure
May I also suggest a look at VisualLangLab (http://vll.java.net/)?
It's a completely visual environment for developing (see
http://vll.java.net/EditingTheGrammarTree.html) and testing (see
http://vll.java.net/TestingParsers.html) parsers without using code/
scripts of any kind. Under the hood, its parsers use a Java version of
Scala's parser combinator library.

The developed parsers can be saved (as an XML file) that can be opened
again for further editing, testing, etc. The saved XML file can also
be loaded by any client program using a well-documented API (see
http://vll.java.net/UsingTheAPI.html) that is usable from any JVM
language.

But if you must have a library, the classes under
"net.java.vll.vll4j.combinator" are the ones you need. They are named
after the classes in the Scala parser combinator library, and work the
same way (except the "internal DSL" functionality).

A tutorial that explores the scenarios and examples in chapter 3 (A
Quick Tour for the Impatient) of the book The Definitive ANTLR
Reference can be found here: http://vll.java.net/examples/a-quick-tour.html

There is just one small executable jar you need (double-click to start
the IDE). It also contains several bundled examples that you can
tinker with, and the same jar works as the API for client programs:
http://java.net/projects/vll/downloads/download/VLL4J.jar

- Sanjay

On Jan 29, 1:44 pm, Roman Perepelitsa <roman.perepeli...@gmail.com>
wrote:

Despite

unread,
Feb 15, 2012, 8:47:09 PM2/15/12
to Clojure
> Haskell has a parser library named for a distance of approximately
> three centimetres? :)

Not that it's pertinent, but a parsec is 31 trillion kilometers. Did
you massively misplace a decimal? :)

Alan Malloy

unread,
Feb 15, 2012, 9:04:21 PM2/15/12
to Clojure
Roman Gonzalez:
> this library is a port of Haskell's attoparsec

Despite:
1 attoParsec = 3.08568025 × 10-5 kilometers

DAemon

unread,
Feb 15, 2012, 9:08:24 PM2/15/12
to clo...@googlegroups.com
atto is 10^-18, and a parsec is 3.1×10^13 km, which is 3.1×10^16m, which is 3.1×10^18cm, so Cedric was right, from what I can see...
 
Turns out I misread a 3 as a 5... lol *facepalm*

DAemon

unread,
Feb 15, 2012, 8:51:20 PM2/15/12
to clo...@googlegroups.com
Not massively - I get about 3.1 metres. 10^-18x10^15x10^3x3.1m...

Alan Malloy

unread,
Feb 16, 2012, 2:38:52 PM2/16/12
to Clojure
https://www.google.com/search?q=attoparsec+in+centimeters is where I
got a citation to back the 3.1 centimeter number (though, curiously, I
asked for km instead of cm the first time).
Reply all
Reply to author
Forward
0 new messages