caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Paul Snively <psnively@mac.com>
Cc: David McClain <David.McClain@Avisere.com>,
	Joshua Smith <josh@trdlnk.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Context Free Grammars?
Date: 13 Aug 2004 15:22:28 +1000	[thread overview]
Message-ID: <1092374548.29139.86.camel@pelican.wigram> (raw)
In-Reply-To: <55D5BF02-EC95-11D8-915C-000A27DEEC20@mac.com>

On Fri, 2004-08-13 at 05:25, Paul Snively wrote:

> 1) Only one token at a time is taken into account in reductions.
> 2) Right-recursion will screw you over.

Actually Ocamlyacc handles right recursion just fine.
I have no idea why .. but it does, in fact its the
prefered form in many cases: here's an example
of BOTH left and right recursion being used:
 
tlelement:
  | lelement COLON factor { $1,Some (typecode_of_expr $3) } 
  | lelement { $1,None }

lexprs:
  | tlelement COMMA lexprs { $1 :: $3 }
  | tlelement { [$1] }


This works -- its part of the Felix grammar: tlelement
is left recursive, lexprs is right recursive,
and the reason is clear -- its the most efficient
way to build a list. 

Perhaps someone can explain why this actually works ..??

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2004-08-13  5:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-12 17:18 David McClain
2004-08-12 18:02 ` Joshua Smith
2004-08-12 18:14   ` David McClain
2004-08-12 19:25     ` Paul Snively
2004-08-12 21:47       ` Erik de Castro Lopo
2004-08-13  5:22       ` skaller [this message]
2004-08-13  5:59         ` David Brown
2004-08-13 14:20         ` Brian Hurt
2004-08-13  4:45 ` 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=1092374548.29139.86.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=David.McClain@Avisere.com \
    --cc=caml-list@inria.fr \
    --cc=josh@trdlnk.com \
    --cc=psnively@mac.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).