Repository navigation
Fixed #9207: ocamlyacc can now handle 255 entry points - #9210
Merged
Merged
Conversation
The previous promised limit of ocamlyacc was 256 entry points, the actual limit was 127 due to representation of bucket->entry as char. Switching to unsigned char extends the limit to 255. I introduced a constant MAX_ENTRY_POINT as a synonym of MAXCHAR to handle checks against the limit consistently over the different modules of ocamlyacc. Extensions beyond 255 entry points would require a bit more work (which looks unrewarding) since there is an assumption in the implementation that the octal representation of an entry point fits into 3 digits.
xavierleroy
approved these changes
Dec 26, 2019
xavierleroy
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. Thanks for the patch. I updated a comment directly, so that this can be merged promptly.
| /* MAX_ENTRY_POINT is the maximal number of entry points into the grammar. */ | ||
| /* Entry points are identified by a non-zero byte in the input stream, */ | ||
| /* so there are at most 255 entry points. */ | ||
|
|
Contributor
There was a problem hiding this comment.
I updated the comment to explain the source for this limitation to 255 entry points.
| char assoc; | ||
| char entry; | ||
| unsigned char entry; /* 1..MAX_ENTRY_POINT (0 for unassigned) */ | ||
| char true_token; |
Contributor
There was a problem hiding this comment.
The missing unsigned is the root of the issue, indeed.
dra27
reviewed
Dec 26, 2019
| @@ -74,8 +74,8 @@ Working version | |||
| (Gabriel Scherer, review by Armaël Guéneau) | |||
|
|
|||
| * #9207: fix ocamlyacc to work correctly with up to 255 entry points | |||
Member
There was a problem hiding this comment.
The fix isn’t breaking, so this wants to be - (not near my laptop, or I’d just push it!)
xavierleroy
added a commit
that referenced
this pull request
Dec 26, 2019
rboudrouss
pushed a commit
to rboudfork/ocaml
that referenced
this pull request
Jul 12, 2026
The previous promised limit of ocamlyacc was 256 entry points, but on some platforms (x86 at least) the actual limit was 127 due to representation of bucket->entry as char. Switching to unsigned char extends the limit to 255. I introduced a constant MAX_ENTRY_POINT as a synonym of MAXCHAR to handle checks against the limit consistently over the different modules of ocamlyacc. Extensions beyond 255 entry points would require a bit more work (which looks unrewarding) since entry points are currently identified by a single byte at the beginning of the input stream. Fixes: ocaml#9207
rboudrouss
pushed a commit
to rboudfork/ocaml
that referenced
this pull request
Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous promised limit of ocamlyacc was 256 entry points, the
actual limit was 127 due to representation of bucket->entry as char.
Switching to unsigned char extends the limit to 255.
I introduced a constant MAX_ENTRY_POINT as a synonym of MAXCHAR to
handle checks against the limit consistently over the different modules
of ocamlyacc.
Extensions beyond 255 entry points would require a bit more work (which
looks unrewarding) since there is an assumption in the implementation
that the octal representation of an entry point fits into 3 digits.
Merry Christmas!