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
|
/*
* @LANG: c++
*/
#include <iostream>
#include <string.h>
using std::cout;
using std::endl;
%%{
machine foo;
action c1 {i}
action c2 {j}
action one { cout << " one" << endl;}
action two { cout << " two" << endl;}
main := (
[a-z] |
('\n' when c1 @one)
)*
('\n' when c2 @two);
}%%
%% write data noerror;
void test( int i, int j, const char *str )
{
int cs = foo_start;
const char *p = str;
const char *pe = str + strlen( str );
cout << "run:" << endl;
%% write exec;
if ( cs >= foo_first_final )
cout << " success" << endl;
else
cout << " failure" << endl;
cout << endl;
}
int main()
{
test( 0, 0, "hi\n\n" );
test( 1, 0, "hi\n\n" );
test( 0, 1, "hi\n" );
test( 0, 1, "hi\n\n" );
test( 1, 1, "hi\n" );
test( 1, 1, "hi\n\n" );
test( 1, 1, "hi\n\nx" );
return 0;
}
#ifdef _____OUTPUT_____
run:
failure
run:
one
one
failure
run:
two
success
run:
two
failure
run:
one
two
success
run:
one
two
one
two
success
run:
one
two
one
two
failure
#endif
|