diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-04-13 00:45:52 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-04-13 00:45:52 -0700 |
commit | 5665ec50835d983ecfd73e669864ab75a65f4461 (patch) | |
tree | 784a9e1f194744234d0049d048329719f23c1048 /libregex/types.myr | |
parent | 7c4f9de24d02cf599d4ef1c0e38e5112b0873e97 (diff) | |
download | mc-5665ec50835d983ecfd73e669864ab75a65f4461.tar.gz |
Move code to subdir in preparation for merging with mc.
Diffstat (limited to 'libregex/types.myr')
-rw-r--r-- | libregex/types.myr | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libregex/types.myr b/libregex/types.myr new file mode 100644 index 0000000..24e9842 --- /dev/null +++ b/libregex/types.myr @@ -0,0 +1,63 @@ +use std + +pkg regex = + type status = union + `Noimpl + `Incomplete + `Unbalanced + `Emptyparen + `Badrep + `Badrange + `Badescape + ;; + + type regex = struct + /* compile state */ + debug : bool + pat : byte[:] + nmatch : std.size + + /* VM state */ + runq : rethread# + expired : rethread# + expiredtail : rethread# + proglen : std.size + prog : reinst[:] + nthr : std.size + str : byte[:] + strp : std.size + ;; + + type rethread = struct + next : rethread# /* run queue link */ + + tid : std.size /* just for debugging */ + ip : std.size /* the instruction pointer */ + dead : bool /* thread died */ + matched : bool /* thread matched */ + + mstart : std.size[:] /* match starts */ + mend : std.size[:] /* match ends */ + ;; + + type reinst = union + /* direct consumers */ + `Ibyte byte + `Irange (byte, byte) + + /* groups */ + `Ilbra std.size + `Irbra std.size + + /* anchors */ + `Ibol + `Ieol + `Ibow + `Ieow + + /* control flow */ + `Ifork (std.size, std.size) + `Ijmp std.size + `Imatch + ;; +;; |