Quasi-quotation API extension?

Forgive me if I am saying obvious things. I will surely make false claims and then someone could be so kind and correct me.

Quasi-quotations are a mechanism for putting arbitrary content within a Prolog source file, capturing Prolog variables from the context, and converting it to a proper Prolog term at compile time. I am not sure what is the correct name for this: it is not compile-time or run-time, it is “writing the code”-time. (help, someone?)

You can and usually want to have content that can be parsed with a formal grammar. The SWI-Prolog implementation helps you by hooking your parser to the compiler and running it at compile time.

Existing parsers:

On the informal end of the spectrum, you have the quasi-quotation syntax for plain strings provided by library(strings), see the source file, close to the top. Jan was kind enough to implement it, maybe provoked by my incessant questions.

You have already found the HTML quasi-quotation parser; just in case, here is the source.

After this too long intro, I think that nothing prevents you from reusing the parsers that quasi-quotations use, without the quasi-quotation mechanism: maybe using it on a user-provided string at run time? Or am I wrong again?

1 Like