Skip to content

Support OCaml 5.4#122

Merged
314eter merged 2 commits intotree-sitter:masterfrom
314eter:labeled-tuples
May 29, 2025
Merged

Support OCaml 5.4#122
314eter merged 2 commits intotree-sitter:masterfrom
314eter:labeled-tuples

Conversation

@314eter
Copy link
Copy Markdown
Collaborator

@314eter 314eter commented May 29, 2025

New feature:

Labeled tuples are annoying to parse, since the interaction with labeled function arguments makes the grammar not LR(1).

When parsing

val v : x:t1 * t2
val f : x:t1 * t2 -> t3

you don't know whether the x: is a tuple label (first case) or function argument label (second case) until the ->.

The OCaml parser handles that by incorrectly parsing the first one as x:(t1 * t2), and post-processing it to x:t1 * t2. We can't do that in tree-sitter.

This means we have to introduce our first conflict in the grammar. That's not a problem at all, but I liked that tree-sitter-ocaml was conflict free until now.

Fixes #121.

@314eter 314eter merged commit c2e9fad into tree-sitter:master May 29, 2025
6 checks passed
@314eter 314eter mentioned this pull request May 30, 2025
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.

Feature request: support for labeled tuples in OCaml 5.4.0

1 participant