Browse thread
[Caml-list] Context Free Grammars?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] Context Free Grammars? |
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