1// re2c $INPUT -o $OUTPUT
2#include <iostream>
3
4#define YYCTYPE unsigned char
5#define YYCURSOR cursor
6#define YYLIMIT cursor
7#define YYMARKER marker
8#define YYFILL(n)
9
10bool scan(const char *text)
11{
12	YYCTYPE *start = (YYCTYPE *)text;
13	YYCTYPE *cursor = (YYCTYPE *)text;
14	YYCTYPE *marker = (YYCTYPE *)text;
15next:
16	YYCTYPE *token = cursor;
17/*!re2c
18'(This file must be converted with BinHex 4.0)'
19	{
20		if (token == start || *(token - 1) == '\n')
21		return true; else goto next;
22	}
23[\001-\377]
24	{ goto next; }
25[\000]
26	{ return false; }
27*/
28	return false;
29}
30
31#define do_scan(str, expect) \
32	res = scan(str) == expect ? 0 : 1; \
33	std::cerr << str << "\t-\t" << (res ? "fail" : "ok") << std::endl; \
34	result += res
35
36/*!max:re2c */
37
38int main(int,void**)
39{
40	int res, result = 0;
41	do_scan("(This file must be converted with BinHex 4.0)", 1);
42	do_scan("x(This file must be converted with BinHex 4.0)", 0);
43	do_scan("(This file must be converted with BinHex 4.0)x", 1);
44	do_scan("x(This file must be converted with BinHex 4.0)x", 0);
45
46	return result;
47}
48