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
Re: [Caml-list] 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:40)
From: yoann padioleau <padator@w...>
Subject: Re: [Caml-list] ocamlyacc -- can i tell it to be quiet?

> > The following leads to shift reduce conflict:
> > 
> > ctype_name:
> >   | LONG LONG 
> >   | LONG 
> > 
> > Yacc is very weird -- I can parse a list of LONG without
> > a conflict .. but not two of them?? 
> > 
> > Is there any way to tell it to shut up?
> Rather than trying to solve this in the LALR parser (which
> might involve a major rewrite of the grammer in this case),
> the easiest way is to adapt the _lexer_ to produce two
> different tokens for "long" and for "long long": The lexer
> (ocamllex) always goes for the longest match, and in this
> case this is what you want ;-).

except that sometimes there is some space, comments, between the 2 "long", so the regexp for "long long" would
be uselessly complicated. 

BTW, I dont know if your grammar talks about C, but in C you can even write
 "long const extern long a;"