Added two new statements: prepush and postpop. These are code blocks that are
[external/ragel.git] / test / export3.rl
1 #
2 # @LANG: ruby
3 #
4
5 %%{
6         machine test;
7
8         export c1 = 'c';
9         export c2 = 'z';
10         export c3 = 't';
11
12         commands := (
13                 c1 . digit* '\n' @{ puts "c1"; } |
14                 c2 . alpha* '\n' @{ puts "c2"; }|
15                 c3 . '.'* '\n' @{ puts "c3"; }
16         )*;
17                         
18         other := any*;
19 }%%
20
21 %% write exports;
22 %% write data;
23
24 def run_machine( data )
25         p = 0;
26         pe = data.length
27         cs = test_en_commands
28         val = 0;
29         neg = false;
30
31         %% write init nocs;
32         %% write exec;
33         %% write eof;
34         if  cs >= test_first_final
35                 puts "ACCEPT"
36         else
37                 puts "FAIL"
38         end
39 end
40
41 inp = [
42                 test_ex_c1, ?1, ?2, ?\n, 
43                 test_ex_c2, ?a, ?b, ?\n, 
44                 test_ex_c3, ?., ?., ?\n
45 ]
46
47 run_machine( inp );
48
49 =begin _____OUTPUT_____
50 c1
51 c2
52 c3
53 ACCEPT
54 =end _____OUTPUT_____