[ragel-users] combining ragel and lemon

Adrian Thurston thurston at colm.net
Fri Aug 16 15:57:21 EDT 2019


Hi Mark,

You can return from the scanner pattern action if you like. You can also 
craft a machine that that just attempts to match one token, then return 
the token. If you want to stay faithful to lex semantics, you have to 
take some care to implement the "longest-match" characteristic yourself.

But from what I've seen, lemon lets you pass in one token at a time. 
This is just one example I found, but there seems to be more.

https://github.com/eloraiby/rl-json-parser/blob/master/json-parser/lexer.rl

Adrian

On 2019-08-16 11:07, Mark Olesen wrote:
> I've use ragel in a few places already for parsing, but now I'm looking
> to port over a medium sized chunk of flex/bison. Perhaps going for a
> ragel/lemon combination.
> 
> According to the lemon docs (https://www.hwaci.com/sw/lemon/lemon.html)
> the parser is the one calling the lexer. But this seems to be the same
> as ragel would like to be doing: match a pattern, call an action.
> 
> The few examples of ragel/lemon that I've found (the classic 
> calculator,
> or a json parser) seem to be handling this by running ragel as the
> scanner, and calling the lemon parser in its actions.
> 
> Some other examples I've seen use re2c for the lexing part. This 
> appears
> to fit better with what lemon expects, but there must be some way to 
> lex
> a single token and return from ragel I suspect.
> 
> I would be thankful for ideas.
> 
> Cheers,
> /mark
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users



More information about the ragel-users mailing list