Let's stop parser Hell

Jonathan M Davis jmdavisProg at gmx.com
Tue Jul 10 13:53:13 PDT 2012


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. And that's essentially what happens with HTML.

- Jonathan M Davis


More information about the Digitalmars-d mailing list