Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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;
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 <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net