Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] CFG's and OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-08-13 (16:42)
From: Xavier Leroy <Xavier.Leroy@i...>
Subject: Re: [Caml-list] CFG's and OCaml
> My number one complaint with 
> Ocaml is the number of shift/reduce (and hidden reduce/reduce) conflicts 
> in it's grammar.  These bite me on a regular basis.

>From this message and earlier messages of yours, I think you are under
the wrong impression that precedences and associativities can be used
(and would be used in OCaml's grammar) to resolve (or "hide" as you
say) reduce/reduce conflicts.  

This is incorrect: Yacc uses precedences and associativities to
resolve (i.e. choose to shift or choose to reduce) shift/reduce
conflicts only.  If there were reduce/reduce conflicts in OCaml's
grammar, Yacc would say so and no among of precedence tweaking would
hide them.

This said, it is true the OCaml grammar uses precedences a lot to deal
with shift/reduce situations.  It is equally true that some of these
situations correspond to syntactic corners of the language that can
confuse the user.

Concerning David McClain's problems, I can only repeat the advice
given at the beginning of the ocamlyacc chapter in the OCaml manual:

`` Readers unfamiliar with lex and yacc are referred to ``Compilers:
principles, techniques, and tools'' by Aho, Sethi and Ullman
(Addison-Wesley, 1986), or ``Lex & Yacc'', by Levine, Mason and Brown
(O'Reilly, 1992). ''

(The latter is more practice-oriented.)

- Xavier Leroy

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: