Ask HN: Which one is better for writing a SQL parser?
It seems that there are two choices: Lemon Parser Generator and YACC.
PostgreSQL uses YACC and SQLite uses Lemon.
My usages should be multi-thread, embedded parser for much simpler SQL syntax (a SQL subset).
Which one is better for this?
10 comments
[ 3.3 ms ] story [ 29.2 ms ] threadhttp://www.pragprog.com/titles/tpantlr/the-definitive-antlr-...
Even if it gives you something a bit too elaborate, it can be easier to filter your way back down to what you are looking for than to rewrite something up from the bottom. (One easy strategy is to just scream "SYNTAX ERROR!" when you see something that the grammar knows, but you don't understand. Since you'll be attaching your own object model/structs to the parser anyhow, this is virtually trivial.)
Anyway, the field of parser generators seems to have grown recently. I had never heard of ANTLR before, nor Lemon. Thanks for the pointers in this thread, I'll be sure to investigate them. There is also Parsec (for Haskell), and ocamllex and ocamlyacc (for OCaml). If you use C++, look into Boost.Spirit. I use tinyjson in production, which uses Boost.Spirit and it works quite well.
Oh and if for some reason you end up using flex somewhere, don't forget to specify the "-8" option to ensure it generates an 8-bit clean scanner.