Use library(codesio)
:
| ?- use_module(library(codesio)).
yes
?- set_prolog_flag(double_quotes,codes).
true.
| ?- read_from_codes("a(X,Y).",T).
T = a(_A,_B) ? yes
| ?- read_term_from_codes("a(X,Y).",T,[variable_names(VN_list)]).
T = a(_A,_B),
VN_list = ['X'=_A,'Y'=_B] ?
In addition to that, you need atom_codes/2
which is ISO.
For more complex operations, you can open a stream with open_codes_stream/2
. Which needs to be closed with close/1
.