! Copyright (C) 2009 Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license.
-USING: regexp.classes kernel sequences regexp.negation
-quotations assocs fry math locals combinators sets
-accessors words compiler.units kernel.private strings
-sequences.private arrays namespaces unicode.breaks
-regexp.transition-tables combinators.short-circuit ;
+USING: accessors assocs combinators combinators.short-circuit
+kernel kernel.private math namespaces quotations regexp.classes
+regexp.transition-tables sequences sequences.private sets
+strings unicode words ;
IN: regexp.compiler
GENERIC: question>quot ( question -- quot )
} 2&&
] ;
-M: $ question>quot
+M: $crlf question>quot
drop [ { [ length = ] [ ?nth "\r\n" member? ] } 2|| ] ;
-M: ^ question>quot
+M: ^crlf question>quot
drop [ { [ drop zero? ] [ [ 1 - ] dip ?nth "\r\n" member? ] } 2|| ] ;
M: $unix question>quot
[ question>> question>quot ] [ yes>> ] [ no>> ] tri
[ (execution-quot) ] bi@
'[ 2dup @ _ _ if ]
- ] [ '[ _ execute ] ] if ;
+ ] [ 1quotation ] if ;
: execution-quot ( next-state -- quot )
dup sequence? [ first ] when
dup transitions>> keys [ gensym ] H{ } map>assoc
[ transitions-at ]
[ values ]
- bi swap ;
+ bi swap ;
: dfa>main-word ( dfa -- word )
states>words [ states>code ] keep start-state>> ;