[ragel-users] Machine definitions that depend on each other

Adrian Thurston thurs... at cs.queensu.ca
Wed May 16 00:13:05 UTC 2007


Hi,

In general, Ragel cannot handle recursive structures because the grammar
is interpreted as a regular language.

However, depending on what needs to be parsed it is sometimes practical
to manually implement the recursive part using fcall/fret. The trick is
to think of these as function calls and to mimic a recursive descent
parser. To balance parentheses you can often use counters and fgoto.
Conditions are also a possibility. Look in test/cond6.rl for an example.

Cheers,
 Adrian

chrsan wrote:
> Hi!
> 
> I'm working with Ragel for the first time, implementing a CSS scanner/
> parser.
> I've run into trouble having machine definitions that depend on each
> other. In the following
> example term refers to function which in turn refers to expr that
> refers to term.
> 
> What's the best way to solve this in Ragel?
> I haven't come up with a way to solve this by rearranging the
> definitions.
> 
> function = ident '(' s* expr ')' s*;
> term = ( ( ( unary_operator? ( unary_term | num ident ) ) | string |
> ident | uri ) s* ) | hexcolor | function;
> operator = ( '/' | ',' ) s*;
> expr = term ( operator? term )*;
> 
> Thanks in advance,
> Christer Sandberg
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ragel-users" group.
> To post to this group, send email to ragel-users at googlegroups.com
> To unsubscribe from this group, send email to ragel-users-unsubscribe at googlegroups.com
> For more options, visit this group at http://groups.google.com/group/ragel-users?hl=en
> -~----------~----~----~----~------~----~------~--~---

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070515/990f74fc/attachment-0001.sig>


More information about the ragel-users mailing list