shithub: mc

ref: 2a91805ad7f1a901eae822c58f40e74558bf8ec0
dir: /types.myr/

View raw version
use std

pkg regex =
	type status = union
		`Earlystop
		`Unbalanced
		`Emptyparen
		`Badrep
		`Noimpl
	;;

	type regex = struct
		pat	: byte[:]
		/* VM state */
		prog	: reinst[:]
		nthr	: std.size
		thr	: rethread#[:]
		str	: byte[:]
		strp	: std.size
		matched	: std.option(rethread#)
	;;

	type rethread = struct
		uid	: std.size
		ip	: std.size
	;;

	type reinst = union
		/* direct consumers */
		`Byte	byte
		`Range	[byte, byte]
		`Dot

		`Match	/* found the end of the expr */

		`Split	[std.size, std.size]
		`Jmp	std.size
	;;
;;