haskell / happy

The Happy parser generator for Haskell
Other
273 stars 85 forks source link

`happyExpToks` table can be larger than `happyTable` #271

Open sgraf812 opened 5 months ago

sgraf812 commented 5 months ago

For tests/issue93.y, the happyExpToks array is about 20% larger than happyTable. We should definitely try to compress it more, perhaps use an array of lists. Better: Error handling is not required to be fast; just reconstruct the expected tokens from the happyTable.

int-index commented 5 months ago

Error handling is not required to be fast

Are you sure? GHC relies on the error token to implement the layout rule.

sgraf812 commented 4 months ago

Yes, in https://github.com/haskell/happy/pull/272 I produce the expected tokens lazily when the error handler (reportError, in the example) needs them. For the error token, this error handler will not even be called, unless there really is a syntax error.