[ragel-users] How do I act on eof in state charts

Adrian Thurston thurston at complang.org
Fri Oct 23 01:46:12 UTC 2009


Hi Antony

You can do this:

       seen_quote: (
               "'" -> start |
               [^'] @{ fhold; } -> final
               ) >eof(here);

If you don't like putting the action after the closing brace you can do 
this.

       seen_quote: "" $eof(here) (
               "'" -> start |
               [^'] @{ fhold; } -> final
               );

-Adrian

Antony Blakey wrote:
> Hi,
> 
> I (a Ragel newb) have a state chart for consuming smalltalk string  
> literals (single quotes, any body, double single quotes is an embedded  
> quote), like this:
> 
> string_literal_body =
>    start: (
>      "'" -> seen_quote |
>      [^'] -> start
>    ),
>    seen_quote: (
>      "'" -> start |
>      [^'] @{ fhold; } -> final
>    );
> string_literal = "'" string_literal_body %{ puts "string_literal" } ;
> 
> The problem occurs when a string literal ends at eof. How do I specify  
> the eof 'match' in the seen_quote state such that all the leaving- 
> transition actions that are in place above the string_literal are  
> executed, such as the 'puts' on the 'string_literal' machine. I don't  
> want to manually duplicate the parent code because multiple machines  
> reference string_literal, with different leaving-transition actions.
> 
> I couldn't get it to work using priorities - the terminator needs  
> lookahead to disambiguate; the following doesn't work:
> 
> string_literal = "'" [^']* ( "''" [^']* )* '"'
> 
> Antony Blakey
> --------------------------
> CTO, Linkuistics Pty Ltd
> Ph: 0438 840 787
> 
> Lack of will power has caused more failure than lack of intelligence  
> or ability.
>   -- Flower A. Newhouse
> 
> 
> _______________________________________________
> 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