// Generated by re2js
// re2js $INPUT -o $OUTPUT --input-encoding utf8

// This example supports multiple input encodings: UTF-8 and UTF-32.
// Both lexers are generated from the same rules block, and the use
// blocks add only encoding-specific configurations.


function lex_utf8(yyinput) {
    let yycursor = 0
    
{
    let yych = 0
    let yystate = 0
    yyl: while (true) {
        switch (yystate) {
            case 0:
                yych = yyinput.at(yycursor)
                yycursor += 1;
                switch (yych) {
                    case 0xE2:
                        yystate = 3
                        continue yyl
                    default:
                        yystate = 1
                        continue yyl
                }
            case 1:
                yystate = 2
                continue yyl
            case 2:
                { return null }
            case 3:
                yymarker = yycursor;
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x88:
                        yycursor += 1;
                        yystate = 4
                        continue yyl
                    default:
                        yystate = 2
                        continue yyl
                }
            case 4:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x80:
                        yycursor += 1;
                        yystate = 6
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 5:
                yycursor = yymarker;
                yystate = 2
                continue yyl
            case 6:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x78:
                        yycursor += 1;
                        yystate = 7
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 7:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x20:
                        yycursor += 1;
                        yystate = 8
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 8:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0xE2:
                        yycursor += 1;
                        yystate = 9
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 9:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x88:
                        yycursor += 1;
                        yystate = 10
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 10:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x83:
                        yycursor += 1;
                        yystate = 11
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 11:
                yych = yyinput.at(yycursor)
                switch (yych) {
                    case 0x79:
                        yycursor += 1;
                        yystate = 12
                        continue yyl
                    default:
                        yystate = 5
                        continue yyl
                }
            case 12:
                { return yycursor }
            default:
                throw "internal lexer error"
        }
    }
}

}

function lex_utf32(yyinput) {
    let yycursor = 0
    
{
    let yych = 0
    let yystate = 0
    yyl: while (true) {
        switch (yystate) {
            case 0:
                yych = yyinput.at(yycursor)
                yycursor += 1;
                if (yych === 0x00002200) {
                    yystate = 2
                    continue yyl
                }
                yystate = 1
                continue yyl
            case 1:
                { return null }
            case 2:
                yymarker = yycursor;
                yych = yyinput.at(yycursor)
                if (yych !== 0x00000078) {
                    yystate = 1
                    continue yyl
                }
                yycursor += 1;
                yych = yyinput.at(yycursor)
                if (yych === 0x00000020) {
                    yycursor += 1;
                    yystate = 4
                    continue yyl
                }
                yystate = 3
                continue yyl
            case 3:
                yycursor = yymarker;
                yystate = 1
                continue yyl
            case 4:
                yych = yyinput.at(yycursor)
                if (yych !== 0x00002203) {
                    yystate = 3
                    continue yyl
                }
                yycursor += 1;
                yych = yyinput.at(yycursor)
                if (yych !== 0x00000079) {
                    yystate = 3
                    continue yyl
                }
                yycursor += 1;
                { return yycursor }
            default:
                throw "internal lexer error"
        }
    }
}

}

function test(f, s) {
    if (f(s) != s.length) throw "error!"
}

test(lex_utf8, [0xe2, 0x88, 0x80, 0x78, 0x20, 0xe2, 0x88, 0x83, 0x79])
test(lex_utf32, [0x2200, 0x78, 0x20, 0x2203, 0x79])
