Use the new import feature of Ragel for bringing in defines from the parser
[ragel.git] / test / export2.rl
blob198e10ce17ca332c70b533aaac4c97289f9951ae
1 /*
2  * @LANG: java
3  * @ALLOW_GENFLAGS: -T0
4  */
6 class export2
8         %%{
9                 machine test;
11                 export c1 = 'c';
12                 export c2 = 'z';
13                 export c3 = 't';
15                 commands := (
16                         c1 . digit* '\n' @{ System.out.println( "c1" );} |
17                         c2 . alpha* '\n' @{ System.out.println( "c2" );}|
18                         c3 . '.'* '\n' @{ System.out.println( "c3" );}
19                 )*;
20                         
21                 other := any*;
22         }%%
24         %% write exports;
25         %% write data;
27         static void test( char data[] )
28         {
29                 int cs = test_en_commands, p = 0, pe = data.length;
30                 int top;
32                 %% write init nocs;
33                 %% write exec;
35                 if ( cs >= test_first_final )
36                         System.out.println( "ACCEPT" );
37                 else
38                         System.out.println( "FAIL" );
39         }
41         public static void main( String args[] )
42         {
43                 char data[] = { 
44                         test_ex_c1, '1', '2', '\n', 
45                         test_ex_c2, 'a', 'b', '\n', 
46                         test_ex_c3, '.', '.', '\n',
47                 };
48                 test( data );
49         }
53 /* _____OUTPUT_____
57 ACCEPT