-
Notifications
You must be signed in to change notification settings - Fork 37
Description
The payload of Pconst_*
nodes in the Parsetree is changing on a regular basis: Pconst_int changed, now it is the turn of Pconst_string, etc. Having support for literal quotation would be nice as it would let us write version-robust code to create literals or pattern-match on them, in the simple case where we don't need all the data/knobs of the full datatype. (Typically to parse attribute information encoded in literals.)
( @thierry-martinez and myself were discussing this is ocaml-ppx/ppx_deriving_protobuf#36 (comment) )
I would propose the following interface: [%lit.{integer,int,int32,in64,nativeint,float,char,string} <payload>]
, available in both expressions and patterns (with a question mark). This is one quotation per constructor in the Ast_helper.Const
module (suggestion from @thierry-martinez), and I would propose to use the same payload type as the non-default parameter of the constructor (in particular, string
for %lit.integer
and int
for %lit.int
).