[ragel-users] Greedy star operator
Adrian Thurston
thurston at complang.org
Wed Jul 21 06:21:30 UTC 2010
Hi Alexander,
You should use the * in text and ** in main on Element.
Also, you'll get a warning about applying kleene star to a machine that
accepts the zero length word. Normally you don't want to do that because
it creates an ambiguity. You'll actually see evidence of the ambiguity
... start_test will get executed more than once.
-Adrian
On 10-07-20 11:56 AM, Alexander Laslavic wrote:
> This is a problem I come up against over and over again:
>
> action start_text { printf("start_text") }
> action end_text {printf("end_text")}
>
> text = any**;
> Text = text>start_text %end_text;
>
> Element = Text;
>
> main := Element*;
>
>
> Essentially, the start_text and end_text actions get called for every
> character. If I take the star operator off of Element, it works fine, but
> if Element has a star operator, ragel is preferring to repeat the Element
> over repeating the any** in 'text'.
>
> Is there some way I am not aware of to get it to prefer the inner
> repitition?
>
>
_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users
More information about the ragel-users
mailing list