summaryrefslogtreecommitdiff
path: root/test/trans.d/case/scan1_rust.rl
blob: aa67bcd543db8d171e7f2f284dc440013d1f72dd (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//
// @LANG: rust
// @GENERATED: true
//

static mut ts : i32
 = 0;
static mut te : i32
 = 0;
static mut act : i32 = 0;
static mut token : i32 = 0;

%%{
	machine scanner;

	# Warning: changing the patterns or the input string will affect the
	# coverage of the scanner action types.
	main := |*
		'a' => {print!( "{}", "on last     " );
if ( p + 1 == te )
{
	print!( "{}", "yes" );

} 
print!( "{}", "\n" );
};

		'b'+ => {print!( "{}", "on next     " );
if ( p + 1 == te )
{
	print!( "{}", "yes" );

} 
print!( "{}", "\n" );
};

		'c1' 'dxxx'? => {print!( "{}", "on lag      " );
if ( p + 1 == te )
{
	print!( "{}", "yes" );

} 
print!( "{}", "\n" );
};

		'd1' => {print!( "{}", "lm switch1  " );
if ( p + 1 == te )
{
	print!( "{}", "yes" );

} 
print!( "{}", "\n" );
};
		'd2' => {print!( "{}", "lm switch2  " );
if ( p + 1 == te )
{
	print!( "{}", "yes" );

} 
print!( "{}", "\n" );
};

		[d0-9]+ '.';

		'\n';
	*|;
}%%



%% write data;

unsafe fn m( s: String )
{
	let data: &[u8] = s.as_bytes();
	let mut p:i32 = 0;
	let mut pe:i32 = s.len() as i32;
	let mut eof:i32 = s.len() as i32;
	let mut cs: i32 = 0;
	let mut buffer = String::new();

	%% write init;
	%% write exec;

	if ( cs >= scanner_first_final ) {
		println!( "ACCEPT" );
	}
	else {
		println!( "FAIL" );
	}
}

fn main()
{
	unsafe { m( "abbc1d1d2\n".to_string() ); }
}