Using the latest SWI-Prolog. I want to use quasi-quotations for more complicated stuff, but first, I would like to understand how to make the easiest thing.
So, I tried like this:
:- quasi_quotation_syntax(multiline).
multiline(Content, _Vars, _Dict, R) :-
with_quasi_quotation_input(Content, Stream, read_string(Stream, _, R)).
foo(X) :-
X = {|multiline||
This is supposed to be
a "string" over multiple lines.
But what happens _really_?
We'll see.
|}.
Now, this works. I now have a multiline string with quotes in it and so on.
?- foo(X), format("~s~n", [X]).
This is supposed to be
a "string" over multiple lines.
But what happens _really_?
We'll see.
X = "\n This is supposed to be\n a \"string\" over multiple lines.\n\n But what happens _really_?\n We'll see.\n ".
A few somewhat related questions, out of ignorance:
-
Is there an âautomaticâ way to get rid of the leading space or do I have to handle it in my quasi-quotation parser?
-
Is there a preferred way of indenting this inside the Prolog code? PceEmacs suggests I do it like this:
baz(X) :-
X = {|multiline||
line
another line
|}.
Any pointers appreciated.
PS: what is the preferred nomenclature? âQuasi quotationsâ as two separate words?