camlp4 パーサーでderiving-ocsigen構文拡張を使用すると問題が発生します。私のパーサーは呼び出されますpa_debug.ml
タグファイルは次のとおりです。
<pa_debug.ml>: pp(camlp4orf.opt), package(deriving-ocsigen.syntax), syntax(camlp4o)
でコンパイルすると
ocamlbuild -libs dynlink,camlp4lib,deriving -cflags -I,+camlp4,-dtypes -lflags -I,+camlp4,-dtypes -use-ocamlfind pa_debug.cmo
次のエラーが表示されます。
Warning: -pp overrides the effect of -syntax partly
File "pa_debug.ml", line 103, characters 66-67:
While expanding quotation "expr" in a position of "expr":
Parse error: [expr] expected after [infix operator (level 0) (comparison operators, and some others)] (in [expr])
このコード スニペットの 2 行目でエラーが発生します。
...
let fun_id = get_fun_id bi in
let app = <:expr< Debug.ho_1 $str:fun_id$ (Show.show<int>) (Show.show<int>) >> in
let debug_fun_body = mk_appln _loc app new_patts in
...
コードでは、派生の構文を引用符で使用するように入力しています。しかし、プリプロセッサは引用符内の「<」と「>」比較演算子の存在を理解していないようです。Show.show<int>
別のファイルで引用符なしで構文を使用すると、エラーなしでコンパイルされます。
問題を解決するための解決策を見てきました-pp overrides the effect of -syntax
が、理解できません。誰かが私にそれを説明したり、それを修正する他の方法を提案したりできますか?