[ragel-users] Newb's FSM troubles, part one.

Adrian Thurston thurs... at cs.queensu.ca
Mon May 12 23:00:43 UTC 2008


Hi,

Change the last line to:

main := (random_text | user_tag)**;

See section 4.2.4 in the manual.

Cheers,
 Adrian

frankshank wrote:
> I'm trying to detect users mentioned in a string. Users have an "@"
> before their name. Here's my current machine:
> 
> %{
>   machine user_parser;
>   action mark { mark = p; }
>   action print_user { puts("user: #{data[mark..p]}"); }
>   user_name = (lower . (lower | digit)*);
>   user_tag = ("@">mark . user_name) % print_user;
>   random_text = (0x20..0x3f | 0x41..0x7e)+; # all ascii, except for
> '@'
>   main := (random_text | user_tag)*;
> }%%
> 
> When I run this against "@u1 @u2", i see this output:
> 
> user: @u1
> user: @u1
> user: @u2
> 
> Why is @u1 seen twice?
> > 
> 



More information about the ragel-users mailing list