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