[ragel-users] Actions embedded into unexpected transitions?

Dmitry Marakasov amdmi3 at amdmi3.ru
Thu Jan 29 21:36:49 UTC 2009


* Adrian Thurston (thurston at complang.org) wrote:

> Sorry I went to fast and didn't see your problem. My mail program was 
> highlighting the lines beginning with ">", causing some confusion for me.
> 
> The bit of info that you're missing is that action embedding operators 
> bind more tightly than concatenation. Use:
> 
> b := ( a 'b'+ ) >{print} %{print};
> 
> and I think you'll get what you want.

That would be too easy :)

Actually that was just an example, the real cause is more complex,
and my goal is to save all informaion encountered while parsing
subexpression amd process it as a whole when it's finished. Like
that:

char *a_start;
char *a_end;

a = 'a'+
    > { a_start = p; }
    % { a_end = p; }
;

b = a 'b'+
    > { a_start = a_end = 0; /* reset state */ }
    % { printf("subexpr finished, there were %d a's\n", a_end-a_start); }
;

main := b+;

-- 
Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
amdmi3 at amdmi3.ru  ..:  jabber: amdmi3 at jabber.ru    http://www.amdmi3.ru




More information about the ragel-users mailing list