I have a file that is just the letter a
. I can "parse" it with this DCG:
identity([]) --> [].
identity([H|T]) --> [H], identity(T).
?- phrase_from_file(identity(X), "jah.txt").
X = [97] ;
false.
This is correct-- but when I add a NUL
byte to my file:
When I attempt to post the above query, Prolog locks up forever. I guess it has to do something with null-terminated strings somewhere, but I'm not sure what to do here-- I'm using DCGs to parse binary files, so I need to be able to deal with null bytes.
I needed to pass type(binary)
as an option to phrase_from_file/3
.
phrase_from_file(identity(X), "jah.txt", [type(binary)]).