Parsing lists with Lemon

Posted on 2014-04-08 00:00:00 -0800

I was parsing some lists of, erm, labels today in Lemon (with Ragel as the lexer), and couldn’t quickly (read lazily) find a grammar for parsing lists, so voila;

with the pseudocode replaced with code appropriate for your host language, and with

1
list
being the uppermost rule, and with
1
COMMA
being whatever delimiter you desire :)

Enjoy!