HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //proc/597785/root/usr/share/doc/re2c/examples/02_recognizing_strings.i.c
/* Generated by re2c */
#include <stdio.h>
#include <string.h>

#define YYMAXFILL 1


struct input_t {
    size_t len;
    char *str;

    input_t(const char *s)
        : len(strlen(s))
        , str(new char[len + YYMAXFILL])
    {
        memcpy(str, s, len);
        memset(str + len, 'a', YYMAXFILL);
    }
    ~input_t()
    {
        delete[]str;
    }
};

static bool lex(const input_t & input)
{
    const char *YYCURSOR = input.str;
    const char *const YYLIMIT = input.str + input.len + YYMAXFILL;
    
{
	char yych;
	if (YYLIMIT <= YYCURSOR) return false;
	yych = *YYCURSOR;
	switch (yych) {
	case '"':	goto yy4;
	case '\'':	goto yy6;
	default:	goto yy2;
	}
yy2:
	++YYCURSOR;
	{ return false; }
yy4:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) return false;
	yych = *YYCURSOR;
	switch (yych) {
	case '"':	goto yy8;
	default:	goto yy4;
	}
yy6:
	++YYCURSOR;
	if (YYLIMIT <= YYCURSOR) return false;
	yych = *YYCURSOR;
	switch (yych) {
	case '\'':	goto yy8;
	default:	goto yy6;
	}
yy8:
	++YYCURSOR;
	{ return YYLIMIT - YYCURSOR == YYMAXFILL; }
}

}

int main(int argc, char **argv)
{
    for (int i = 1; i < argc; ++i) {
        input_t arg(argv[i]);
        printf("%s: %s\n", lex(arg) ? "str" : "err", argv[i]);
    }
    return 0;
}