----- Original Message -----
From: "Andre Baresel" <and...@gm...>
To: "Baptiste Lepilleur" <gai...@fr...>
Sent: Monday, April 28, 2003 10:55 PM
Subject: Re: [Cpptool-develop] Error recovery...
> Baptiste Lepilleur wrote:
>
> > I was reading some of the new parsing code, that is template parsing:
> >
> >---
> > if (tryNextIs('<'))
> > {
> > // skipping all the parameters until next '>'
> > findNextBalanced('<','>');
> >---
> >
> > The issue is not specific to that code, it's just the one that got me
> >thinking. We know an obvious way to have findNextBalanced fails is to
have
> >some constant comparison expression in the template parameter (very
unlikely
> >though), that is "template <const bool optimize = sizeof(A) < sizeof(B) >
> >... ;"
> >
> I've never seen such code, however this is really problematic !
Likehood is very small. This might only be use in advanced generic
programming (running the parser over boost mpl will be interesting).
> Note that another problem is the shift operator '<<' which has not to be
> balanced.
> I'm thinking about some general tokinizing algorithm implemented in the
> new ParserTools.
This can be easily done by implementing a skip policy and passing it to
ParserTools::findNextBalanced.
> The balancing algorithm should than use the tokenizer.
> Note that a tokenizer is now implemented in ExpressionParser and
> DeclarationParser.
> DeclarationParser does except only a subset (defined by the syntax).
> exceptTokenSet would be
> some useful util.
I'll give this alook. My initial idea when I started the parser was that
continuous refactoring would lead us to some mini-parser framework. We'll
see what come out.
> > While it is not dramatic if we failed to parse this correctly, but it
> >would be better if we could do some error recovery. One of the way I
think
> >this could be achieve would be by introducing a findNextBalanced, but
stop
> >parsing if '{' or ';' is found. Then the error recovery could start here.
> >
> > What do you think ?
> >
> Yes - a good idea. I have the feeling that a good error recovery is very
> hard to
> design, maybe we get some ideas when the parser fails with real world
code.
Yes, that would help a lot. By the way, is there a LODMutator that mutate
all the node (parse the declaration list, then declaration...). I'd like to
run some real world test and implements CPPParser::parserAll().
Baptiste.
PS: check your email-client settings. I'm getting two copy of most mail. One
in standard text format, and another as a mail containing a single attached
file ?!?
>
> -- André
|