// Generated by re2zig
// re2zig $INPUT -o $OUTPUT --loop-switch --computed-continue --no-generation-date --no-version

const std = @import("std");

fn lex(yyinput: [:0]const u8) u8 {
    var yycursor: usize = 0;

    var yych: u8 = 0;
    lexer_state: switch (@as(enum {
        node0,
        node1,
        node2,
        node3,
        node4,
        node5,
    }, .node0)) {
        .node0 => {
            yych = yyinput[yycursor];
            yycursor += 1;
            switch (yych) {
                0x61 => {
                    continue :lexer_state .node2;
                },
                0x62 => {
                    continue :lexer_state .node4;
                },
                else => {
                    continue :lexer_state .node1;
                },
            }
        },
        .node1 => {
            return 0;
        },
        .node2 => {
            yych = yyinput[yycursor];
            switch (yych) {
                0x61 => {
                    yycursor += 1;
                    continue :lexer_state .node2;
                },
                else => {
                    continue :lexer_state .node3;
                },
            }
        },
        .node3 => {
            return 1;
        },
        .node4 => {
            yych = yyinput[yycursor];
            switch (yych) {
                0x62 => {
                    yycursor += 1;
                    continue :lexer_state .node4;
                },
                else => {
                    continue :lexer_state .node5;
                },
            }
        },
        .node5 => {
            return 2;
        },
    }

}

test "computed-continue custom state and DFA labels" {
    const Case = struct { input: [:0]const u8, expected: u8 };
    const cases = [_]Case{
        .{ .input = "aaa", .expected = 1 },
        .{ .input = "bbb", .expected = 2 },
        .{ .input = "123", .expected = 0 },
    };

    for (cases) |case| {
        try std.testing.expectEqual(case.expected, lex(case.input));
    }
}
