From 811026ce4d7b61863e51144b284ec99e59c5e6cd Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 6 Nov 2008 13:16:33 -0600 Subject: [PATCH] removing some uses of at* in favor of at, simplifying code --- basis/regexp/regexp-tests.factor | 1 - basis/regexp/regexp.factor | 2 -- basis/regexp/traversal/traversal.factor | 11 +++++------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/basis/regexp/regexp-tests.factor b/basis/regexp/regexp-tests.factor index 46696c8c0f..2339628801 100644 --- a/basis/regexp/regexp-tests.factor +++ b/basis/regexp/regexp-tests.factor @@ -331,4 +331,3 @@ IN: regexp-tests [ { 0 3 } ] [ "abc" "(ab|a)(bc)?" first-match ] unit-test [ { 23 24 } ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" first-match ] unit-test - diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index 73555fe953..083a48a470 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -92,7 +92,6 @@ IN: regexp reversed-regexp initial-option construct-regexp ; - : parsing-regexp ( accum end -- accum ) lexer get dup skip-blank [ [ 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 - : find-regexp-syntax ( string -- prefix suffix ) { { "R/ " "/" } diff --git a/basis/regexp/traversal/traversal.factor b/basis/regexp/traversal/traversal.factor index 346d77e918..91c7ce16dc 100644 --- a/basis/regexp/traversal/traversal.factor +++ b/basis/regexp/traversal/traversal.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs combinators kernel math math.ranges 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 TUPLE: dfa-traverser @@ -23,8 +24,7 @@ TUPLE: dfa-traverser [ dfa-table>> ] [ dfa-traversal-flags>> ] bi dfa-traverser new swap >>traversal-flags - swap [ start-state>> >>current-state ] keep - >>dfa-table + swap [ start-state>> >>current-state ] [ >>dfa-table ] bi swap >>text t >>traverse-forward 0 >>start-index @@ -116,7 +116,7 @@ M: capture-group-off flag-action ( dfa-traverser flag -- ) V{ } clone >>matches ; : 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 ) transitions>> at* [ @@ -124,8 +124,7 @@ M: capture-group-off flag-action ( dfa-traverser flag -- ) ] [ drop ] if ; : match-default ( transition from-state table -- to-state/f ) - [ nip ] dip transitions>> at* - [ t swap at* [ ] [ drop f ] if ] [ drop f ] if ; + nipd transitions>> at t swap at ; : match-transition ( obj from-state dfa -- to-state/f ) { [ match-literal ] [ match-class ] [ match-default ] } 3|| ;