我正在使用带有MLast
模块的camlp5。我想知道嵌套深度大于 1 的反引号的语法。我将用一个模拟示例进行解释。假设我有
let f1 e = <:expr< 3 * $e$ >>
let f2 e = <:expr< $e$ + 1 >>
let f3 e = <:expr< $e$ / 2 >>
let f123 e = f3 (f2 (f1 e))
如何一口气定义f123
?我只能做两部分
let f12 e = <:expr< $<:expr< 3 * \$e\$ >>$ + 1 >>
请注意内部反引号中的强制反斜杠。但是对于三个部分?以下都不起作用:
let f123 e = <:expr< $<:expr< \$<:expr< 3* \$e\$ >>\$ + 1 >>$ / 2 >>
let f123 e = <:expr< $<:expr< \$<:expr< 3* \\$e\\$ >>\$ + 1 >>$ / 2 >>
let f123 e = <:expr< $<:expr< \$<:expr< 3* \\\$e\\\$ >>\$ + 1 >>$ / 2 >>
相应的错误消息是:
Uncaught exception: Pcaml.Qerror ("expr", 1, _)
Uncaught exception: Pcaml.Qerror ("expr", 1, _)
Parse error: end of input expected after [expr] (in [expr_eoi])
我在文档中找不到任何内容。
(PS 当然我知道在这个特定的例子中我可以省略内部的反引号/引号对。这是题外话;这是由于模拟示例中固有的过度简化。)