summaryrefslogtreecommitdiff
path: root/test/scan1.rl
blob: df0971a16a0c0453881a912a6cf8709a60dc7bc5 (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
/*
 * @LANG: indep
 */
ptr ts;
ptr te;
int act;
int token;
%%
%%{
	machine scanner;

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

		'b'+ => {
			prints "on next     ";
			if ( p+1 == te )
				prints "yes";
			prints "\n";
		};

		'c1' 'dxxx'? => {
			prints "on lag      ";
			if ( p+1 == te )
				prints "yes";
			prints "\n";
		};

		'd1' => {
			prints "lm switch1  ";
			if ( p+1 == te )
				prints "yes";
			prints "\n";
		};
		'd2' => {
			prints "lm switch2  ";
			if ( p+1 == te )
				prints "yes";
			prints "\n";
		};

		[d0-9]+ '.';

		'\n';
	*|;
}%%
/* _____INPUT_____
"abbc1d1d2\n"
_____INPUT_____ */
/* _____OUTPUT_____
on last     yes
on next     yes
on lag      yes
lm switch1  yes
lm switch2  yes
ACCEPT
_____OUTPUT_____ */