Infinite left recursion now causes a failed parser rather than a call stack error

release
Chris Double 2007-11-30 00:01:03 +13:00
parent 3003911e07
commit 38beaac720
1 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,11 @@ PRIVATE>
packrat-cache get [
2dup get-cached dup not-in-cache? [
! "cache missed: " write over parser-id number>string write " - " write nl ! pick .
drop [ (parse) dup ] 2keep put-cached
drop
#! Protect against left recursion blowing the callstack
#! by storing a failed parse in the cache.
[ f ] dipd [ put-cached ] 2keep
[ (parse) dup ] 2keep put-cached
] [
! "cache hit: " write over parser-id number>string write " - " write nl ! pick .
2nip