caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Harrop <jon@jdh30.plus.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Right recursion with ocamlyacc
Date: Wed, 16 Feb 2005 04:35:23 +0000	[thread overview]
Message-ID: <200502160435.23574.jon@jdh30.plus.com> (raw)
In-Reply-To: <20050216035811.GA17612@mobile>

On Wednesday 16 February 2005 03:58, Markus Mottl wrote:
> On Wed, 16 Feb 2005, Jon Harrop wrote:
> > I've just been converting a new Computer Language Shootout submission
> > from OCaml to C++ and found that bison falls over very easily with right
> > recursion (failing to load a 10^4-element list) but ocamlyacc had no
> > problems (even on a 10^5-element list).
>
> Why use right recursive productions in the grammar?

There was no justification for it, right recursion just happened to be most 
natural in this case. I've never worried about it before since it never came 
up.

> Left recursion runs in constant stack space so this would be the way to
> go... 

Yes, left recursion is definitely the way to go in general. But has anyone 
ever had a problem with right-recursion when using ocamlyacc? Is there a 
theoretical reason why this is not a problem with ocamlyacc?

When this came up, it occurred to me that (since switching to OCaml) I've 
neglected the stock advice of avoiding right recursion. And I'm not in the 
habit of parsing small files. :-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.


  reply	other threads:[~2005-02-16  4:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-16  2:10 Jon Harrop
2005-02-16  2:28 ` [Caml-list] " Eric C. Cooper
2005-02-16  3:58 ` Markus Mottl
2005-02-16  4:35   ` Jon Harrop [this message]
2005-02-16  9:18     ` Radu Grigore
2005-02-18 15:27       ` Radu Grigore
2005-02-16  4:42   ` skaller

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=200502160435.23574.jon@jdh30.plus.com \
    --to=jon@jdh30.plus.com \
    --cc=caml-list@yquem.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).