-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: On parse error - show the next possible tokens #46
Conversation
I've added an additional commit to the branch, per your review. Feel free to squash/amend send more comments. As for your request, this seems to be taking |
300%+ increase in code size to too much (a lot too much!). In Happy-generated code we can use whatever tricks we like, since it's not meant to be user-editable code. For instance, we use unboxed values all over the place. I suggest there should be a single array of token names (each an unboxed string), and an unboxed array, indexed by state, with a bitmap of the allowed token values. |
Followed your suggestion - now |
Just rechecking - is there anything more to be done for this? |
This looks good. I'll find some time to test it and merge. |
Rebased against However, |
Rebased against Original branch
|
This change introduces the %errorsig attribute, that changes the API of the provided handler function. A [String] of possible next token can be passed to the function in order to provide a better error message to the user. We need to pass over the list of possible token names to the happyFail function. For example: action_12 (12) = happyShift action_9 action_12 (13) = happyShift action_10 action_12 (14) = happyShift action_11 action_12 (15) = happyShift action_12 action_12 (5) = happyGoto action_15 action_12 (6) = happyGoto action_5 action_12 (7) = happyGoto action_6 action_12 (8) = happyGoto action_7 action_12 (9) = happyGoto action_8 action_12 _ = happyFail ["idT","numT","boolT","\"(\""] Signed-off-by: Dan Aloni <dan@kernelim.com>
* Rename %errorsig to %errorhandletype * Detect invalid values for %errorhandletype at parsing stage, not code generation stage. * Document %errorhandlertype * Refactoring at the code generation function. Signed-off-by: Dan Aloni <dan@kernelim.com>
Long list of literal strings, one string for each possible token in a state, increases parser object size significantly. Instead, * Use a bit matrix of the possiblility of a token in a state, generated along with the other parser tables. * Data.Array is now always imported, for storing the array. * Instead of inlining the result of possibleShifts, we now have a compact produceExpListArray that we can use in both the array-based parser and the non-array-based parser. Signed-off-by: Dan Aloni <dan@kernelim.com>
+1 Is there anything missing for this to be merged? |
I got test failures, e.g.
(edited, had the wrong error message) |
Seem related to something else - you get the same errors without this pull request, using yesterday's 1.19.6 tag, due to GHC 7.10. With GHC 7.8.4 the tests pass (and separately, also with the changes here). |
Opened a separate pull request for that test error. |
This broke the Travis build, could you take a look please? https://travis-ci.org/simonmar/happy/builds/133044562 |
Looking into this |
Fixed in a new pull request #68 |
People asked for a patch upstream - so here's the place to start a discussion.
In this change, I've made sure that 'cabal test' still passes, and the interface to unmodified users is preserved. But you would probably have more comments.