caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Ojeda Bar <nicolas.ojeda.bar@lexifi.com>
To: caml-list@inria.fr
Subject: [Caml-list] ocamllex and polymorphic recursion
Date: Sat, 14 May 2016 21:50:47 +0200	[thread overview]
Message-ID: <CADK7aFMqvvLmO6jza3Sh_c_bn64tTtjbDQzvLjmFLs2EKA0zAw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

Hi list,

I am trying to write a parser using ocamllex for a language for which the
usual character -> token -> ast does not make sense and instead one needs
to produce the ast directly from the character level.

Even though this is not its intended use case, it actually works quite
well! Except that, while I can define higher-order rules, such as

  rule sp item = parse
  | ' ' { item lexbuf }

I cannot actually use such a rule for 'item's which return different
types.  As far as I can see this is because the set of all rules is
translated into a set of recursively defined functions and using 'sp' with
'items' of different types would require the function corresponding to 'sp'
to have some explicit polymorphism annotation.

Is there a way to twist ocamllex a little more to make this work ?  Or if
not, would it make sense to expose a way for the user to provide these
annotations herself ?

Thanks!

- Nicolas

[-- Attachment #2: Type: text/html, Size: 1176 bytes --]

             reply	other threads:[~2016-05-14 19:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-14 19:50 Nicolas Ojeda Bar [this message]
2016-05-14 21:29 ` Frédéric Bour
2016-05-15 10:32   ` Nicolas Ojeda Bar

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=CADK7aFMqvvLmO6jza3Sh_c_bn64tTtjbDQzvLjmFLs2EKA0zAw@mail.gmail.com \
    --to=nicolas.ojeda.bar@lexifi.com \
    --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;
as well as URLs for NNTP newsgroup(s).