Added .deps to ignore.
[external/ragel.git] / test / export4.rl
1 /*
2  * @LANG: d
3  */
4
5 import std.c.stdio;
6 import std.string;
7
8 %%{
9         machine test;
10
11         export c1 = 'c';
12         export c2 = 'z';
13         export c3 = 't';
14
15         commands := (
16                 c1 . digit* '\n' @{ printf( "c1\n" );} |
17                 c2 . alpha* '\n' @{ printf( "c2\n" );}|
18                 c3 . '.'* '\n' @{ printf( "c3\n" );}
19         )*;
20                 
21         some_other := any*;
22 }%%
23
24 %% write exports;
25 %% write data;
26
27 int test( char data[] )
28 {
29         int cs = test_en_commands;
30         char *p = data.ptr, pe = data.ptr + data.length;
31
32         %% write init nocs;
33         %% write exec;
34
35         if ( cs >= test_first_final )
36                 printf("ACCEPT\n");
37         else
38                 printf("ERROR\n");
39         return 0;
40 }
41
42 char data[] = [ 
43         test_ex_c1, '1', '2', '\n', 
44         test_ex_c2, 'a', 'b', '\n', 
45         test_ex_c3, '.', '.', '\n'
46 ];
47
48 int main()
49 {
50         test( data );
51         return 0;
52 }
53
54 /+ _____OUTPUT_____
55 c1
56 c2
57 c3
58 ACCEPT
59 ++++++++++++++++++/