   swap [ 
     input set
     0 pos set
+    f lrstack set
+    H{ } clone heads set
     H{ } clone packrat set
   ] H{ } make-assoc swap bind ;
 


:: (grow-lr) ( r p m h -- )
  p pos set
  r eval-rule
  dup fail = pos get m pos>> <= or [
    drop

SYMBOL: pos
SYMBOL: input
SYMBOL: fail
SYMBOL: lrstack
SYMBOL: heads

TUPLE: memo-entry ans pos ;
C: <memo-entry> memo-entry

TUPLE: left-recursion seed rule head next ;
C: <left-recursion> left-recursion
 
TUPLE: peg-head rule involved-set eval-set ;
C: <head> peg-head

: rule-parser ( rule -- parser ) 
  #! A rule is the parser compiled down to a word. It has
  #! a "peg" property containing the original parser.
