From: "Matej Košík" <mail@matej-kosik.net>
To: caml-list@inria.fr
Subject: [Caml-list] how to get location of a polymorphic variant via compiler libs
Date: Thu, 19 Oct 2017 12:55:26 +0200 [thread overview]
Message-ID: <59fb8cd9-0b10-b3a8-7ebf-d7a0b5d1583a@matej-kosik.net> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 541 bytes --]
Hi,
I am using compiler-libs for getting locations of lexical items I am interested in.
(modules, values, types, non-polymorphic variants, record labels).
If I have a code like this:
type t = [`Foo | `Bar]
does the parse-tree hold the location of "`Foo" (or "`Bar") somewhere?
(I am not interested in the location of the whole type definition --- just the location of a specific polymorphic variant/constructor.)
The attachment display the available parse-tree I can see
(and not able to find bits I am interested in)
[-- Attachment #1.1.2: parsetree.txt --]
[-- Type: text/plain, Size: 1537 bytes --]
val structure : Parsetree.structure =
[{pstr_desc =
Pstr_type (Asttypes.Recursive,
[{ptype_name =
{Asttypes.txt = "t";
loc =
{loc_start =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 5};
loc_end =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 6};
loc_ghost = false}};
ptype_params = []; ptype_cstrs = []; ptype_kind = Ptype_abstract;
ptype_private = Asttypes.Public;
ptype_manifest =
Some
{ptyp_desc =
Ptyp_variant
([Rtag ("Foo", [], true, []); Rtag ("Bar", [], true, [])],
Asttypes.Closed, None);
ptyp_loc =
{loc_start =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0;
pos_cnum = 9};
loc_end =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0;
pos_cnum = 22};
loc_ghost = false};
ptyp_attributes = []};
ptype_attributes = [];
ptype_loc =
{loc_start =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0};
loc_end =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 22};
loc_ghost = false}}]);
pstr_loc =
{loc_start =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0};
loc_end =
{Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 22};
loc_ghost = false}}]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next reply other threads:[~2017-10-19 10:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 10:55 Matej Košík [this message]
2017-10-19 11:01 ` Thomas Refis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59fb8cd9-0b10-b3a8-7ebf-d7a0b5d1583a@matej-kosik.net \
--to=mail@matej-kosik.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox