Skip to content

metaquot feature request: literal quotations #83

Description

@gasche

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions