1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// Generated by re2zig
// re2zig $INPUT -o $OUTPUT --recursive-functions
const std = @import("std");
const State = struct {
str: [:0]const u8,
cur: u32,
};
fn yy0(st: *State) bool {
const yych = st.str[st.cur];
st.cur += 1;
switch (yych) {
0x31...0x39 => { return yy2(st); },
else => { return yy1(st); },
}
}
fn yy1(st: *State) bool {
_ = st; return false;
}
fn yy2(st: *State) bool {
const yych = st.str[st.cur];
switch (yych) {
0x30...0x39 => {
st.cur += 1;
return yy2(st);
},
else => { return yy3(st); },
}
}
fn yy3(st: *State) bool {
_ = st; return true;
}
fn lex(st: *State) bool {
return yy0(st);
}
test {
var st = State{.str = "1234", .cur = 0};
try std.testing.expect(lex(&st));
}
|