peg refactorings

db4
Chris Double 2008-03-27 17:24:05 +13:00
parent 8bd7c51c10
commit bc5f82255f
1 changed files with 6 additions and 1 deletions

View File

@ -24,8 +24,13 @@ SYMBOL: packrat
GENERIC: (compile) ( parser -- quot ) GENERIC: (compile) ( parser -- quot )
: input-from ( input -- n )
#! Return the index from the original string that the
#! input slice is based on.
dup slice? [ slice-from ] [ drop 0 ] if ;
:: run-packrat-parser ( input quot c -- result ) :: run-packrat-parser ( input quot c -- result )
input slice? [ input slice-from ] [ 0 ] if input input-from
quot c [ drop H{ } clone ] cache quot c [ drop H{ } clone ] cache
[ [
drop input quot call drop input quot call