diff --git a/extra/peg/peg-tests.factor b/extra/peg/peg-tests.factor index bd4699f097..bd8abb63e6 100644 --- a/extra/peg/peg-tests.factor +++ b/extra/peg/peg-tests.factor @@ -175,6 +175,8 @@ IN: peg.tests [ "1" token , "+" token , "1" token , ] seq* , ] choice* "1-1" over parse parse-result-ast swap - "1+1" swap parse parse-result-ast ] with-packrat + [ + "1+1" swap parse parse-result-ast + ] with-packrat ] unit-test \ No newline at end of file diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index bbd55ec6fa..1361f9fdbd 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -34,12 +34,12 @@ GENERIC: (compile) ( parser -- quot ) #! that maps the input string position to the parser result. [ drop H{ } clone ] cache ; -: cached-result ( n input-cache input quot -- result ) +:: cached-result ( n input-cache input quot -- result ) #! Get the cached result for input position n #! from the input cache. If the item is not in the cache, #! call 'quot' with 'input' on the stack to get the result #! and store that in the cache and return it. - [ nip ] swap compose curry cache ; inline + n input-cache [ drop input quot call ] cache ; inline :: run-packrat-parser ( input quot c -- result ) input input-from