Making all the regexp words compile
parent
72c4736936
commit
6ccd58f278
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue