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

const assert = require('assert');

const YYMAXNMATCH = 3




function lex_tags(str) {
    let cur = 0
    
{
    let yych = 0
    let yystate = 0
    yyl: while (true) {
        switch (yystate) {
            case 0:
                mar = cur
                yych = str.charCodeAt(cur)
                switch (yych) {
                    case 0x62:
                        cur += 1
                        yystate = 2
                        continue yyl
                    default:
                        yyt1 = -1
                        yystate = 1
                        continue yyl
                }
            case 1:
                y = yyt1
                x = yyt1
                yyt1 = -1
                if (x != yyt1) x += -1
                { return x == -1 ? -1 : y - x }
            case 2:
                yych = str.charCodeAt(cur)
                switch (yych) {
                    case 0x61:
                        cur += 1
                        yystate = 4
                        continue yyl
                    default:
                        yystate = 3
                        continue yyl
                }
            case 3:
                cur = mar
                yyt1 = -1
                yystate = 1
                continue yyl
            case 4:
                yyt1 = cur
                yystate = 1
                continue yyl
            default:
                throw "internal lexer error"
        }
    }
}

}

function lex_captures(str) {
    let cur = 0
    let yypmatch = Array(YYMAXNMATCH * 2).fill(-1)
    
{
    let yych = 0
    let yystate = 0
    yyl: while (true) {
        switch (yystate) {
            case 0:
                yych = str.charCodeAt(cur)
                switch (yych) {
                    case 0x61:
                        yyt1 = cur
                        cur += 1
                        yystate = 2
                        continue yyl
                    default:
                        yyt1 = cur
                        yyt2 = -1
                        yystate = 1
                        continue yyl
                }
            case 1:
                yynmatch = 3
                yypmatch[0] = yyt1
                yypmatch[3] = yyt2
                yypmatch[5] = yyt2
                yypmatch[1] = cur
                yypmatch[2] = yyt2
                yyt2 = -1
                if (yypmatch[2] != yyt2) yypmatch[2] += -1
                yypmatch[4] = yypmatch[2]
                { return yypmatch[4] }
            case 2:
                yyt2 = cur
                yystate = 1
                continue yyl
            default:
                throw "internal lexer error"
        }
    }
}

}

assert.equal(lex_tags("\0"), -1)
assert.equal(lex_tags("ba\0"), 1)
assert.equal(lex_captures("\0"), -1)
assert.equal(lex_captures("a\0"), 0)
codegen/js/nested_fixed_tags.re:23:25: warning: rule matches empty string [-Wmatch-empty-string]
codegen/js/nested_fixed_tags.re:32:17: warning: rule matches empty string [-Wmatch-empty-string]
