X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=basis%2Fregexp%2Fregexp.factor;h=42138d5c66e7792b109f2b1651837fa6e02e496f;hp=b09810c9160d5cadec7499c231c45002ce82f963;hb=2f59f72ed58809c266ad1d2a777be7285d246a06;hpb=93c17a7c2f51540316f432918027fc341dc50a77 diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index b09810c916..42138d5c66 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -1,9 +1,10 @@ ! Copyright (C) 2008, 2009 Doug Coleman, Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays compiler.units kernel kernel.private -lexer make math math.ranges namespaces regexp.ast -regexp.compiler regexp.negation regexp.parser sequences -sequences.private splitting strings vocabs.loader words ; +USING: accessors arrays classes compiler.units kernel +kernel.private lexer make math ranges namespaces quotations +regexp.ast regexp.compiler regexp.negation regexp.parser +sequences sequences.private splitting strings vocabs.loader +words ; IN: regexp TUPLE: regexp @@ -18,7 +19,7 @@ TUPLE: reverse-regexp < regexp ; M: lookahead question>quot ! Returns ( index string -- ? ) - term>> ast>dfa dfa>shortest-word '[ f _ execute ] ; + term>> ast>dfa dfa>shortest-word 1quotation [ f ] prepose ; : ( ast -- reversed ) "r" string>options ; @@ -27,11 +28,7 @@ M: lookbehind question>quot ! Returns ( index string -- ? ) term>> ast>dfa dfa>reverse-shortest-word - '[ [ 1 - ] dip f _ execute ] ; - -: check-string ( string -- string ) - ! Make this configurable - dup string? [ "String required" throw ] unless ; + 1quotation [ [ 1 - ] dip f ] prepose ; : match-index-from ( i string regexp -- index/f ) ! This word is unsafe. It assumes that i is a fixnum @@ -45,7 +42,7 @@ M: reverse-regexp end/start drop length 1 - -1 swap ; PRIVATE> : matches? ( string regexp -- ? ) - [ check-string ] dip + [ string check-instance ] dip [ end/start ] 2keep match-index-from [ = ] [ drop f ] if* ; @@ -53,7 +50,7 @@ PRIVATE>