caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Andrej Bauer <andrej.bauer@andrej.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Agda-style parser
Date: Fri, 6 Jul 2012 16:32:58 +0200	[thread overview]
Message-ID: <CAPFanBFUnoNC5wJPFjO1WUoh6hEmW9sXOJMeNjmqGn983bt9Tg@mail.gmail.com> (raw)
In-Reply-To: <CAB0nkh33fuZyCMx78fkwgTLQ7SmtNjzjQhfP6PLr-R52N2doTw@mail.gmail.com>

My advice would be to mimic Agda's conceptual two-pass process: parse
only the static Context-Free Language structure of your language,
parsing "expressions" (or any syntactic class that admits mixfixes)
into just a list of non-terminals (plus parenthesing, if you assume
your mixfixes are all well-balanced wrt. symmetric delimitors). This
can be done easily with existing OCaml parser or parser generator
technology (menhir). Then, in a later pass, you compute mixfix
definitions/scopes and add this structure to the parsetree, using a
custom algorithm that has been described in the Agda literature (or
non-Agda previous work), eg.
http://www.cse.chalmers.se/~nad/publications/danielsson-norell-mixfix.html
.

This is a clean way to handle this and, I believe, one of the simplest
to use, understand and debug.

On Fri, Jul 6, 2012 at 2:52 PM, Andrej Bauer <andrej.bauer@andrej.com> wrote:
> If I wanted a parser in Ocaml that can parse things in teh style of
> Agda (with the cool underscore thingy), where would I start looking?
>
> With kind regards,
>
> Andrej
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

  parent reply	other threads:[~2012-07-06 14:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06 12:52 Andrej Bauer
2012-07-06 13:17 ` Fabrice Le Fessant
2012-07-06 13:22   ` Anil Madhavapeddy
2012-07-06 13:23   ` Wojciech Meyer
2012-07-06 14:32 ` Gabriel Scherer [this message]
2012-07-06 15:15 ` Jérémie Dimino
2012-07-06 21:50   ` Andrej Bauer

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=CAPFanBFUnoNC5wJPFjO1WUoh6hEmW9sXOJMeNjmqGn983bt9Tg@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=andrej.bauer@andrej.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).