haskell / happy

The Happy parser generator for Haskell
Other
291 stars 84 forks source link

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

Closed sgraf812 closed 1 month ago

sgraf812 commented 10 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 9 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 8 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.