smack merge from tizen_2.1_smack
[external/ragel.git] / examples / uri.rl
1 %%{
2         machine uri;
3
4         action scheme {}
5         action loc {}
6         action item {}
7         action query {}
8         action last {}
9         action nothing {}
10
11         main :=
12                 # Scheme machine. This is ambiguous with the item machine. We commit
13                 # to the scheme machine on colon.
14                 ( [^:/?#]+ ':' @(colon,1) @scheme )?
15
16                 # Location machine. This is ambiguous with the item machine. We remain
17                 # ambiguous until a second slash, at that point and all points after
18                 # we place a higher priority on staying in the location machine over
19                 # moving into the item machine.
20                 ( ( '/' ( '/' [^/?#]* ) $(loc,1) ) %loc %/loc )? 
21
22                 # Item machine. Ambiguous with both scheme and location, which both
23                 # get a higher priority on the characters causing ambiguity.
24                 ( ( [^?#]+ ) $(loc,0) $(colon,0) %item %/item )? 
25
26                 # Last two components, the characters that initiate these machines are
27                 # not supported in any previous components, therefore there are no
28                 # ambiguities introduced by these parts.
29                 ( '?' [^#]* %query %/query)?
30                 ( '#' any* %/last )?;
31 }%%