haskell / alex

A lexical analyser generator for Haskell
https://hackage.haskell.org/package/alex
BSD 3-Clause "New" or "Revised" License
298 stars 82 forks source link

Report multiple lexical errors. Fixes #144 #145

Open gustavoaca1997 opened 5 years ago

gustavoaca1997 commented 5 years ago

I have this idea for #144. What do you think, @simonmar ? A problem I don't know how to solve is that it is only reporting one lexical error per line.

simonmar commented 5 years ago

It's not clear to me that this is a good idea in general. We don't know if continuing after an error is a sensible thing to do at all, so it would only be a heuristic, which makes me concerned about adding this behavoiur to the core of Alex.

gustavoaca1997 commented 5 years ago

Could you explain to me more what do you mean by "sensible thing"? And thanks for the reply. I'd be glad helping in any other good first issue 🙂

simonmar commented 5 years ago

Take an example like this: ... "\xfffffff" ... with a Haskell lexer. The character constant in the string is a lexical error because it's out of range, but if we report the error and continue, the lexer doesn't know we're inside a string, so it will be out of step and will probably report a ton more errors for the rest of the input.