// Generated by re2js
// re2js $INPUT -o $OUTPUT

const YYMAXFILL = 1


function lex(yyinput) {
    let yycursor = 0;
    let yylimit = yyinput.length
    let count = 0

    loop: while (true) {
    
{
    let yych = 0
    let yystate = 0
    yyl: while (true) {
        switch (yystate) {
            case 0:
                if (yylimit <= yycursor) {
                    return -1
                }
                yych = yyinput.charCodeAt(yycursor)
                yycursor += 1;
                switch (yych) {
                    case 0x00:
                        yystate = 1
                        continue yyl
                    case 0x20:
                        yystate = 3
                        continue yyl
                    case 0x27:
                        yystate = 5
                        continue yyl
                    default:
                        yystate = 2
                        continue yyl
                }
            case 1:
                {
            // check that it is the sentinel, not some unexpected null
            return (yycursor == yylimit - YYMAXFILL + 1) ? count : -1
        }
            case 2:
                { return -1 }
            case 3:
                if (yylimit <= yycursor) {
                    return -1
                }
                yych = yyinput.charCodeAt(yycursor)
                switch (yych) {
                    case 0x20:
                        yycursor += 1;
                        yystate = 3
                        continue yyl
                    default:
                        yystate = 4
                        continue yyl
                }
            case 4:
                { continue loop }
            case 5:
                if (yylimit <= yycursor) {
                    return -1
                }
                yych = yyinput.charCodeAt(yycursor)
                yycursor += 1;
                switch (yych) {
                    case 0x27:
                        yystate = 6
                        continue yyl
                    case 0x5C:
                        yystate = 7
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 6:
                { count += 1; continue loop }
            case 7:
                if (yylimit <= yycursor) {
                    return -1
                }
                yycursor += 1;
                yystate = 5
                continue yyl
            default:
                throw "internal lexer error"
        }
    }
}

    }
}

function test(s, n) {
    let padded_s = s + "\0".repeat(YYMAXFILL)
    if (lex(padded_s) != n) throw "error!"
}

test("", 0)
test("'unterminated\\'", -1)
test("'qu\0tes' 'are' 'fine: \\'' ", 3)
test("'unexpected \0 null", -1)
