[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-12-04 (16:48) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] yacc question |
On Sun, 2005-12-04 at 16:03 +0100, Robert W. wrote: > ocamlyacc parses longest match by default. > Your rule for atoms seem to complex or you lexer isn't able to extract > the token for atoms correctly from the line. When I parse atoms only, it all works fine. The problem is that if the user specifies a production like: #statement select expr within statement ; then if I parse 'expr' with 'atom' this will not be allowed: select 1 + 2 within print x; because '1 + 2' isn't an atom. The user would be forced to write: select (1 + 2) within print x; But if I parse with 'expr' instead of atom, the parse fails when it hits the unknown symbol 'within'. > > | expr token_not_allowed_in_expressions > > > > and then 'put back' the trailing token into the buffer. > > Is there another way? > > > This shouldn't be necessary, normally you can redesign your parser > rules to avoid this. The problem is I'm trying to add 'on the fly' user defined grammar productions -- so the 'grammar' is extensible. This will be done by recursive descent, but hooked inside, and hooking, the existing ocamlyacc grammar. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net