]> gitweb.factorcode.org Git - factor.git/commitdiff
peg: Throw an error if nothing at all matches at position 0.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 30 Mar 2016 16:16:02 +0000 (09:16 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 30 Mar 2016 17:16:15 +0000 (10:16 -0700)
basis/peg/peg.factor

index 0a8365899f92b6d81ec0f2affcf80e0f2ebdc387..ac1c525de7e9ddbdca80aaa6ce4769b6db2339bd 100644 (file)
@@ -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 <parse-error> throw ] if* ] unless*
+    ] with-packrat ;
 
 : (parse) ( input parser -- result )
     dup word? [ compile ] unless compiled-parse ;