From 26689c3d75967c683505032ef59b8d1b4ba0f4f3 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 30 Mar 2016 09:16:02 -0700 Subject: [PATCH] peg: Throw an error if nothing at all matches at position 0. --- basis/peg/peg.factor | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index 0a8365899f..ac1c525de7 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -303,7 +303,11 @@ SYMBOL: delayed ] with-compilation-unit ; : compiled-parse ( state word -- result ) - swap [ execute( -- result ) [ error-stack get first throw ] unless* ] with-packrat ; + swap [ + execute( -- result ) + [ error-stack get ?first [ throw ] + [ pos get input get f throw ] if* ] unless* + ] with-packrat ; : (parse) ( input parser -- result ) dup word? [ compile ] unless compiled-parse ;