Making all the regexp words compile

db4
Daniel Ehrenberg 2009-03-09 17:29:32 -05:00
parent 72c4736936
commit 6ccd58f278
2 changed files with 10 additions and 9 deletions

View File

@ -106,13 +106,15 @@ C: <box> box
transitions>quot ; transitions>quot ;
: states>code ( words dfa -- ) : states>code ( words dfa -- )
'[ [ ! with-compilation-unit doesn't compile, so we need call( -- )
[ [
dup _ word>quot '[
(( last-match index string -- ? )) dup _ word>quot
define-declared (( last-match index string -- ? ))
] each define-declared
] with-compilation-unit ; ] each
] with-compilation-unit
] call( words dfa -- ) ;
: states>words ( dfa -- words dfa ) : states>words ( dfa -- words dfa )
dup transitions>> keys [ gensym ] H{ } map>assoc dup transitions>> keys [ gensym ] H{ } map>assoc

View File

@ -5,9 +5,8 @@ eval strings multiline accessors regexp.matchers ;
IN: regexp-tests IN: regexp-tests
\ <regexp> must-infer \ <regexp> must-infer
! the following don't compile because [ ] with-compilation-unit doesn't compile \ compile-regexp must-infer
! \ compile-regexp must-infer \ matches? must-infer
! \ matches? must-infer
[ f ] [ "b" "a*" <regexp> matches? ] unit-test [ f ] [ "b" "a*" <regexp> matches? ] unit-test
[ t ] [ "" "a*" <regexp> matches? ] unit-test [ t ] [ "" "a*" <regexp> matches? ] unit-test