allow |b b| || regexps
parent
96afddc72b
commit
7724ad2387
|
@ -31,3 +31,7 @@ IN: regexp2.parser
|
|||
[ ] [ "[a-c]" test-regexp ] unit-test
|
||||
[ ] [ "[^a-c]" test-regexp ] unit-test
|
||||
[ "[^]" test-regexp ] must-fail
|
||||
|
||||
[ ] [ "|b" test-regexp ] unit-test
|
||||
[ ] [ "b|" test-regexp ] unit-test
|
||||
[ ] [ "||" test-regexp ] unit-test
|
||||
|
|
|
@ -67,7 +67,7 @@ left-parenthesis pipe caret dash ;
|
|||
: <negation> ( obj -- negation ) negation boa ;
|
||||
: <concatenation> ( seq -- concatenation )
|
||||
>vector get-reversed-regexp [ reverse ] when
|
||||
concatenation boa ;
|
||||
[ epsilon ] [ concatenation boa ] if-empty ;
|
||||
: <alternation> ( seq -- alternation ) >vector alternation boa ;
|
||||
: <capture-group> ( obj -- capture-group ) capture-group boa ;
|
||||
: <kleene-star> ( obj -- kleene-star ) kleene-star boa ;
|
||||
|
|
|
@ -14,6 +14,13 @@ IN: regexp2-tests
|
|||
[ t ] [ "c" "a|b|c" <regexp> matches? ] unit-test
|
||||
[ f ] [ "c" "d|e|f" <regexp> matches? ] unit-test
|
||||
|
||||
[ t ] [ "b" "|b" <regexp> matches? ] unit-test
|
||||
[ t ] [ "b" "b|" <regexp> matches? ] unit-test
|
||||
[ t ] [ "" "b|" <regexp> matches? ] unit-test
|
||||
[ t ] [ "" "b|" <regexp> matches? ] unit-test
|
||||
[ f ] [ "" "|" <regexp> matches? ] unit-test
|
||||
[ f ] [ "" "|||||||" <regexp> matches? ] unit-test
|
||||
|
||||
[ f ] [ "aa" "a|b|c" <regexp> matches? ] unit-test
|
||||
[ f ] [ "bb" "a|b|c" <regexp> matches? ] unit-test
|
||||
[ f ] [ "cc" "a|b|c" <regexp> matches? ] unit-test
|
||||
|
|
Loading…
Reference in New Issue