logoalt Hacker News

rstuart413311/08/20241 replyview on HN

Not EBNF or anything standard, but possibly readable enough. It is an LR(1) grammar that has tested on all the test cases in Sqlite's test suite at the time:

https://lrparsing.sourceforge.net/doc/examples/lrparsing-sql...

The grammer contains things you won't have seen before, like Prio(). Think of them as macros. It all gets translated to LR(1) productions which you can ask it to print out. LR(1) productions are simpler than EBNF. They look like:

   symbol1 := symbol2 symbol3
   symbol1 := symbol4 symbol3
   symbol3 := token1 symbol2 token2
   ...
Documentation on what the macros do, and how to get it to spit out the LR1(1) productions is here:

https://lrparsing.sourceforge.net/doc/html/

It was used to do a similar task the OP is attempting.


Replies

jamra11/08/2024

This is great. Do you have any pointers to where those tests are? It’s hard to test the grammar without those.

Edit: Never mind. I see it right there under the parser. Thanks!