/* Generated by re2c */
#line 1 "repeater.re"
// re2c $INPUT -o $OUTPUT 
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define RET(n) return n

int scan(const char *s, int l){
const char *p = s;
const char *q;
#define YYCTYPE         char
#define YYCURSOR        p
#define YYLIMIT         (s+l)
#define YYMARKER        q
#define YYFILL(n)

#line 20 "repeater.c"
{
	YYCTYPE yych;
	unsigned int yyaccept = 0;
	if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
	yych = *YYCURSOR;
	switch (yych) {
		case '\n':
		case 'q': goto yy3;
		case 'A': goto yy5;
		case 'a': goto yy6;
		default: goto yy1;
	}
yy1:
	++YYCURSOR;
yy2:
#line 23 "repeater.re"
	{RET(5);}
#line 38 "repeater.c"
yy3:
	++YYCURSOR;
yy4:
#line 24 "repeater.re"
	{RET(0);}
#line 44 "repeater.c"
yy5:
	yyaccept = 0;
	yych = *(YYMARKER = ++YYCURSOR);
	switch (yych) {
		case '\n': goto yy7;
		case 'A':
		case 'a': goto yy8;
		default: goto yy2;
	}
yy6:
	yyaccept = 1;
	yych = *(YYMARKER = ++YYCURSOR);
	switch (yych) {
		case '\n': goto yy7;
		case 'A':
		case 'a': goto yy8;
		default: goto yy4;
	}
yy7:
	++YYCURSOR;
#line 19 "repeater.re"
	{RET(1);}
#line 67 "repeater.c"
yy8:
	yych = *++YYCURSOR;
	switch (yych) {
		case '\n': goto yy10;
		case 'A':
		case 'a': goto yy11;
		default: goto yy9;
	}
yy9:
	YYCURSOR = YYMARKER;
	if (yyaccept == 0) goto yy2;
	else goto yy4;
yy10:
	++YYCURSOR;
#line 20 "repeater.re"
	{RET(2);}
#line 84 "repeater.c"
yy11:
	yych = *++YYCURSOR;
	switch (yych) {
		case '\n': goto yy10;
		case 'A':
		case 'a': goto yy12;
		default: goto yy9;
	}
yy12:
	yych = *++YYCURSOR;
	switch (yych) {
		case '\n': goto yy13;
		case 'A':
		case 'a': goto yy14;
		default: goto yy9;
	}
yy13:
	++YYCURSOR;
#line 22 "repeater.re"
	{RET(4);}
#line 105 "repeater.c"
yy14:
	yych = *++YYCURSOR;
	switch (yych) {
		case '\n': goto yy13;
		case 'A':
		case 'a': goto yy15;
		default: goto yy9;
	}
yy15:
	yych = *++YYCURSOR;
	switch (yych) {
		case '\n': goto yy16;
		default: goto yy18;
	}
yy16:
	++YYCURSOR;
#line 21 "repeater.re"
	{RET(3);}
#line 124 "repeater.c"
yy17:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) YYFILL(1);
	yych = *YYCURSOR;
yy18:
	switch (yych) {
		case '\n': goto yy13;
		case 'A':
		case 'a': goto yy17;
		default: goto yy9;
	}
}
#line 25 "repeater.re"

}

void _do_scan(int exp, const char * str, int len)
{
	int ret = scan(str, len);
	
	printf("%d %s %d\n", exp, exp == ret ? "==" : "!=", ret);
}

#define do_scan(exp, str) _do_scan(exp, str, sizeof(str) - 1)

main()
{
	do_scan(1, "a\n");
	do_scan(2, "aa\n");
	do_scan(2, "aaa\n");
	do_scan(4, "aaaa\n");
	do_scan(0, "q");
	do_scan(0, "a");
	do_scan(1, "A\n");
	do_scan(2, "AA\n");
	do_scan(2, "aAa\n");
	do_scan(4, "AaaA\n");
	do_scan(5, "Q");
	do_scan(4, "AaaAa\n");
	do_scan(3, "AaaAaA\n");
	do_scan(5, "A");
	do_scan(0, "\n");
	do_scan(5, "0");
	do_scan(0, "a");
	do_scan(0, "q");
	do_scan(5, "x");
}
