[m-dev.] A formal grammar for Mercury?
Modestas Valauskas
valauskasmodestas at gmail.com
Wed Jan 25 04:47:35 AEDT 2023
Thank you Julien and Raghu.
On Mon, 16 Jan 2023 at 11:17, Julien Fischer <jfischer at opturion.com> wrote:
>
> Hi,
>
> On Fri, 13 Jan 2023, Modestas Valauskas wrote:
>
> > I'm looking for a formal grammar for Mercury. I'm thinking of a
> > declarative specification in the form of e.g. BNF/EBNF or perhaps
> > ANTLR or a different parser generator tool, but if that is not
> > available, anything else that would allow me to more easily write a
> > formal grammar for Mercury would be appreciated.
>
> There isn't one written down in a single spot, so far as I am aware.
> Some of it scattered throughout the reference manual -- the version
> from recent ROTDs is probably more useful in this respect than the
> current release.
>
> The way Mercury is parsed is a little unusual (mainly for historical
> reasons). The main steps are:
>
> 1. Tokenization (done by library/mercury_term_lexer.m).
> 2. Parsing the token stream into terms (done by
> libary/mercury_term_parser.m and related modules.)
> 3. Parsing of terms into items (declarations and clauses).
>
> The compiler design document (in compiler/notes/compiler_design.html)
> describes this in more detail and provides pointers to the relevant
> bits of code.
>
> Julien.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/developers/attachments/20230124/e07ec83e/attachment.html>
More information about the developers
mailing list