I’m using: SWI-Prolog version 8.3.20
I have a file with the following line:
% Target: ability/2
Suppose I’d like to parse it with the following grammar:
:- use_module(library(dcg/basics)). target(T) --> comment, blank, `Target:`, blanks, predicate_symbol(T). comment --> `%`. predicate_symbol(F/A) --> string(F), `/`, integer(A).
?- phrase(target(_Cs/A), `% Target: ability/2`), atom_codes(T, _Cs). A = 2, T = ability .
?- phrase_from_file(target(T), 'my_file.log'). false.
How can I make phrase_from_file/2 succeed?
Note that the example of ‘file_contains/3’ in the documentation only shows how to count occurrences of a pattern but I want to bind variables in the output. Is this possible with phrase_from_file/2?