Repository navigation
Parse C++23 and C++26 syntax: if consteval, contracts, pack indexing, and more - #375
Open
arraypress wants to merge 1 commit into
Open
arraypress wants to merge 1 commit into
arraypress wants to merge 1 commit into
Conversation
… and more - `if consteval` / `if !consteval` (C++23, as in tree-sitter#362) - Contracts: `pre(…)`, `post(r: …)` on function declarators (C++26) - Pack indexing `Ts...[0]` in types and expressions (C++26); `...[` is one token, so a pack expansion followed by a subscript is never misread - Attributes on structured bindings: `auto [a [[maybe_unused]], b]` (C++26) - `= delete("reason")` (C++26) - Explicit instantiation of a class template: `template class Ring<int, 4>;` - Attributes before `friend` (as in tree-sitter#366) - `= default` / `= delete` on a function outside a class. `void f() = delete;` left a MISSING node, and `friend auto operator<=>(…) = default;` parsed as a variable initialised with an identifier `default`; the expected tree in declarations.txt is updated for the second - The `->*` operator, and pointer-to-member field and typedef declarators: `int Widget::* field;` New corpus: test/corpus/cpp23-26.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Parses C++23 and C++26 syntax that currently produces
ERRORnodes, and fixes two misparses of= default/= delete.Added
if consteval/if !consteval(C++23; overlaps Add support for C++23 feature if consteval #362).pre(…)andpost(r: …)on function declarators (C++26).Ts...[0]in types and expressions (C++26)....[is a single token, so a pack expansion followed by a subscript is never misread.auto [a [[maybe_unused]], b](C++26).= delete("reason")(C++26).template class Ring<int, 4>;.friend(overlaps Friend leading attribute #366).->*operator, and pointer-to-member field and typedef declarators (int Widget::* field;,typedef int Widget::* P;).Fixed
= default/= deleteon a function outside a class.void f() = delete;produced a MISSING node, andvoid g() = delete("x");parsed as a variable initialised by adeleteexpression.friend auto operator<=>(A const &, A const &) = default;parsed as a declaration whose initialiser was an identifier nameddefault. Its expected tree indeclarations.txtnow has afunction_definitionwith adefault_method_clause, the same as the member form above it.Tests: the other existing tests pass unchanged. New
test/corpus/cpp23-26.txtcovers each construct.Generated with tree-sitter-cli 0.26.13 against the tree-sitter-c version in
package.json. That CLI regenerates the currentsrc/parser.cbyte for byte. One conflict entry,[_declaration_modifiers, using_declaration], became unnecessary and is removed.Size:
parser.cgrows from 25.9 MB to 26.5 MB.🤖 Generated with Claude Code