Get regexp words to infer
parent
d6dd9ea2a3
commit
5c51d9fd2c
|
@ -137,7 +137,7 @@ ERROR: bad-special-group string ;
|
|||
DEFER: (parse-regexp)
|
||||
: nested-parse-regexp ( token ? -- )
|
||||
[ push-stack (parse-regexp) pop-stack ] dip
|
||||
[ <negation> ] when pop-stack boa push-stack ;
|
||||
[ <negation> ] when pop-stack new swap >>term push-stack ;
|
||||
|
||||
! non-capturing groups
|
||||
: (parse-special-group) ( -- )
|
||||
|
|
|
@ -2,6 +2,9 @@ USING: regexp tools.test kernel sequences regexp.parser
|
|||
regexp.traversal eval ;
|
||||
IN: regexp-tests
|
||||
|
||||
\ <regexp> must-infer
|
||||
\ matches? must-infer
|
||||
|
||||
[ f ] [ "b" "a*" <regexp> matches? ] unit-test
|
||||
[ t ] [ "" "a*" <regexp> matches? ] unit-test
|
||||
[ t ] [ "a" "a*" <regexp> matches? ] unit-test
|
||||
|
|
|
@ -107,7 +107,8 @@ M: capture-group-off flag-action ( dfa-traverser flag -- )
|
|||
: increment-state ( dfa-traverser state -- dfa-traverser )
|
||||
[
|
||||
dup traverse-forward>>
|
||||
[ 1+ ] [ 1- ] ? change-current-index
|
||||
[ [ 1+ ] change-current-index ]
|
||||
[ [ 1- ] change-current-index ] if
|
||||
dup current-state>> >>last-state
|
||||
] dip
|
||||
first >>current-state ;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
USING: regexp.utils tools.test ;
|
||||
IN: regexp.utils.tests
|
||||
|
||||
[ [ ] [ ] while-changes ] must-infer
|
|
@ -5,9 +5,7 @@ namespaces regexp.backend sequences unicode.categories
|
|||
math.ranges fry combinators.short-circuit vectors ;
|
||||
IN: regexp.utils
|
||||
|
||||
: (while-changes) ( obj quot pred pred-ret -- obj )
|
||||
! quot: ( obj -- obj' )
|
||||
! pred: ( obj -- <=> )
|
||||
: (while-changes) ( obj quot: ( obj -- obj' ) pred: ( obj -- <=> ) pred-ret -- obj )
|
||||
[ [ dup slip ] dip pick over call ] dip dupd =
|
||||
[ 3drop ] [ (while-changes) ] if ; inline recursive
|
||||
|
||||
|
|
Loading…
Reference in New Issue