Applied java data array encoding patch from Colin Fleming. Only works with byte
[external/ragel.git] / test / java1.rl
1 /*
2  * @LANG: java
3  * @ALLOW_GENFLAGS: -T0
4  */
5
6 class java1
7 {
8         %%{
9                 machine java1;
10                 alphtype byte;
11
12                 one := 'one\n';
13                 two := 'two\n';
14                 four := 'four\n';
15
16                 main := 
17                         ( 'hello' | 'there' | 'friend' ) 
18                         '\n' @{int s = fentry(one); fgoto *s; char c = fc;}
19                         ( 'one' | 'two' | 'four' ) '\n';
20         }%%
21
22         %% write data;
23
24         static void test( char data[] )
25         {
26                 int cs, p = 0, pe = data.length;
27                 int top;
28
29                 %% write init;
30                 %% write exec;
31
32                 if ( cs >= java1_first_final )
33                         System.out.println( "ACCEPT" );
34                 else
35                         System.out.println( "FAIL" );
36         }
37
38         public static void main( String args[] )
39         {
40                 test( "hello\none\n".toCharArray() );
41                 test( "there\ntwo\n".toCharArray() );
42                 test( "friend\nfour\n".toCharArray() );
43         }
44 }
45
46 /* _____OUTPUT_____
47 ACCEPT
48 FAIL
49 FAIL
50 */