projects
/
external
/
ragel.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Updated the svn:ignore in test, added EXTRA_DIST so that tests get added to the
[external/ragel.git]
/
test
/
import1.rl
1
/*
2
* @LANG: c
3
*/
4
5
#include <stdio.h>
6
7
char *foo = "foo";
8
9
char b = 98;
10
char a = 97;
11
char r = 114;
12
13
#define SP 32
14
#define NL '\n'
15
16
%%{
17
machine tmp;
18
import "import1.rl";
19
20
foobar =
21
foo @{printf("foo\n"); } |
22
b a r @{printf("bar\n");};
23
24
main := ( foobar SP foobar NL )*;
25
}%%
26
27
%% write data;
28
29
int cs;
30
31
void exec_str( char *p, int len )
32
{
33
char *pe = p + len;
34
%% write exec;
35
}
36
37
void exec_c( char c )
38
{
39
exec_str( &c, 1 );
40
}
41
42
int main()
43
{
44
%% write init;
45
46
exec_str( foo, 3 );
47
exec_c( SP );
48
exec_c( b );
49
exec_c( a );
50
exec_c( r );
51
exec_c( NL );
52
53
exec_c( b );
54
exec_c( a );
55
exec_c( r );
56
exec_c( SP );
57
exec_str( foo, 3 );
58
exec_c( NL );
59
60
if ( cs < tmp_first_final )
61
printf("FAIL\n");
62
else
63
printf("ACCEPT\n");
64
65
return 0;
66
}
67
#ifdef _____OUTPUT_____
68
foo
69
bar
70
bar
71
foo
72
ACCEPT
73
#endif