Type casts not recognized in ppx
rixed opened this issue · comments
Exemple:
# #require "bitstring";;
# open Bitstring;;
# let x = 42;;
val x : int = 42
# #require "bitstring.ppx";;
# let%bitstring b = {| x : 6 |};;
val b : Bitstring.bitstring = (Bytes.of_string "\168", 0, 6)
# let%bitstring b = {| (x :> int) : 6 |};;
Error: Invalid qualifiers list
Yes, I can see how :>
would be a problem. The parser for the content of {| |}
is very primitive and simply splits the verbatim string using the :
delimiter. I can probably come up with a workaround for the :>
operator.
Your latest patch works for me.
But for a last annoying error: comments are not allowed within match%bitstring patterns.
Not a big deal but the error message can be a bit confusing.
comments are not allowed within match%bitstring patterns
Yes, that's to be expected. The parser is quite dumb. I've been pondering over using menhir
to make the parser a bit more friendly and ruled against it to avoid having to implement and actual OCaml parser.
Regardless, I'll reopen that question and link your comment to it.
Well, thank you anyway, for answering and fixing the parser so fast for my issue.