Added two new statements: prepush and postpop. These are code blocks that are
[external/ragel.git] / test / erract9.rl
1 #
2 # @LANG: ruby
3 #
4 # Test the host language scanning for ruby.
5 #
6
7 %%{
8         machine erract9;
9
10         action on_char  { print("char: ", data[p..p], "\n"); }
11         action on_err   { print("err: ", data[p..p], "\n"); }
12         action to_state { print("to state: " , data[p..p], "\n"); }
13
14         main := 'heXXX' $on_char $err(on_err) $to(to_state);
15 }%%
16
17 %% write data;
18
19 def run_machine( data )
20         p = 0;
21         pe = data.length
22         cs = 0
23
24         %% write init;
25         %% write exec;
26
27         print("rest: " , data[p..p+2], "\n")
28 end
29
30 inp = [
31                 "hello\n",
32 ]
33
34 inp.each { |str| run_machine(str) }
35
36 =begin _____OUTPUT_____
37 char: h
38 to state: h
39 char: e
40 to state: e
41 err: l
42 rest: llo
43 =end _____OUTPUT_____