File: java1.rl

package info (click to toggle)
ragel 5.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,628 kB
  • ctags: 4,619
  • sloc: cpp: 15,187; ansic: 3,490; yacc: 1,921; makefile: 411; sh: 146; awk: 6
file content (49 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * @LANG: java
 * @ALLOW_GENFLAGS: -T0
 */

class java1
{
	%%{
		machine java1;

		one := 'one\n';
		two := 'two\n';
		four := 'four\n';

		main := 
			( 'hello' | 'there' | 'friend' ) 
			'\n' @{int s = fentry(one); fgoto *s; char c = fc;}
			( 'one' | 'two' | 'four' ) '\n';
	}%%

	%% write data;

	static void test( char data[] )
	{
		int cs, p = 0, pe = data.length;
		int top;

		%% write init;
		%% write exec;

		if ( cs >= java1_first_final )
			System.out.println( "ACCEPT" );
		else
			System.out.println( "FAIL" );
	}

	public static void main( String args[] )
	{
		test( "hello\none\n".toCharArray() );
		test( "there\ntwo\n".toCharArray() );
		test( "friend\nfour\n".toCharArray() );
	}
}

/* _____OUTPUT_____
ACCEPT
FAIL
FAIL
*/