Commit Graph

178 Commits (1c3c93d727c3bb833b224b062fd1f20eb085f962)

Author SHA1 Message Date
John Drouhard 8071cdeedd Add support for lambda expression template parameters 2022-01-16 21:02:27 +07:00
John Drouhard 5b83b753f2 Add support for default comparisons and the three way comparison operator 2022-01-16 20:30:51 +07:00
John Drouhard 8e735aaf11 Add consteval and constinit support 2022-01-16 19:44:15 +07:00
John Drouhard d146a46b58 Concepts: add support for requires clauses in function declarators 2022-01-16 18:07:29 +07:00
John Drouhard 9c521041ec trailing return type must be last in a function declarator 2022-01-16 17:04:07 +07:00
John Drouhard 862f6f2841 alias decltype_auto to decltype 2022-01-16 17:00:14 +07:00
John Drouhard 6800b65532 Add support for constraints on placeholder type specifiers 2022-01-16 16:12:28 +07:00
Stephan Seitz 4af61b769e Make simple_requirement an alias for expression_statement 2022-01-16 20:33:16 +07:00
Stephan Seitz 4014e212eb Add support for concepts 2021-11-28 17:59:11 +07:00
John Drouhard e8dcc9d2b4 Support attributes on class/struct/union declarations 2021-10-28 08:16:36 +07:00
BigRedEye 724b93bac0 feat: Support namespace aliases 2021-10-25 23:27:38 +07:00
John Drouhard 30b9a2f6b4 Overhaul scoped identifier rules and add dependent name support
!! Breaking change due to restructuring and renaming of scoped identifiers !!

Scoped identifier rules have been renamed to "qualified_x_identifier"
and all variants are aliased so they appear as simply
"qualified_identifier" in the syntax tree. This name better reflects the
c++ standard's language describing this concept.

Qualified identifier rules are now always the "parent" with a right
associative rule that lets them nest indefinitely. Each rule terminates
with some kind of non-scope identifier.

This commit also adds support for the 'template' keyword where required
to disambiguate dependent template names. Field accessors (., ->) can be
followed by keyword template before a template method. The scope
resolution operator can be immediately followed by the 'template'
keyword to indicate the following dependent name with '<' is actually a
template and shouldn't be parsed as a binary operator. These keywords
are required for dependent names in these contexts.
2021-09-23 22:59:30 +07:00
cynix 977dc3a960
Add user-defined literals (#115)
* Add user-defined literals

* Simplify operator rule

* Tweak operator tests

* Remove precedence for user-defined literanl

* Define a rule for ud-suffix

* Use a more readable name for ud-suffix
2021-09-23 15:38:55 +07:00
John Drouhard ca00ce9629 Refactor virtual_function_specifier to simply be a declaration modifier so it can appear in any order in the decl-specifier-seq 2021-09-20 14:08:48 +07:00
John Drouhard d0730bb0c3 Update tree-sitter-c dependency to 0.20.1 2021-09-20 14:08:46 +07:00
John Drouhard 46befa3f34 Add template_method to field_initializer rule 2021-09-20 09:56:58 +07:00
Alois Wohlschlager 01b9eb2ee5
Ref-qualifiers on functions
Add support for the C++11 ref-qualifier syntax to the grammar. Add tests
that ref-qualifiers are parsed properly on both declarations and
definitions.
2021-09-18 14:46:33 +07:00
Andrew He 2889d93330 Add support for initializer lists in subscript operator
See https://en.cppreference.com/w/cpp/language/operator_member_access

Fixes #100
2021-09-17 11:11:07 +07:00
John Drouhard 6cc73d72fd All cpp-specific statements are valid under case statements. Fixes #97 2021-09-17 08:02:55 +07:00
John Drouhard 5d46d3a5fb Add thread_local to storage_class_specifiers (fixes #101) 2021-09-16 12:35:05 +07:00
John Drouhard 99e287a435 Utilize tree-sitter-c for [[attribute]] grammar 2021-09-15 22:54:12 +07:00
Calixte Denizet 25d65aa70c Add c++20 attributes on statements 2021-09-15 08:33:07 +07:00
Alois Wohlschlager 42c8fd32c1
Support C++20 coroutines
C++20 introduces language support for coroutines, using three new
keywords and related language constructions.

* co_await is a unary operator.
* co_return introduces a statement, and works just like return or throw.
* co_yield similarly introduces a statement, but cannot stand for
  itself.

Add support for these facilities to the parser and highlighter.
2021-09-15 11:35:15 +07:00
Calixte Denizet 21e951b104 Can have spaces between delete and [] in operator declaration 2021-09-14 14:59:53 +07:00
Calixte Denizet ead843bf36 Add operator delete/new[]/delete[] 2021-09-14 14:59:44 +07:00
Calixte Denizet b996f893a6 Add new operator 2021-09-14 14:59:33 +07:00
Calixte Denizet 089c1e49cc Operator keyword can be followed by a space 2021-09-14 14:59:24 +07:00
Calixte Denizet f503c2a0d7 Namespace names for definition can be scoped and contain inline keyword 2021-08-13 10:46:30 +07:00
Max Brunsfeld c61212414a Disambiguite function declarator vs init declarator
See tree-sitter/tree-sitter#1016
2021-03-27 10:08:51 +07:00
jdrouhard fb8250eef8
Fixes for constructor declarations (#89)
Constructor declarations can have the same decl-specifiers as
constructor definitions. This adds a new rule to match as many
"constructor specifiers" that are present in any order before the
function decl itself, and adds the rule to constructor declarations and
constructor definitions.

The cast operator can also have any of these specifiers in any order
before the declaration, so this commit also changes the cast operator
declaration and definition to use the new rule as well.

Finally, constructor declarations and cast operator declarations can be
part of a template declaration in addition to the definitions, so add
them both to the template_declaration rule.
2020-11-02 09:46:58 +07:00
Max Brunsfeld 7070224878 Fix alias: _declaration -> declaration 2020-05-14 11:46:28 +07:00
Mathieu Nayrolles 72348197be
Add support for Microsoft-specific modifiers (#79)
* Add support for Microsoft-specific modifiers

Microsoft-specific modifiers are keywords can be used to modify declarators to form derived types.

The specification for the modifiers themselves is here:
https://docs.microsoft.com/en-us/cpp/cpp/microsoft-specific-modifiers?view=vs-2019

This commit updates tree-sitter-c to ^0.16.1 that supports the modifiers
, updates the grammar.js to reflect the changes and add tests.

* 0.16.1
2020-04-01 09:18:50 +07:00
jdrouhard 4da6618567
Non-type template parameters can be variadic as well (#76) 2020-03-20 13:12:24 +07:00
jdrouhard 0c605b92d1
Improve parsing of friend declarations when using c++11 simple type specifier (#77)
Also resolves possible erroneous parsing of a friend declaration
attempting to define a new class.
2020-03-20 09:28:38 +07:00
jdrouhard 1e8f4b142e
Fix array assignment expressions so they don't parse as structured bindings (#78)
* Fix array assignment expressions so they don't parse as structured bindings

Array assignment expressions were broken in df7bc44 which added more
support for structured binding declarators. We need to add a dynamic
precedence that is lower than that of an assignment expression so that
code is parsed as an assignment expression before it's parsed as a
structured binding.

* Just use -1 for structured binding dynamic precedence

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2020-03-19 10:16:16 +07:00
jdrouhard 4d511d9a92
Identifiers in variadic declarators should be optional like other parameter declarators (#75) 2020-03-19 10:05:59 +07:00
calixteman 9570367528
Add operator conversion (#73) 2020-03-19 09:54:18 +07:00
Max Brunsfeld c7b767ac5f Fix issue with function types in expression position 2019-12-17 13:43:08 +07:00
calixteman f2e0cd5e3b Fix declaration in if/switch/while conditions (#54)
* Fix declaration in if/switch/while conditions

* Simplify structure of if/while/switch conditions
2019-12-17 12:58:55 +07:00
Max Brunsfeld 89c68a5548 Tweak rules to reduce parse state count 2019-12-17 12:13:27 +07:00
calixteman 94a3cbbc59 new operator can be called in the global scope (#56) 2019-12-17 11:22:36 +07:00
calixteman 9ba0c978c0 Fix explicit ctor declaration and support explicit with condition (c++20) (#70) 2019-12-17 11:16:54 +07:00
calixteman ba21308963 Primitive types have ctors (#66) 2019-12-17 11:13:34 +07:00
calixteman 2987cba279 Trailing return type can have a type specifier (#71) 2019-12-17 11:09:06 +07:00
calixteman 86f1e6ca02 static_assert can have raw strings or concatenated strings as 2nd arg (#69) 2019-12-17 11:03:20 +07:00
calixteman 279b973a92 Handle decltype (#67) 2019-12-17 10:54:35 +07:00
calixteman a426194b36 Concatenated strings can contain raw string literals (#65)
* Concatenated strings can contain raw string literals

* Restore require path for tree-sitter-c
2019-12-17 10:49:33 +07:00
calixteman 565244b6f6 Assignment LHS can be a scoped identifier (#68)
* Assignment LHS can be a scoped identifier

* Bad path in grammar

* Forgot test and parser

* Update for latest tree-sitter-c
2019-12-17 10:40:22 +07:00
Max Brunsfeld b583491d42 Parse 'this' as a distinct node type 2019-12-10 12:04:20 +07:00
jdrouhard 7263d5bdb8 Add support for static_assert declarations (#61) 2019-10-30 10:58:36 +07:00
jdrouhard 9ad3202e7d Support for parameter pack expansions and improvements to lambda expressions (#60)
For information about parameter packs, see
https://en.cppreference.com/w/cpp/language/parameter_pack

Most expansion loci should work with this commit since it is implemented
as an expression, so anywhere an expression is valid, parameter pack
expansions will be parsed.

This commit also adds support for:
* The sizeof... operator (as an alternative to sizeof)
* Lambda captures can optionally start with a default capture along with
  other captures
* Lambda function declarators (the parameter list) are optional

Tests added for the following parameter pack expansion loci:
* Function parameter and argument lists
* Template argument lists
* Brace-enclosed initializers
* Base class specifiers and member initializer lists
* Lambda captures
2019-10-30 10:53:21 +07:00
jdrouhard 5ba6c37d72 Add support for alias templates (#59) 2019-10-04 14:21:07 +07:00
johnmiked15 7e00ca7c74 Various improvements to template parsing (#58)
This implements support for the following:
* Template constructors defined outside class definition (Fixes #50)
* Nested template function definitions outside class definition
* Template template parameters
* Name-specifiers are now (correctly) optional in template parameters
2019-09-30 19:38:40 +07:00
johnmiked15 e21d7ff7d8 Add default_method_clause to inline_method_definition (#57)
Fixes #48
2019-09-30 19:23:51 +07:00
calixteman f5afa0ee48 Add a base type for enums (#55)
* Add a base type for enums

* Add scoped type identifiers and handle enum class/struct
2019-08-06 17:23:46 +07:00
Max Brunsfeld 9f8ce312e2 Fix ambiguity for template calls w/ value parameters
Fixes #49
2019-06-24 12:15:18 +07:00
Max Brunsfeld 42dcb72c28 Add node fields 2019-06-24 12:06:48 +07:00
calixteman 89d917ae81 Handle throw and noexcept specifiers (#46)
* Handle throw and noexcept specifiers

* Don't change ts-c path
2019-06-07 14:28:11 +07:00
calixteman 96a320b628 Handler initializer list in for loop (#44) 2019-06-05 12:47:05 +07:00
calixteman def9e6f60d Handle throw (#43)
* Fix ctor/dtor with attributes

* Handle 'throw'
2019-06-05 10:22:35 +07:00
calixteman 300b739bb1 Fix virtual issues for method declaration/definition (#39) 2019-06-04 11:48:12 +07:00
Max Brunsfeld df7bc44e33 Allow structured binding declarators in pmore places
Refs atom/language-c#325
2019-05-08 15:51:47 +07:00
Max Brunsfeld 03f36b8b29 Allow attributes on methods
Fixes atom/language-c#313
2019-04-18 13:53:36 +07:00
Max Brunsfeld e54a86a62e Add attribute specifiers
Fixes #33
2019-04-18 13:34:01 +07:00
Max Brunsfeld 4837c1c837 Add virtual specifier
Refs #33
2019-04-18 13:24:51 +07:00
Max Brunsfeld 57dd274de6 Regenerate with latest tree-sitter-c 2018-12-02 14:30:40 +07:00
Max Brunsfeld 95439ea4cc Add support for default member initializers
Fixes #23
2018-11-18 13:37:20 +07:00
Max Brunsfeld 1d0fdd0aad Add variadic template and function parameters
Fixes #20
2018-11-14 17:41:24 +07:00
Max Brunsfeld a2cd752b28 Fix parsing of nested classes with inheritance
Fixes #22
2018-11-14 17:08:10 +07:00
Max Brunsfeld ddd28aa68b Fix parsing of new expressions with no argument lists
Fixes tree-sitter/tree-sitter#208
2018-10-29 13:55:17 +07:00
Max Brunsfeld 64d9263832 Update tree-sitter-c 2018-10-28 13:36:42 +07:00
Max Brunsfeld 71bf2098a4 Add try statements
Fixes #16
2018-10-01 10:23:47 +07:00
Max Brunsfeld b43899edba Add default and delete method specifiers
Fixes #17
2018-10-01 10:11:31 +07:00
Max Brunsfeld b673eceee3 Support template value params with optional names
Fixes #9
2018-08-23 17:24:33 +07:00
Andrew Sutherland ce35ac90eb Add support for method virtual specifiers.
This expands on #6 to support override/final for functions

The relevant specs are:
https://en.cppreference.com/w/cpp/language/override
https://en.cppreference.com/w/cpp/language/final
2018-07-31 13:16:17 +07:00
Andrew Sutherland 61ec3b9008 C++11 class-virt-specifier: "class A final"
As documented at https://en.cppreference.com/w/cpp/language/final (3)
and https://en.wikipedia.org/wiki/C%2B%2B11#Explicit_overrides_and_final
in the latter part, C++11 made syntax like "struct A final {}" legal.
2018-05-31 16:11:30 +07:00
Max Brunsfeld 3a76511be9 Add constexpr if statements
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 13:43:15 +07:00
Max Brunsfeld 743d6de28d Allow template argument lists to be empty
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 13:36:11 +07:00
Max Brunsfeld 5066474dbb Add dependent type names
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 13:34:16 +07:00
Max Brunsfeld aed6de49a4 ⬆️ tree-sitter-c to allow preproc conditionals in class defs
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 13:23:19 +07:00
Max Brunsfeld dfd266b27f Allow explicit constructors
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 12:52:14 +07:00
Max Brunsfeld 06e557ada7 Allow templates with optional type parameters
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 12:33:52 +07:00
Max Brunsfeld 64ac620f5d Add the constexpr type qualifier
Co-Authored-By: Thomas Johansen <thomasjo@gmail.com>
2018-05-14 12:21:08 +07:00
Max Brunsfeld 9dab393b10 Add c++17 structured binding declarations 2018-04-23 11:33:41 +07:00
Max Brunsfeld c17905d04f Differentiate template methods from template functions 2018-02-15 17:15:05 +07:00
Max Brunsfeld 4abee33b91 Update conflict to reflect tree-sitter-c initializer_list change 2018-02-10 14:33:06 +07:00
Max Brunsfeld a1168f46a2 Add raw string literals 2018-01-09 12:03:13 +07:00
Max Brunsfeld 63b48817a0 Add nullptr, primitive types, constants 2017-10-04 12:27:46 +07:00
Max Brunsfeld e6dfce698a Boost dynamic precedence of argument list, like in C 2017-10-04 11:46:25 +07:00
Max Brunsfeld 12b2232560 Tweak identifier naming 2017-08-01 21:08:02 +07:00
Max Brunsfeld 69a3ef688a Use new alias API 2017-07-31 17:46:36 +07:00
Max Brunsfeld 58b68438ab Improve differentiation between types and variables 2017-07-24 19:59:00 +07:00
Max Brunsfeld a38155d4f8 Start separating variable, type, and field names 2017-07-20 15:38:40 +07:00
Max Brunsfeld 9f6f3ae509 Add r-value references 2017-06-22 22:13:15 +07:00
Max Brunsfeld 8694f5beb2 Add classes with inheritance 2017-06-22 22:10:23 +07:00
Max Brunsfeld 53a18a46ae Add explicit template instantiations 2017-06-22 21:52:26 +07:00
Max Brunsfeld 67e93f50e6 Add declarations with braced initializer lists 2017-06-22 16:37:48 +07:00
Max Brunsfeld 4892ecbbc1 Add scoped classes definitions, using namespace declarations 2017-06-21 15:19:59 +07:00
Max Brunsfeld 39e3810038 Add friend, using, alias declarations inside classes 2017-06-21 15:05:06 +07:00
Max Brunsfeld 0e2af7283f Add template class/struct declarations 2017-06-21 14:35:39 +07:00