caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chet Murthy <murthy.chet@gmail.com>
To: caml-list@inria.fr
Cc: chetsky@gmail.com
Subject: [Caml-list] char/line-numbers in error-messages from data-structures bulit via ocamllex?
Date: Mon, 24 Apr 2017 13:18:04 -0700	[thread overview]
Message-ID: <2183504.2kfSNf9Hln@twitter> (raw)

Ages (decades) ago, I recall (perhaps incorrectly) that there was a
somewhat well-known way of using ocamllex and {ocamlyacc, PP streams}
together, in order to decorate a parse-tree with line-number
information -- so that later (e.g. type-checking) passes could emit
that line-number information as part of error-messages.

As I rack my brain trying to imagine what that method might be,
several approaches come to mind:

(1) with PP streams, I could define the token-type to be a tuple of
the real token-type and a lexing position, e.g.

type token = real_token * Lexing.position

(2) with camlyacc, I'd have to stuff the position into every branch of
the algebraic datatype, e.g.

type token =
| LIT of Lexing.position * literal
| ID of Lexing.position * identifier
| OP of Lexing.position * operator
...

Both of these seem workable, but I don't remember either of them as
being "the" way to do it, back in the day.

Does anybody have any memory of this "Echte" way of doing it?

Thanks,
--chet--


             reply	other threads:[~2017-04-24 20:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 20:18 Chet Murthy [this message]
2017-04-24 20:30 ` François Pottier

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=2183504.2kfSNf9Hln@twitter \
    --to=murthy.chet@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=chetsky@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).