Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ jobs:
run: |
cargo test --locked
cargo test --locked --all-features
- name: Run Rust tests on minimum supported runtime
run: |
cargo update -p tree-sitter --precise 0.25.10
cargo test --locked
cargo test --locked --all-features
- name: Check Rust formatting
run: cargo fmt --check
- name: Check whitespace
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ reflection, lambda, explicit object parameter, and operator-call changes
while retaining Brokk's quoted Windows include-path and split conditional
`extern "C"` guard fixes.

Version 0.24.2 retains declarations following array bounds built from an
`#ifdef` or `#ifndef` prefix and an unconditional tail expression. The
`preproc_array_size` node owns that complete bound. General `#if`, `#else`,
and nested directives inside array bounds remain unsupported. This version
also recognizes qualified defaulted constructors, including namespace-qualified
owners and exception specifications, both at file scope and inside namespaces.

Generation uses the pinned C grammar 0.24.1 and Tree-sitter CLI 0.26.3.
The 0.23.x line remains based on upstream 0.23.4 with parser ABI 14.

Expand All @@ -34,14 +41,14 @@ The 0.23.x line remains based on upstream 0.23.4 with parser ABI 14.
Add the Brokk-maintained Rust crate to your project:

```sh
cargo add brokk-tree-sitter-cpp@=0.24.0
cargo add brokk-tree-sitter-cpp@=0.24.2
```

Or add it directly to `Cargo.toml`:

```toml
[dependencies]
tree-sitter-cpp = { package = "brokk-tree-sitter-cpp", version = "=0.24.0" }
tree-sitter-cpp = { package = "brokk-tree-sitter-cpp", version = "=0.24.2" }
```

The crate prefixes its native parser symbols so it can coexist with the
Expand Down
87 changes: 87 additions & 0 deletions bindings/rust/lib.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 55 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ module.exports = grammar(C, {
[$.qualified_type_identifier, $.qualified_identifier],
[$.comma_expression, $.initializer_list],
[$.expression, $._declarator],
[$._qualified_function_declarator, $._declarator, $.expression],
[$._qualified_function_declarator, $._declarator],
[$.expression, $.structured_binding_declarator],
[$.expression, $._declarator, $.type_specifier],
[$.expression, $.identifier_parameter_pack_expansion],
Expand Down Expand Up @@ -150,7 +152,8 @@ module.exports = grammar(C, {
$.import_declaration,
$.global_module_fragment_declaration,
$.private_module_fragment_declaration,
alias($.constructor_or_destructor_definition, $.function_definition),
prec(-1, alias($.constructor_or_destructor_definition, $.function_definition)),
alias($.qualified_constructor_or_destructor_definition, $.function_definition),
alias($.operator_cast_definition, $.function_definition),
alias($.operator_cast_declaration, $.declaration),
),
Expand Down Expand Up @@ -203,6 +206,7 @@ module.exports = grammar(C, {
alias($.preproc_if_in_block, $.preproc_if),
alias($.preproc_ifdef_in_block, $.preproc_ifdef),
alias($.constructor_or_destructor_definition, $.function_definition),
alias($.qualified_constructor_or_destructor_definition, $.function_definition),
alias($.operator_cast_definition, $.function_definition),
alias($.operator_cast_declaration, $.declaration),
),
Expand Down Expand Up @@ -326,6 +330,36 @@ module.exports = grammar(C, {
field('body', choice(e.content, $.try_statement))),
}),

array_declarator: $ => prec(1, seq(
field('declarator', $._declarator),
'[',
repeat(choice($.type_qualifier, 'static')),
field('size', optional(choice(
$.expression,
'*',
$.preproc_array_size,
))),
']',
)),

preproc_array_size: $ => seq(
alias($._preproc_ifdef_in_array_declarator, $.preproc_ifdef),
field('tail', $.expression),
),

_preproc_ifdef_in_array_declarator: $ => prec(1, seq(
choice(preprocessor('ifdef'), preprocessor('ifndef')),
field('name', $.identifier),
repeat1($._preproc_array_size_item),
preprocessor('endif'),
)),

_preproc_array_size_item: $ => choice(
$.number_literal,
$.identifier,
$._fold_operator,
),

declaration: $ => seq(
$._declaration_specifiers,
commaSep1(field('declarator', choice(
Expand Down Expand Up @@ -690,6 +724,26 @@ module.exports = grammar(C, {
),
),

_qualified_function_declarator: $ => prec.dynamic(2, seq(
field('declarator', $.qualified_identifier),
$._function_declarator_seq,
)),

qualified_constructor_or_destructor_definition: $ => prec(1, seq(
repeat($._constructor_specifiers),
field('declarator', alias($._qualified_function_declarator, $.function_declarator)),
choice(
seq(
optional($.field_initializer_list),
field('body', $.compound_statement),
),
alias($.constructor_try_statement, $.try_statement),
$.default_method_clause,
$.delete_method_clause,
$.pure_virtual_clause,
),
)),

constructor_or_destructor_declaration: $ => seq(
repeat($._constructor_specifiers),
field('declarator', $.function_declarator),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading