 : parser-body ( parser -- quot )
   #! Return the body of the word that is the compiled version
   #! of the parser.
-  gensym 2dup swap peg>> (compile) 0 1 <effect> define-declared swap dupd "peg" set-word-prop
+  gensym 2dup swap peg>> (compile) 0 1 <effect> define-declared swap dupd id>> "peg-id" set-word-prop
   [ execute-parser ] curry ;
 
 : compiled-parser ( parser -- word )

  #! Return the index from the original string that the
  #! input slice is based on.
  dup slice? [ slice-from ] [ drop 0 ] if ;

: input-cache ( parser -- cache )
  #! From the packrat cache, obtain the cache for the parser 
  #! that maps the position to the parser result.
  id>> packrat get [ drop H{ } clone ] cache ;

: process-rule-result ( p result -- result )
  [

    nip
  ] if ; 

USE: prettyprint

: apply-rule ( r p -- ast )
!   2dup [ rule-id ] dip 2array "apply-rule: " write .
   2dup recall [
!     "  memoed" print
     nip apply-memo-rule
   ] [
!     "  not memoed" print
     apply-non-memo-rule
   ] if* ; inline

