summaryrefslogtreecommitdiff
path: root/test/import1.rl
blob: e721f56282ea86f8eeb813e4f130b9c676777a5c (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
/*
 * @LANG: c
 */

#include <stdio.h>

char *foo = "foo";

char b = 98;
char a = 97;
char r = 114;

#define SP 32
#define NL '\n'

%%{
	machine tmp;
	import "import1.rl";

	foobar = 
		foo @{printf("foo\n"); } |
		b a r @{printf("bar\n");};

	main := ( foobar SP foobar NL )*;
}%%

%% write data;

int cs;

void exec_str( char *p, int len )
{
	char *pe = p + len;
	%% write exec;
}

void exec_c( char c )
{
	exec_str( &c, 1 );
}

int main()
{
	%% write init;

	exec_str( foo, 3 );
	exec_c( SP );
	exec_c( b );
	exec_c( a );
	exec_c( r );
	exec_c( NL );

	exec_c( b );
	exec_c( a );
	exec_c( r );
	exec_c( SP );
	exec_str( foo, 3 );
	exec_c( NL );

	if ( cs < tmp_first_final )
		printf("FAIL\n");
	else
		printf("ACCEPT\n");

	return 0;
}
#ifdef _____OUTPUT_____
foo
bar
bar
foo
ACCEPT
#endif