Okay, I wanted to write a Liquid-parser, so I decided to test Ragel
(together with Ruby, not C). The idea was to write a "tokenizer" in
Ragel, which would simply find all the dynamics/blocks (not putting {%
if %} and {% endif %} together for instance) and then have a "parser"
which matches them up. The final Liquid-parser would then be an engine
with those two parsers.
Well. I failed. Because of two things:
1) {% tags %} seems to be very hard to parse, because every tag is
responsible for parsing itself. It works in the current Liquid-parser
because it's parsed with regexp, but that doesn't work with Ragel
since it compiles. It's fair enough that the built-in tags requires
special parsing, but also custom tags? It makes it a lot harder.
2) I couldn't figure out how to parse both text and {{ output }}, so
now it can only parse things like "{{ var | yeah: 123 }}". Not a big
issue - I'm just doing it wrong.
If anyone interested, here's what I got:
https://gist.github.com/0e65a352d6b16b445763 (no idea if it's
"idomatic" Ragel, but at least it works)
//Magnus Holm