
Ragel State Machine Compiler - Arubis
https://www.colm.net/open-source/ragel/
======
jdnier
Are you aware of anyone working to add Python as a target language? Will Ragel
7's intermediate codegen language make that easier?

~~~
thurston
Not at this time. But yes Ragel 7 will make it much easier. The first round of
new languages I added helped me polish the technique. Once 7 is out and vetted
it will make sense to add more.

------
lsllc
I've used Ragel extensively with both C and Go; I can't recommend it more
highly enough!

Thanks Adrian for your efforts.

~~~
thurston
My pleasure, thank you for the note!

------
fasteo
Seems like Lua would be a perfect target for Ragel. Do you know if anyone is
working in this direction ?

How does it compare with LPeg[1] ? This is what I currently use for all my
parsing needs.

[1] [http://www.inf.puc-rio.br/~roberto/lpeg/](http://www.inf.puc-
rio.br/~roberto/lpeg/)

~~~
leafo
Ragel doesn't support recursion (last I checked), so it's not suitable for
many parsing jobs. I considered it for MoonScript's parser at one point but it
didn't seem like it could do it. I've been experimenting with this project as
a replacement for LPEG for the MoonScript parser:
[http://piumarta.com/software/peg/](http://piumarta.com/software/peg/)

I've made an LPEG style syntax that compiles to the peg syntax for that tool,
which is then compiled to c and linked into a Lua module, you can see how the
parser is written here:
[https://github.com/leafo/moonparse/blob/master/parse.peg.moo...](https://github.com/leafo/moonparse/blob/master/parse.peg.moon#L115)

------
kbob
How is this different from Lex, written in 1975? Even the syntax looks fairly
similar.

[https://en.wikipedia.org/wiki/Lex_(software)](https://en.wikipedia.org/wiki/Lex_\(software\))

~~~
thurston
Ragel allows embedding actions into the subexpressions of a regular
expression. This allows one to compose a parser using a single regular
expression.

~~~
ticviking
Why would you want to do that?

~~~
jasonwatkinspdx
There are a lot of advantages to a declarative approach, and a lot of risks
and problems with hand written parsers and state machines.

A good example is the http code Zed wrote with ragel. From what I remember it
was contracted by verisign because they wanted an implementation that actually
followed the spec in detail, unlike all other code available at the time. That
ragel code has been reused by a lot of embedded http servers in many languages
now.

~~~
iofj
The thing I keep finding problematic about declarative approaches is that
nobody knows them. That means if you're not a lone wolf on a project, the
people editing your declarative state machine are going to be unfamiliar with
it. Aside from the complaints that gives (and the "look I rewrote it" issues),
that means they make mistakes and don't understand what happens.

So they don't last. They're not all that maintainable in real teams. My
experiences are mostly with ANTLR code (which has a debugger and lots of
tooling and isn't that hard at all).

I'm at a loss for how to overcome this.

~~~
thurston
Keep using them is how you overcome this ;)

------
clumsysmurf
I've been using Ragel on Android since Froyo (Java target); amazing software!

~~~
thurston
Thanks!

