 USING: kernel sequences strings fry namespaces math assocs shuffle 
        vectors arrays combinators.lib math.parser match
        unicode.categories sequences.lib compiler.units parser
-       words quotations effects memoize accessors locals effects ;
+       words quotations effects memoize accessors locals effects splitting ;
 IN: peg
 
 USE: prettyprint


: parse-token ( input string -- result )
  #! Parse the string, returning a parse result
  2dup head? [
    dup >r length tail-slice r> <parse-result>
  ] [
    2drop f
  ] if ;

M: token-parser (compile) ( parser -- quot )
  [ \ input-slice , symbol>> , \ parse-token , ] [ ] make ;
   
TUPLE: satisfy-parser quot ;

MATCH-VARS: ?quot ;

: parse-satisfy ( input quot -- result )
  swap dup empty? [

  T{ range-parser _ ?min ?max } range-pattern match-replace ;

TUPLE: seq-parser parsers ;

MATCH-VARS: ?quot ;

: seq-pattern ( -- quot )
  [
