1Regex: module { 2 3 PATH: con "/dis/lib/regex.dis"; 4 5# normally imported identifiers 6 7 Re: type ref Arena; 8 compile: fn(nil:string,nil:int): (Re, string); 9 execute: fn(nil:Re, nil:string): array of (int, int); 10 executese: fn(nil:Re, nil:string, se: (int, int), bol: int, eol: int): array of (int, int); 11 12# internal identifiers, not normally imported 13 14 ALT, CAT, DOT, SET, HAT, DOL, NUL, PCLO, CLO, OPT, LPN, RPN : con (1<<16)+iota; 15 16 refRex : type int; # used instead of ref Rex to avoid circularity 17 18 Set: adt { # character class 19 neg: int; # 0 or 1 20 ascii : array of int; # ascii members, bit array 21 unicode : list of (int,int); # non-ascii char ranges 22 }; 23 24 Rex: adt { # node in parse of regex, or state of fsm 25 kind : int; # kind of node: char or ALT, CAT, etc 26 left : refRex; # left descendant 27 right : refRex; # right descendant, or next state 28 set : ref Set; # character class 29 pno : int; 30 }; 31 32 Arena: adt { # free store from which nodes are allocated 33 rex : array of Rex; 34 ptr : refRex; # next available space 35 start : refRex; # root of parse, or start of fsm 36 pno : int; 37 }; 38}; 39