
A Parser Combinator library for C - joubert
https://github.com/orangeduck/mpc
======
enqk
Another is Hammer,
[https://github.com/UpstandingHackers/hammer](https://github.com/UpstandingHackers/hammer)

------
0xCMP
This is being used from another thing posted here about making your own lisp:
[http://www.buildyourownlisp.com/](http://www.buildyourownlisp.com/)

Pretty nice and simple. I'm on Chapter 8 of 16.

~~~
gshrikant
I think both the library and the book are written by the same author [1].

[1] [http://theorangeduck.com/page/you-could-have-invented-
parser...](http://theorangeduck.com/page/you-could-have-invented-parser-
combinators)

------
poseid
nice!

------
anon5_
What's the difference between this and flex/yacc?

~~~
revelation
From the readme, a workflow that doesn't make you want to kill yourself.

Also no generated code that requires extra build steps and instantly breaks
platform compatibility. That said, inline grammar definition might not be for
everyone.

~~~
gopowerranger
Hmm. So for people who don't know how to use Unix/flex/yacc?

This is just reinventing an existing wheel.

~~~
MichaelMoser123
In yacc the generator will tell you about shift reduce conflicts. Once you
have debugged the grammar the parser is likely to work. With parser
combinators you have no such assurance - you don't know if your grammar has
loops, the parser might get stuck easily while parsing. However for a simple
and regular input language like sexpr everything is fine.

~~~
sklogic
In recursive descent you simply do not have any shift/reduce conflicts.

~~~
MichaelMoser123
you can have left recursion, or implicit left recursion in your recursive
descent grammar, if you have then the parser gets stuck while parsing a clause
that contains left recursion.

~~~
sklogic
Firstly, this have nothing to do with shift/reduce. Secondly, you can safely
handle left-recursive grammars in Packrat (which, in turn, can be implemented
with combinators).

~~~
MichaelMoser123
I didn't say that left recursion has anything to do with shift reduce
conflicts. Please read again.

~~~
sklogic
I see, yes, you mentioned loops earlier. Anyway, it is not a problem for
combinator-based parsing, just use Packrat with a left-recursive extension [1]

[1]
[http://www.vpri.org/pdf/tr2007002_packrat.pdf](http://www.vpri.org/pdf/tr2007002_packrat.pdf)

