blob: 040ad73a2be1c60675862fec458ddeee7bca68ba (
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
|
/*
* @LANG: c
*/
#include <stdio.h>
#include <string.h>
%%{
machine foo;
action on_char { printf("char: %c\n", *p); }
action on_err { printf("err: %c\n", *p); }
action to_state { printf("to state: %c\n", *p); }
main := 'heXXX' $on_char $err(on_err) $to(to_state);
}%%
%% write data;
int main()
{
int cs;
char *p = "hello", *pe = p + strlen(p);
char *eof = pe;
%%{
write init;
write exec;
}%%
printf( "rest: %s\n", p );
return 0;
}
#ifdef _____OUTPUT_____
char: h
to state: h
char: e
to state: e
err: l
rest: llo
#endif
|