peg: Throw an error if nothing at all matches at position 0.

locals-and-roots
Doug Coleman 2016-03-30 09:16:02 -07:00
parent e4df1c8503
commit 26689c3d75
1 changed files with 5 additions and 1 deletions

View 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 ;