Applied java data array encoding patch from Colin Fleming. Only works with byte
[ragel.git] / test / java1.rl
blobd98f6c74e06c590ae16c2ecc2e5c03786a0ae237
1 /*
2  * @LANG: java
3  * @ALLOW_GENFLAGS: -T0
4  */
6 class java1
8         %%{
9                 machine java1;
10                 alphtype byte;
12                 one := 'one\n';
13                 two := 'two\n';
14                 four := 'four\n';
16                 main := 
17                         ( 'hello' | 'there' | 'friend' ) 
18                         '\n' @{int s = fentry(one); fgoto *s; char c = fc;}
19                         ( 'one' | 'two' | 'four' ) '\n';
20         }%%
22         %% write data;
24         static void test( char data[] )
25         {
26                 int cs, p = 0, pe = data.length;
27                 int top;
29                 %% write init;
30                 %% write exec;
32                 if ( cs >= java1_first_final )
33                         System.out.println( "ACCEPT" );
34                 else
35                         System.out.println( "FAIL" );
36         }
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         }
46 /* _____OUTPUT_____
47 ACCEPT
48 FAIL
49 FAIL