use pom::parser::*;
use pom::utf8;
fn main() {
let testcases: [Vec<u8>; 6] = [
vec![0b10100100, 0b11110000, 0b10011111, 0b10100100, 0b10010100], vec![0xd9, 4, 0b11110000, 0b10011111, 0b10011000, 0b10101110], vec![0xda, 0, 4, 0b11110000, 0b10011111, 0b10100100, 0b10101111], vec![
0xdb, 0, 0, 0, 4, 0b11110000, 0b10011111, 0b10010010, 0b10100101,
], vec![0xc4, 4, 0b11110000, 0b10011111, 0b10011000, 0b10101110], vec![0b10100100, 0b10010100, 0b10100100, 0b10011111, 0b11110000], ];
const MASK: u8 = 0b11100000; const SIZE_31: u8 = 0b10100000;
fn rest_as_str<'a>() -> utf8::Parser<'a, &'a str> {
utf8::any().repeat(0..).collect()
}
let parser = (sym(0xdb) * any().repeat(4) * rest_as_str()) | (sym(0xda) * any().repeat(2) * rest_as_str()) | (sym(0xd9) * any() * rest_as_str()) | (is_a(|x| x&MASK == SIZE_31) * rest_as_str()) - end();
for testcase in testcases.iter() {
println!("{:?}", parser.parse(testcase));
}
}