By “unescaped” I mean something like:
a /\ b =>
c
Note that the newline is literally newline not “\n” and the backslash is not escaped. Is it possible to write this in a ppx expansion and capture the string literal from it?
By “unescaped” I mean something like:
a /\ b =>
c
Note that the newline is literally newline not “\n” and the backslash is not escaped. Is it possible to write this in a ppx expansion and capture the string literal from it?
The payload
type declared in parsetree.mli
does not seem to allow it. I guess one needs to work with the lexer if one wants the raw text quotation instead of working with the parsetree
.
(/\)
…If you just want the string itself, can’t you just use the string literal syntax:
let x = {|a /\ b =>
c
|}
If you instead are trying to get a raw string to use within a ppx rewriter, you can reuse the string literal syntax no?:
let x = {%my_ppx|a /\ b =>
c
|}
I need to write a ppx rewriter. I didn’t come across any reference on this. Thanks! I will give it a try:
The quoted string syntax for extension node ({%ext|...|}
and {%%ext|...|}
) is described in the extension node section of the manual.
I was able to get this to work
let t = [%q{|a /\ b|}];;
in utop
, but utop
didn’t accept the shorthand version.
Cool! Thanks!
The shorthand version was only added in 4.11.0, this is probably the reason it is not working in utop
for you.
That must be it. I am still on 4.10.2.