Newb's FSM troubles, part one.
frankshank
franksh... at mailinator.com
Sun May 11 06:11:10 UTC 2008
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
More information about the ragel-users
mailing list