     swapd first2 swap [ substring-list ] keep void* <c-direct-array>
     [ utf8 alien>string ] { } map-as [ of swap 2array ] with map-index ;
 
-! High-level
+PRIVATE>
+
+TUPLE: compiled-pcre pcre extra nametable ;
+
 : <compiled-pcre> ( expr -- compiled-pcre )
     <pcre> dup <pcre-extra> 2dup name-table-entries compiled-pcre boa ;
 

: next-utf8-char ( byte-array pos -- pos' )
    1 + 2dup swap ?nth
    [ utf8-start-byte? [ nip ] [ next-utf8-char ] if ] [ 2drop f ] if* ;

: fullinfo ( pcre extra what -- obj )
    { int } [ pcre_fullinfo ] with-out-parameters nip ;

    [ <alien> 1 alien-unsigned-1 ] 
    [ 2 + <alien> utf8 alien>string ] bi ; 

: options ( pcre -- opts )
    f PCRE_INFO_OPTIONS fullinfo ;

: name-table-entries ( pcre extra -- addrs )
    [ name-table ] [ name-entry-size ] [ name-count ] 2tri
    gen-array-addrs [ name-table-entry 2array ] map ;

CONSTANT: default-opts flags{ PCRE_UTF8 PCRE_UCP }

: (pcre) ( expr -- pcre err-message err-offset )
    default-opts { c-string int } [ f pcre_compile ] with-out-parameters ;
