shithub: mc

ref: 5fe0859c8a8a801150efa772492db9b6f1baa631
dir: /types.myr/

View raw version
use std

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

	type regex = struct
		debug	: bool
		pat	: byte[:]
		nmatch	: std.size

		/* 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	/* just for debugging */
		ip	: std.size	/* the instruction pointer */

		mstart	: std.size[:]	/* match starts */
		mend	: std.size[:]	/* match ends */
	;;

	type reinst = union
		/* direct consumers */
		`Ibyte	byte
		`Irange	[byte, byte]
		`Idot

		/* groups */
		`Ilbra	std.size
		`Irbra	std.size

		/* control flow */
		`Ifork	[std.size, std.size]
		`Ijmp	std.size
		`Imatch
	;;
;;