Open progman1 opened 5 years ago
I see back in 2016 the intention was to drop -pp and then in 2018 it was re-introduced but only for source-to-source transformations. why is an AST outputting pre-processor not accepted?
In Dune to support future-syntax we also use a -pp
preprocessor that returns an AST.
The problem we observe is different though: merlin does honor the -pp flag, but it tries to parse the result as an OCaml source file, and reports errors consistent with that.
The relevant -pp flag:
$ cat .merlin | grep -- '-pp'
FLG -pp '.../dune/_boot/install/default/bin/ocaml-syntax-shims -dump-ast'
The error messages:
$ echo "haha" | ocamlmerlin single errors -filename c.ml | jq
{
"class": "return",
"value": [
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 16
},
"type": "typer",
"sub": [],
"valid": true,
"message": "Unbound constructor Caml1999M023����"
},
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 1,
"col": 60
},
"type": "typer",
"sub": [],
"valid": true,
"message": "This expression has type int but an expression was expected of type\n unit\n because it is in the left-hand side of a sequence"
},
{
"start": {
"line": 1,
"col": 16
},
"end": {
"line": 1,
"col": 17
},
"type": "lexer",
"sub": [],
"valid": true,
"message": "Illegal character (\\000)"
},
....
As I followed up with, -pp was re-introduced with source file parsing, not AST. so to those that know, why does merlin not accept an AST?
I have a pre-processor that emits AST and works fine via ocamlc -pp ... In a .merlin file I have "FLG -pp ./yaccy"
Invoking merlin in order to get feedback I do: cat demo.ml |ocamlmerlin single errors "-protocol" "sexp" "-log-file" "-" "-filename" ./demo.ml
merlin picks it up: "flags_applied": [ { "cwd": "./ppocaml", "flags": [ "-pp", "./yaccy" ] } ], "extensions": [],
but doesn't appear to honour it:
{ "start": { "line": 25, "col": 5 }, "end": { "line": 25, "col": 6 }, "type": "parser", "sub": [], "valid": true, "message": "Syntax error, expecting
:'" } ]((assoc) (class . "return") (value ((assoc) (start (assoc) (line . 17) (col . 14)) (end (assoc) (line . 17) (col . 47)) (type . "warning") (sub) (valid . true) (message . "Warning 22: Using modified grammar")) ((assoc) (start (assoc) (line . 25) (col . 5)) (end (assoc) (line . 25) (col . 6)) (type . "parser") (sub) (valid . true) (message . "Syntax error, expecting
:'"))) (notifications) (timing (assoc) (total . 227.522) (query . 8.578) (reader . 196.908) (ppx . 0.265) (typer . 21.625) (error . 0.146)))Am I doing something wrong?