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
yacc question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-12-04 (14:15)
From: skaller <skaller@u...>
Subject: yacc question
I have the 'usual' kind of parser for expressions, with two
nonterminals 'expr' and 'atom', the latter including ( expr ) 
and INTEGER of course.

When I have input like

1 + 2 ;
(1 + 2) ;

none of the case parse as expressions, the first and
last do parse as atoms (leaving the ; in the buffer).

What I want is to parse the longest possible match.
The only way I can think of doing this is:

  | expr token_not_allowed_in_expressions

and then 'put back' the trailing token into the buffer.
Is there another way?

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net