128386fa5c50c2ff509edf8c0c20ebf8cd598754
[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
11                 one := 'one\n';
12                 two := 'two\n';
13                 four := 'four\n';
14
15                 main := 
16                         ( 'hello' | 'there' | 'friend' ) 
17                         '\n' @{int s = fentry(one); fgoto *s; char c = fc;}
18                         ( 'one' | 'two' | 'four' ) '\n';
19         }%%
20
21         %% write data;
22
23         static void test( char data[] )
24         {
25                 int cs, p = 0, pe = data.length;
26                 int top;
27
28                 %% write init;
29                 %% write exec;
30
31                 if ( cs >= java1_first_final )
32                         System.out.println( "ACCEPT" );
33                 else
34                         System.out.println( "FAIL" );
35         }
36
37         public static void main( String args[] )
38         {
39                 test( "hello\none\n".toCharArray() );
40                 test( "there\ntwo\n".toCharArray() );
41                 test( "friend\nfour\n".toCharArray() );
42         }
43 }
44
45 /* _____OUTPUT_____
46 ACCEPT
47 FAIL
48 FAIL
49 */