caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Yitzhak Mandelbaum <yitzhakm@cs.princeton.edu>
To: "Török Edwin" <edwintorok@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Array.make exception and parser
Date: Tue, 4 Jan 2011 22:24:41 -0500	[thread overview]
Message-ID: <6A25DBD6-126B-4C9F-A13D-4E2753C0AE2F@cs.princeton.edu> (raw)
In-Reply-To: <4D238B3D.2090903@gmail.com>

Good question -- its languages fall into neither of LL(k) or LR(k). It uses a form of priority parsing, with one token lookahead and a few grammar transformations (assuming camlp4 shares the same parsing technology as camlp5, and nothing has changed since I last took a look at the docs and source code).

In more detail:

Its basic operation is to try each branch in a series of branches until one is found which successfully parses beyond one token. So, it uses only 1 token of lookahead, and it decides which branch to take at the beginning of set of branches. These characteristics make it similar to LL(1). However, it does not ensure that branches do not conflict. So, if two branches share the same token (see more on this below), then the second one will never be taken. IIRC, the parsec parser combinator library has similar semantics for its standard branch combinator.

Furthermore, it performs a number of transformations: First, it does a (shallow) left factoring. So, if a set of branches are defined, it will left factor them without looking into any of the nonterminals. Second, it supports a certain amount of left-recursion through dynamic tracking of the current nonterminal.

--Yitzhak

On Jan 4, 2011, at 4:03 PM, Török Edwin wrote:

> On 2011-01-04 22:40, Lukasz Stafiniak wrote:
>> On Tue, Jan 4, 2011 at 9:31 PM, Francois Pottier
>> <Francois.Pottier@inria.fr> wrote:
>>> On Tue, Jan 04, 2011 at 08:30:48PM +0100, Daniel Bünzli wrote:
>>>> So everybody trades developer convenience for end user convenience --
>>>> I mean, the syntax errors produced by LR parsers are just terrible,
>>> 
>>> It is true that ocamlyacc (and Menhir) offer essentially no support for
>>> explaining parse errors.
>> 
>> But Menhir's support for grammar debugging is very nice and already a
>> strong enough argument to switch over from ocamlyacc!
>> 
> 
> How about camlp4, what kind of parser is it? LL/LR?
> I found its error messages more helpful than ocamlc's (for example just
> running my source code through camlp4o), though it could be better
> (it could say ; expected insteam of [semi]).
> 
> Best regards,
> --Edwin
> 
> -- 
> 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
> 

-----------------------------
Yitzhak Mandelbaum





  reply	other threads:[~2011-01-05  3:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-04 13:41 Jean Krivine
2011-01-04 14:56 ` Daniel Bünzli
2011-01-04 14:57   ` Daniel Bünzli
2011-01-04 14:57 ` Török Edwin
2011-01-04 15:14   ` Jean Krivine
2011-01-04 15:31     ` Daniel Bünzli
2011-01-04 16:22       ` Yitzhak Mandelbaum
2011-01-04 16:42         ` Daniel Bünzli
2011-01-04 17:03           ` Yitzhak Mandelbaum
2011-01-04 17:04       ` Jean Krivine
2011-01-04 17:22         ` Daniel Bünzli
2011-01-04 15:38     ` bluestorm
2011-01-04 17:43       ` Jean Krivine
     [not found]       ` <1125074892.441923.1294163043602.JavaMail.root@zmbs2.inria.fr>
2011-01-04 17:53         ` Francois Pottier
     [not found]     ` <1259991756.440008.1294155536392.JavaMail.root@zmbs2.inria.fr>
2011-01-04 17:45       ` Francois Pottier
2011-01-04 19:30         ` Daniel Bünzli
2011-01-04 19:52           ` Yitzhak Mandelbaum
2011-01-04 20:36             ` Daniel Bünzli
     [not found]         ` <1263353434.442766.1294169448342.JavaMail.root@zmbs2.inria.fr>
2011-01-04 20:31           ` Francois Pottier
2011-01-04 20:40             ` Lukasz Stafiniak
2011-01-04 21:03               ` Török Edwin
2011-01-05  3:24                 ` Yitzhak Mandelbaum [this message]
2011-01-05 14:12             ` Boris Yakobowski
2011-01-05 21:12             ` Boris Yakobowski
2011-01-05 13:37 ` Xavier Leroy
2011-01-05 13:46   ` Jean Krivine

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=6A25DBD6-126B-4C9F-A13D-4E2753C0AE2F@cs.princeton.edu \
    --to=yitzhakm@cs.princeton.edu \
    --cc=caml-list@inria.fr \
    --cc=edwintorok@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).