diff --git a/extra/peg/ebnf/ebnf-tests.factor b/extra/peg/ebnf/ebnf-tests.factor index a511e271c2..aa47d37e55 100644 --- a/extra/peg/ebnf/ebnf-tests.factor +++ b/extra/peg/ebnf/ebnf-tests.factor @@ -144,16 +144,17 @@ IN: peg.ebnf.tests "Z" [EBNF foo=[^A-Z] EBNF] call ] unit-test -[ +{ V{ 49 } } [ #! Test direct left recursion. Currently left recursion should cause a #! failure of that parser. - "1+1" [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call -] must-fail + #! Using packrat, so first part of expr fails, causing 2nd choice to be used + "1+1" [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call parse-result-ast +] unit-test -[ +{ V{ 49 } } [ #! Test indirect left recursion. Currently left recursion should cause a #! failure of that parser. #! Using packrat, so first part of expr fails, causing 2nd choice to be used - "1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call -] must-fail + "1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call parse-result-ast +] unit-test diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 81a9ed8ace..1d2f67f52e 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -67,10 +67,12 @@ C: memo-entry :: apply-non-memo-rule ( r p -- ast ) [let* | + m [ fail p dup p r set-memo ] ans [ r eval-rule ] - m [ ans pos get ] | - m p r set-memo ans + ans m (>>ans) + pos get m (>>pos) + ans ] ; : apply-memo-rule ( m -- ast )