transitions>quot ;
: states>code ( words dfa -- )
- '[
+ [ ! with-compilation-unit doesn't compile, so we need call( -- )
[
- dup _ word>quot
- (( last-match index string -- ? ))
- define-declared
- ] each
- ] with-compilation-unit ;
+ '[
+ dup _ word>quot
+ (( last-match index string -- ? ))
+ define-declared
+ ] each
+ ] with-compilation-unit
+ ] call( words dfa -- ) ;
: states>words ( dfa -- words dfa )
dup transitions>> keys [ gensym ] H{ } map>assoc
IN: regexp-tests
\ <regexp> must-infer
-! the following don't compile because [ ] with-compilation-unit doesn't compile
-! \ compile-regexp must-infer
-! \ matches? must-infer
+\ compile-regexp must-infer
+\ matches? must-infer
[ f ] [ "b" "a*" <regexp> matches? ] unit-test
[ t ] [ "" "a*" <regexp> matches? ] unit-test