English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
ocamlyacc -- can i tell it to be quiet?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-11-18 (14:39)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] ocamlyacc -- can i tell it to be quiet?
On Friday 18 November 2005 14:08, skaller wrote:
> The following leads to shift reduce conflict:
> ctype_name:
>   | LONG
> Yacc is very weird -- I can parse a list of LONG without
> a conflict .. but not two of them??

I'm not a yacc expert but there seem to be two possibilities:

1. The same action is repeated, in which case "LONG LONG" is superfluous and 
can be removed.

2. The two actions are different, in which case you need to tell yacc that 
LONG LONG has a higher precedence:

%nonassoc LONG
%prec long_long
| LONG LONG %prec long_long { ... }
| LONG { ... };

I think this is equivalent to the dangling "else" problem. Anyway, you 
shouldn't be parsing C++, it is bad for your health. ;-)

Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists