! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators kernel math math.ranges sequences regexp2.backend regexp2.utils memoize sets regexp2.parser regexp2.nfa regexp2.dfa regexp2.traversal regexp2.transition-tables ; IN: regexp2 : default-regexp ( string -- regexp ) regexp new swap >>raw >>nfa-table >>dfa-table >>minimized-table reset-regexp ; : construct-regexp ( regexp -- regexp' ) { [ parse-regexp ] [ construct-nfa ] [ construct-dfa ] [ ] } cleave ; : match ( string regexp -- pair ) do-match return-match ; : matches? ( string regexp -- ? ) dupd match [ [ length ] [ range-length 1- ] bi* = ] [ drop f ] if* ; : match-head ( string regexp -- end ) match length>> 1- ; : initial-option ( regexp option -- regexp' ) over options>> conjoin ; : ( string -- regexp ) default-regexp construct-regexp ; : ( string -- regexp ) default-regexp case-insensitive initial-option construct-regexp ; : ( string -- regexp ) default-regexp reversed-regexp initial-option construct-regexp ; : R! CHAR: ! ; parsing : R" CHAR: " ; parsing : R# CHAR: # ; parsing : R' CHAR: ' ; parsing : R( CHAR: ) ; parsing : R/ CHAR: / ; parsing : R@ CHAR: @ ; parsing : R[ CHAR: ] ; parsing : R` CHAR: ` ; parsing : R{ CHAR: } ; parsing : R| CHAR: | ; parsing