/* Generated by re2d */
#line 1 "d/eof/04_fake_sentinel.re"
// re2d $INPUT -o $OUTPUT
module main;

import core.stdc.stdlib;
import core.stdc.string;

private int lex(immutable char[] s) {
    // For the sake of example create a string without terminating null.
    char *buf = cast(char*) malloc(s.length);
    memcpy(buf, cast(const(void*)) s, s.length);

    const(char) *cur = buf, lim = buf + s.length;
    int count = 0;

    for (;;) {
    
#line 20 "d/eof/04_fake_sentinel.d"
{
    char yych;
    yych = cur < lim ? *cur : 0;
    switch (yych) {
        case 0x00: goto yy1;
        case ' ': goto yy3;
        case 'a': .. case 'z': goto yy5;
        default: goto yy2;
    }
yy1:
    ++cur;
#line 24 "d/eof/04_fake_sentinel.re"
    { break;{} }
#line 34 "d/eof/04_fake_sentinel.d"
yy2:
    ++cur;
#line 23 "d/eof/04_fake_sentinel.re"
    { count = -1; break; }
#line 39 "d/eof/04_fake_sentinel.d"
yy3:
    ++cur;
    yych = cur < lim ? *cur : 0;
    switch (yych) {
        case ' ': goto yy3;
        default: goto yy4;
    }
yy4:
#line 26 "d/eof/04_fake_sentinel.re"
    { continue; }
#line 50 "d/eof/04_fake_sentinel.d"
yy5:
    ++cur;
    yych = cur < lim ? *cur : 0;
    switch (yych) {
        case 'a': .. case 'z': goto yy5;
        default: goto yy6;
    }
yy6:
#line 25 "d/eof/04_fake_sentinel.re"
    { ++count; continue;{} }
#line 61 "d/eof/04_fake_sentinel.d"
}
#line 27 "d/eof/04_fake_sentinel.re"

    }

    free(buf);
    return count;
}

void main() {
    assert(lex("") == 0);
    assert(lex("one two three ") == 3);
    assert(lex("f0ur") == -1);
}
