   { } make seq ; inline 
 
 : choice ( seq -- parser )
-  choice-parser boa init-parser ;
+  choice-parser boa wrap-peg ;
 
 : 2choice ( parser1 parser2 -- parser )
   2array choice ;


TUPLE: parse-result remaining ast ;
TUPLE: parse-error position messages ; 
TUPLE: parser id compiled ;
M: parser equal? [ id>> ] bi@ = ;

M: parser hashcode* id>> hashcode* ;

C: <parse-result>  parse-result
C: <parse-error> parse-error
C: <parser>        parser

M: parse-error error.
  "Peg parsing error at character position " write dup position>> number>string write 

  { } make choice ; inline 

: repeat0 ( parser -- parser )
  repeat0-parser boa wrap-peg ;

: repeat1 ( parser -- parser )
  repeat1-parser boa wrap-peg ;

: optional ( parser -- parser )
  optional-parser boa wrap-peg ;

: semantic ( parser quot -- parser )
  semantic-parser boa wrap-peg ;

: ensure ( parser -- parser )
  ensure-parser boa wrap-peg ;

: ensure-not ( parser -- parser )
  ensure-not-parser boa wrap-peg ;

: action ( parser quot -- parser )
  action-parser boa wrap-peg ;

: sp ( parser -- parser )
  sp-parser boa wrap-peg ;

: hide ( parser -- parser )
  [ drop ignore ] action ;

: delay ( quot -- parser )
  delay-parser boa wrap-peg ;

: box ( quot -- parser )
  #! because a box has its quotation run at compile time
  #! it must always have a new parser wrapper created, 
  #! not a cached one. This is because the same box,
  #! compiled twice can have a different compiled word
  #! due to running at compile time.
