Let's stop parser Hell

Timon Gehr timon.gehr at gmx.ch
Tue Jul 10 14:00:00 PDT 2012


On 07/10/2012 10:53 PM, Jonathan M Davis wrote:
> On Tuesday, July 10, 2012 22:40:17 Jacob Carlborg wrote:
>> On 2012-07-10 22:25, Jonathan M Davis wrote:
>>> Which is horrible. You pretty much have to with HTML because of the horrid
>>> decision that it should be parsed so laxly by browsers, but pretty much
>>> nothing else should do that. Either it's correct or it's not. Having the
>>> compiler "fix" your code would cause far more problems that it would ever
>>> fix.
>> I'm not sure but I think he was referring to a kind of error reporting
>> technique used by compilers. Example:
>>
>> int foo ()
>> {
>>     int a = 3 // note the missing semicolon
>>     return a;
>> }
>>
>> Instead of the parser going completely mad because of the missing
>> semicolon. It will basically insert a semicolon, report the error and
>> then happily continue parsing. I think this will make it easier to find
>> later errors and less likely to report incorrect errors due to a
>> previous error.
>
> Well, giving an error, continuing to parse, and giving a partial result can be
> useful (and you give a prime example of that), but "fixing" the problem (e.g by
> inserting the semicolon) and not considering it to be an error would be a
> _huge_ mistake IMHO.

This is actually precisely what many of the more recent curly-brace-
and-semicolon languages have been doing with regard to semicolons.


More information about the Digitalmars-d mailing list