On 21 September 2010 01:06, Rodrigo Rivas <rodrigorivasco...@gmail.com> wrote:
>>> The easy solution would be to remove the assignment to
>>> type_definition_forbidden_message and then check for this case
>>> particulary.
>>
>> cp_parser_type_specifier_seq could return some indication of why the
>> parsing has failed or whether it has parsed a declaration. This is
>> much more useful than just throwing an error. In general this is true
>> of the whole C++ parser.
> You are right. Being a C++ parser it would be appropriate to implement
> some kind of exception-like error management.

You do not need exceptions to implement what I said, just to return a
value. A boolean would suffice to detect whether you parsed a
definition.

> But this is way out of my scope (pun intended).
>
>>> Or we can change the cp_parser_check_type_definition() function to call
>>> cp_parser_error() instead of error().
>>
>> No please, cp_parser_error() is almost always annoying and
>> uninformative saying things like:
>>
>> expected __asm__ before ';'
>>
>> because it lacks context.
> I said that just because of c_parser_error respect the tentative flag.
> I think that you can put whatever message you like, can't you?

The "before whatever" is hardcoded. And tentative parsing is
thoroughly abused in the parser. It means that you can get an error
but you do not really know what happened, so you ignore it and try
something else, which is bad in many (most?) cases. Most fixes I have
done to the C++ parser error-handling involved removing tentative
parsing.

Cheers,

Manuel.

Reply via email to