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

Antony Blakey antony.blakey at gmail.com
Wed Oct 21 13:40:16 UTC 2009


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





More information about the ragel-users mailing list