Commit Graph

178 Commits (1c3c93d727c3bb833b224b062fd1f20eb085f962)

Author SHA1 Message Date
Amaan Qureshi 1c3c93d727 feat: support pure virtual destructors 2024-04-14 16:03:44 +07:00
Amaan Qureshi aa79a170c6 fix: specifier and virtual do not strictly require each other 2024-04-14 16:03:44 +07:00
ObserverOfTime 075886a9fb ci: update workflows
and move eslint config to package.json
2024-04-04 15:23:34 +07:00
ObserverOfTime dc564d2d32 build: update bindings 2024-04-04 15:23:34 +07:00
Amaan Qureshi d51470929e fix: allow qualified identifiers in field expressions 2024-02-18 08:19:22 +07:00
Amaan Qureshi 1ef1791b3c fix: give for statement bodies a higher `dynamic` precedence to avoid parse errors 2024-02-18 08:19:22 +07:00
Amaan Qureshi bbde8cd9c5 chore: update tree-sitter-c 2024-02-18 08:19:22 +07:00
Amaan Qureshi 2e4d27f772
fix: hide aliased rule 2024-02-01 14:02:46 +07:00
Brandon Wu 4ca37be8e7
disambiguate fold vs parenthesized assignment (#239) 2024-01-26 10:33:26 +07:00
Amaan Qureshi 3deebb6635
fix: abstrace reference declarators in parameters 2024-01-24 18:19:00 +07:00
Amaan Qureshi 16874f1fea
chore: bump tree-sitter-c to 0.20.7 2024-01-24 12:11:52 +07:00
Ben Deane a90f170f92
refactor: rewrite `number_literal`
Addresses #224 and properly parses all C++ numbers.
2023-08-16 02:46:22 +07:00
Amaan Qureshi 5cf9c8032b fix: rework some rules to reduce state count 2023-08-13 17:02:14 +07:00
Amaan Qureshi 9cc21dd5d5
fix: allow template before identifier in qualified_identifier 2023-08-10 21:25:36 +07:00
Amaan Qureshi 345c85ec9f
fix: allow user defined literals in assignment lhs 2023-08-10 20:54:58 +07:00
Amaan Qureshi fdb6dfc6f4
feat: bump tree-sitter-c to 0.20.5 and update grammar accordingly 2023-08-10 20:45:24 +07:00
Ben Deane 9692f069b9 Support dependent operator templates
This change allows operators (not just fields/member functions) as dependent
template expressions.

```cpp
auto x = y.template operator()<int>();
```

This syntax is used e.g. to call C++20 lambda expressions with a template head
where the template arguments are not function arguments and therefore cannot be
deduced.

```cpp
[]<typename> () {}.template operator()<int>();
```
2023-08-09 17:06:35 +07:00
Ben Deane 472002f3bf Support multidimensional subscripts
This change allows commas inside subscripts.

```cpp
auto x = a[1, 2, 3];
```

From C++23, array subscripts work like arguments to `operator[]` as an n-ary
function.

Before C++23, `operator[]` must be a unary function, but before C++20, it's
possible to use the comma operator inside subscript expressions - and this is
done in libraries that use expression templates to achieve multidimensional
array syntax.

Use of the comma operator in subscript expressions was deprecated in C++20 to
make way for the C++23 change to n-ary `operator[]`.
2023-08-06 12:19:00 +07:00
Amaan Qureshi 81e46a7376
chore: remove unnecessary conflicts 2023-07-26 22:54:07 +07:00
Amaan Qureshi ba1f79fb1d
fix: allow `attribute_specifier` after `noexcept` 2023-07-26 22:52:10 +07:00
Amaan Qureshi c7dd622e7a
feat: add `alignas_specifier` and `alignof_expression` 2023-07-26 22:52:10 +07:00
Amaan Qureshi e99ad99231
fix: allow pointer declarators in qualified identifiers & `.*` in field expressions 2023-07-26 22:52:10 +07:00
Amaan Qureshi dbc1e2baac
fix: initializer lists can be the RHS of an assignment expression 2023-07-26 22:52:10 +07:00
Amaan Qureshi 3c898ed3f0
fix: backport `attribute_specifier` fixes from C 2023-07-25 06:35:59 +07:00
Amaan Qureshi eba14809da
fix: primitive types are allowed in compound literal expressions 2023-07-25 06:35:40 +07:00
Amaan Qureshi 7ce69cb41d
fix: remove `_typedef_type_specifier`, use git version of tree-sitter-c 2023-07-23 22:47:15 +07:00
Amaan Qureshi 0dd318d271
fix: update `if_statement` to align with C 2023-07-23 22:31:45 +07:00
Amaan Qureshi 03aec3de1f
chore: update C to v0.20.3 2023-07-18 17:32:40 +07:00
Amaan Qureshi bef54737be
feat: add eslint formatting 2023-06-20 15:12:34 +07:00
John Drouhard 670404d7c6 feat: support template friend declarations 2023-04-15 11:29:44 +07:00
John Drouhard 0b6d0eb9ab feat!: namespace rule tweaks
breaking change: namespace_definition_name has been renamed to
nested_namespace_specifier and the nesting has been reversed to match
the way normal scope resolution works elsewhere.

identifiers that are part of a namespace_definition are now
namespace_identifier, which matches the identifier node type used in
scope resolution for qualified types.

namespace alias definitions use the new nested_namespace_specifier so
all identifiers are namespace_identifier nodes.

support for top-level "inline" namespace declarations (which are valid
if they are nested in another namespace body).
2023-03-26 13:30:32 +07:00
Amaan Qureshi af15a5260b
feat: add missing fold operators (#195) 2023-03-25 10:30:48 +07:00
John Drouhard 03fa93db13 support alternate logical operators (and/or) in requires clauses
Fixes #193
2023-03-02 08:15:22 +07:00
John Drouhard 56cec4c2eb feat!: support virtual inheritance
breaking changes:
- access_specifier is now a named node in base class clauses
- virtual_function_specifier node has been renamed to virtual
2023-01-27 11:24:06 +07:00
John Drouhard 5e9f44f632 reduce state count a bit more for function declarations; fix a few places where attributes can appear 2023-01-27 10:32:51 +07:00
John Drouhard bc8809507a reduce parse state count by combining class/struct/union declarations into one anonymous rule 2023-01-27 08:32:21 +07:00
John Drouhard 20beae977e change function declarator to more accurately parse all the possible components
Fixes #184
2023-01-25 22:19:59 +07:00
v1nh1shungry e2fcae8792 support attribute in alias declaration 2023-01-22 15:41:38 +07:00
John Drouhard 2d2c4aee86 enum_specifier: change to right precedence; fixes #187 2023-01-08 23:02:26 +07:00
John Drouhard 2b908639fd decltype(...) expressions can be used in qualified identifiers prior to scope resolution operators 2023-01-08 21:23:45 +07:00
Sam McCall cf12e88166
Include rawstring delimiters in the tree, use for injections (#181)
Include rawstring delimiters in the tree, use for injections

In raw-strings, the delimiter can be used to indicate embedded language:

   R"css( body { background: red; } )css"

This patch adds the delimiter (if present) and raw-string content as
children of the raw_string_literal.

These can be used to parse the content with an injected grammar.

Fixes https://github.com/tree-sitter/tree-sitter-cpp/issues/159
2023-01-05 08:37:51 +07:00
John Drouhard 5ead1e26c6 support using-enum-declaration 2022-10-19 20:38:44 +07:00
jdrouhard d5e90fba89
Add support for alternative operator representations (#179) 2022-10-03 14:48:29 +07:00
Michal Liszcz 45593f0578
Correct function-try-block parsing (#176)
Support for function-try-block implemented in #168/#169 was not correct:
member initializer list in constructor must appear between `try` and the
opening curly brace. Also some cases where try block is allowed were not
implemented.

Following changes are included:

* fix initializer list handling in try block in constructors,
* disallow initializer list in =default/=delete constructors,
* allow for try block in inline function definition,
* allow for try block in cast operator definition.
2022-09-28 04:04:12 +07:00
John Drouhard 818a564afc Add support for init-statements in range-for loops
- Adds a named "init_statement" node for all applicable locations (if,
  switch, while, and range-for)
- Adds alias declarations and typedef declarations to possible types of
  init statements (c++20/c++23)
2022-07-23 15:52:24 +07:00
mliszcz fd7bec5933 Add support for function-try-block
Fixes #168
2022-07-23 13:52:55 +07:00
John Drouhard a832195eb3 trailing return types: all type descriptors can appear as a trailing return type
- apply right precedence to c's type_descriptor rule
- reuse existing type_descriptor rule in trailing_return_type
2022-03-14 15:34:21 +07:00
Ben Dunkin a403969cbb
Implement fold expressions and more complete requires clauses (#151) 2022-02-20 07:54:42 +07:00
John Drouhard 656d7ea44b Type requirements can only specify type names after the typename keyword, not any expression 2022-01-17 09:06:11 +07:00
John Drouhard 1784c22641 Add some fieldnames to requires clause and expression 2022-01-17 09:05:35 +07:00