shithub: mc

ref: d5ff76398f8fb87284ea7b26121bf1262aaaae25
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 */
		proglen	: std.size
		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 */
		`Ibyte	byte
		`Irange	[byte, byte]
		`Idot

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

		`Ifork	[std.size, std.size]
		`Ijmp	std.size
	;;
;;