removing some uses of at* in favor of at, simplifying code
parent
666100a07b
commit
811026ce4d
basis/regexp
|
@ -331,4 +331,3 @@ IN: regexp-tests
|
||||||
[ { 0 3 } ] [ "abc" "(ab|a)(bc)?" <regexp> first-match ] unit-test
|
[ { 0 3 } ] [ "abc" "(ab|a)(bc)?" <regexp> first-match ] unit-test
|
||||||
|
|
||||||
[ { 23 24 } ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" <regexp> first-match ] unit-test
|
[ { 23 24 } ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" <regexp> first-match ] unit-test
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ IN: regexp
|
||||||
reversed-regexp initial-option
|
reversed-regexp initial-option
|
||||||
construct-regexp ;
|
construct-regexp ;
|
||||||
|
|
||||||
|
|
||||||
: parsing-regexp ( accum end -- accum )
|
: parsing-regexp ( accum end -- accum )
|
||||||
lexer get dup skip-blank
|
lexer get dup skip-blank
|
||||||
[ [ index-from dup 1+ swap ] 2keep swapd subseq swap ] change-lexer-column
|
[ [ index-from dup 1+ swap ] 2keep swapd subseq swap ] change-lexer-column
|
||||||
|
@ -112,7 +111,6 @@ IN: regexp
|
||||||
: R{ CHAR: } parsing-regexp ; parsing
|
: R{ CHAR: } parsing-regexp ; parsing
|
||||||
: R| CHAR: | parsing-regexp ; parsing
|
: R| CHAR: | parsing-regexp ; parsing
|
||||||
|
|
||||||
|
|
||||||
: find-regexp-syntax ( string -- prefix suffix )
|
: find-regexp-syntax ( string -- prefix suffix )
|
||||||
{
|
{
|
||||||
{ "R/ " "/" }
|
{ "R/ " "/" }
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs combinators kernel math math.ranges
|
USING: accessors assocs combinators kernel math math.ranges
|
||||||
quotations sequences regexp.parser regexp.classes fry arrays
|
quotations sequences regexp.parser regexp.classes fry arrays
|
||||||
combinators.short-circuit regexp.utils prettyprint regexp.nfa ;
|
combinators.short-circuit regexp.utils prettyprint regexp.nfa
|
||||||
|
shuffle ;
|
||||||
IN: regexp.traversal
|
IN: regexp.traversal
|
||||||
|
|
||||||
TUPLE: dfa-traverser
|
TUPLE: dfa-traverser
|
||||||
|
@ -23,8 +24,7 @@ TUPLE: dfa-traverser
|
||||||
[ dfa-table>> ] [ dfa-traversal-flags>> ] bi
|
[ dfa-table>> ] [ dfa-traversal-flags>> ] bi
|
||||||
dfa-traverser new
|
dfa-traverser new
|
||||||
swap >>traversal-flags
|
swap >>traversal-flags
|
||||||
swap [ start-state>> >>current-state ] keep
|
swap [ start-state>> >>current-state ] [ >>dfa-table ] bi
|
||||||
>>dfa-table
|
|
||||||
swap >>text
|
swap >>text
|
||||||
t >>traverse-forward
|
t >>traverse-forward
|
||||||
0 >>start-index
|
0 >>start-index
|
||||||
|
@ -116,7 +116,7 @@ M: capture-group-off flag-action ( dfa-traverser flag -- )
|
||||||
V{ } clone >>matches ;
|
V{ } clone >>matches ;
|
||||||
|
|
||||||
: match-literal ( transition from-state table -- to-state/f )
|
: match-literal ( transition from-state table -- to-state/f )
|
||||||
transitions>> at* [ at ] [ 2drop f ] if ;
|
transitions>> at at ;
|
||||||
|
|
||||||
: match-class ( transition from-state table -- to-state/f )
|
: match-class ( transition from-state table -- to-state/f )
|
||||||
transitions>> at* [
|
transitions>> at* [
|
||||||
|
@ -124,8 +124,7 @@ M: capture-group-off flag-action ( dfa-traverser flag -- )
|
||||||
] [ drop ] if ;
|
] [ drop ] if ;
|
||||||
|
|
||||||
: match-default ( transition from-state table -- to-state/f )
|
: match-default ( transition from-state table -- to-state/f )
|
||||||
[ nip ] dip transitions>> at*
|
nipd transitions>> at t swap at ;
|
||||||
[ t swap at* [ ] [ drop f ] if ] [ drop f ] if ;
|
|
||||||
|
|
||||||
: match-transition ( obj from-state dfa -- to-state/f )
|
: match-transition ( obj from-state dfa -- to-state/f )
|
||||||
{ [ match-literal ] [ match-class ] [ match-default ] } 3|| ;
|
{ [ match-literal ] [ match-class ] [ match-default ] } 3|| ;
|
||||||
|
|
Loading…
Reference in New Issue