From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 1B8B4BB9C for ; Sun, 4 Dec 2005 15:15:44 +0100 (CET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB4EFgZ2023663 for ; Sun, 4 Dec 2005 15:15:43 +0100 Received: from rosella (ppp33-4.lns1.syd2.internode.on.net [59.167.33.4] (may be forged)) by smtp1.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id jB4EFeWs095190 for ; Mon, 5 Dec 2005 00:45:40 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: yacc question From: skaller To: caml-list@yquem.inria.fr Content-Type: text/plain Date: Mon, 05 Dec 2005 01:15:40 +1100 Message-Id: <1133705740.11050.14.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4392FA0E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; parser:01 expr:01 buffer:01 expr:01 token:01 trailing:01 token:01 buffer:01 sourceforge:01 integer:01 match:02 parse:02 parse:02 expressions:03 expressions:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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; 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: top_expr: | expr token_not_allowed_in_expressions and then 'put back' the trailing token into the buffer. Is there another way? -- John Skaller Felix, successor to C++: http://felix.sf.net