Skip to content

Fixed #9207: ocamlyacc can now handle 255 entry points - #9210

Merged
xavierleroy merged 3 commits into
ocaml:trunkfrom
andreasabel:trunk
Dec 26, 2019
Merged

xavierleroy merged 3 commits into
ocaml:trunkfrom
andreasabel:trunk

Conversation

@andreasabel

@andreasabel andreasabel commented Dec 25, 2019 •

Copy link
Copy Markdown
Contributor

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.

  • Documentation: the upper limit on entry points was not documented in the man page, so I did not edit the man pages.
  • Testing: I did not find a comprehensive testsuite in place for ocamlyacc, thus, I did not add any tests. The existing test (singular) runs fine.

Merry Christmas!

andreasabel and others added 3 commits December 25, 2019 13:50
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 xavierleroy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for the patch. I updated a comment directly, so that this can be merged promptly.

Comment thread yacc/defs.h
/* 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. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment to explain the source for this limitation to 255 entry points.

Comment thread yacc/defs.h
char assoc;
char entry;
unsigned char entry; /* 1..MAX_ENTRY_POINT (0 for unassigned) */
char true_token;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The missing unsigned is the root of the issue, indeed.

@xavierleroy
xavierleroy merged commit 0d97917 into ocaml:trunk Dec 26, 2019
Comment thread Changes
@@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix isn’t breaking, so this wants to be - (not near my laptop, or I’d just push it!)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted, thanks. Corrected in 584b142

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants