shithub: mc

ref: 0529dbb64b33733ef6caeb7403e708e49e8f1b36
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[:]
		/* 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 */

		mactive	: std.size[:]	/* stack of active matches */
		mstart	: std.size[:]	/* match starts */
		mend	: std.size[:]	/* match ends */
	;;

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

		/* groups */


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