@exercism/lezer-cpp 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +147 -0
- package/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/index.cjs +191 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +187 -0
- package/package.json +47 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
## 1.0.0
|
|
2
|
+
|
|
3
|
+
This is Exercism's first release of the package, published as
|
|
4
|
+
`@exercism/lezer-cpp`. It parses more of the C and C++ in Exercism's tracks,
|
|
5
|
+
which upstream reports as errors, and adds an `objc` dialect for Objective-C.
|
|
6
|
+
|
|
7
|
+
## 1.1.6 (2026-05-28)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Support comma-separated identifiers in `using` declarations.
|
|
12
|
+
|
|
13
|
+
Fix highlighting of preprocessor directive arguments.
|
|
14
|
+
|
|
15
|
+
Allow line comments after preprocessor arguments.
|
|
16
|
+
|
|
17
|
+
## 1.1.5 (2026-01-05)
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
Improve handling of unclosed block comments.
|
|
22
|
+
|
|
23
|
+
## 1.1.4 (2025-12-09)
|
|
24
|
+
|
|
25
|
+
### Bug fixes
|
|
26
|
+
|
|
27
|
+
Fix a bug where the parser would get stuck trying to parse a big expression with multiple less-than operators as a template type.
|
|
28
|
+
|
|
29
|
+
## 1.1.3 (2025-03-16)
|
|
30
|
+
|
|
31
|
+
### Bug fixes
|
|
32
|
+
|
|
33
|
+
Enable delimiter detection for the grammar, improving bracket matching and by-syntax cursor navigation.
|
|
34
|
+
|
|
35
|
+
## 1.1.2 (2023-12-28)
|
|
36
|
+
|
|
37
|
+
### Bug fixes
|
|
38
|
+
|
|
39
|
+
Tag comments and strings as isolating for the purpose of bidirectional text.
|
|
40
|
+
|
|
41
|
+
## 1.1.1 (2023-07-03)
|
|
42
|
+
|
|
43
|
+
### Bug fixes
|
|
44
|
+
|
|
45
|
+
Make the package work with new TS resolution styles.
|
|
46
|
+
|
|
47
|
+
## 1.1.0 (2023-02-08)
|
|
48
|
+
|
|
49
|
+
### New features
|
|
50
|
+
|
|
51
|
+
Add support for a number of C++20 constructs.
|
|
52
|
+
|
|
53
|
+
## 1.0.0 (2022-06-06)
|
|
54
|
+
|
|
55
|
+
### New features
|
|
56
|
+
|
|
57
|
+
First stable version.
|
|
58
|
+
|
|
59
|
+
## 0.16.0 (2022-04-20)
|
|
60
|
+
|
|
61
|
+
### Breaking changes
|
|
62
|
+
|
|
63
|
+
Move to 0.16 serialized parser format.
|
|
64
|
+
|
|
65
|
+
## 0.15.3 (2022-03-28)
|
|
66
|
+
|
|
67
|
+
### Bug fixes
|
|
68
|
+
|
|
69
|
+
Properly parse braced initializer lists in assignment expressions.
|
|
70
|
+
|
|
71
|
+
### New features
|
|
72
|
+
|
|
73
|
+
The parser now includes syntax highlighting information in its node types.
|
|
74
|
+
|
|
75
|
+
>>>>>>> 9081cc7 (Mark version 0.16.0)
|
|
76
|
+
## 0.15.2 (2022-01-24)
|
|
77
|
+
|
|
78
|
+
### Bug fixes
|
|
79
|
+
|
|
80
|
+
Allow more explicit operator names, stop treating the 'operator' keyword as part of the operator name token.
|
|
81
|
+
|
|
82
|
+
Allow comment after simple preprocessor directives.
|
|
83
|
+
|
|
84
|
+
Support friend declarations in template declarations.
|
|
85
|
+
|
|
86
|
+
Improve the parsing of some ambiguous cases in struct/enum/class specifiers.
|
|
87
|
+
|
|
88
|
+
## 0.15.1 (2022-01-21)
|
|
89
|
+
|
|
90
|
+
### Bug fixes
|
|
91
|
+
|
|
92
|
+
Regenerate with \@lezer/generator 0.15.3 to fix a problem with parsing macros.
|
|
93
|
+
|
|
94
|
+
## 0.15.0 (2021-08-11)
|
|
95
|
+
|
|
96
|
+
### Breaking changes
|
|
97
|
+
|
|
98
|
+
The module's name changed from `lezer-cpp` to `@lezer/cpp`.
|
|
99
|
+
|
|
100
|
+
Upgrade to the 0.15.0 lezer interfaces.
|
|
101
|
+
|
|
102
|
+
## 0.13.2 (2021-03-23)
|
|
103
|
+
|
|
104
|
+
### Bug fixes
|
|
105
|
+
|
|
106
|
+
Fix a crash that sometimes occurred during error-recovery around strings.
|
|
107
|
+
|
|
108
|
+
## 0.13.1 (2020-12-04)
|
|
109
|
+
|
|
110
|
+
### Bug fixes
|
|
111
|
+
|
|
112
|
+
Fix versions of lezer packages depended on.
|
|
113
|
+
|
|
114
|
+
## 0.13.0 (2020-12-04)
|
|
115
|
+
|
|
116
|
+
## 0.12.0 (2020-10-23)
|
|
117
|
+
|
|
118
|
+
### Breaking changes
|
|
119
|
+
|
|
120
|
+
Adjust to changed serialized parser format.
|
|
121
|
+
|
|
122
|
+
## 0.11.1 (2020-09-26)
|
|
123
|
+
|
|
124
|
+
### Bug fixes
|
|
125
|
+
|
|
126
|
+
Fix lezer depencency versions
|
|
127
|
+
|
|
128
|
+
## 0.11.0 (2020-09-26)
|
|
129
|
+
|
|
130
|
+
### Breaking changes
|
|
131
|
+
|
|
132
|
+
Follow change in serialized parser format.
|
|
133
|
+
|
|
134
|
+
## 0.10.1 (2020-09-10)
|
|
135
|
+
|
|
136
|
+
### Bug fixes
|
|
137
|
+
|
|
138
|
+
Fix meaningless names for preprocessor directive tokens.
|
|
139
|
+
|
|
140
|
+
Make `++`/`--` operators `UpdateOp` tokens.
|
|
141
|
+
|
|
142
|
+
## 0.10.0 (2020-09-02)
|
|
143
|
+
|
|
144
|
+
### Breaking changes
|
|
145
|
+
|
|
146
|
+
First numbered release.
|
|
147
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2020 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @exercism/lezer-cpp
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This is Exercism's fork of [@lezer/cpp](https://code.haverbeke.berlin/lezer/cpp).
|
|
4
|
+
It parses the code in the C, C++ and Objective-C editors on
|
|
5
|
+
[exercism.org](https://exercism.org), through `@exercism/codemirror-lang-cpp`. Our changes live on the `exercism`
|
|
6
|
+
branch. The `main` branch follows upstream.
|
|
7
|
+
|
|
8
|
+
The fork parses these, which upstream reports as errors:
|
|
9
|
+
|
|
10
|
+
- A preprocessor directive on the last line of a file with no newline after it, such as a final `#endif`.
|
|
11
|
+
- Empty brace initializers on fields, such as `int x{};` in a class body.
|
|
12
|
+
- A trailing comma in a brace initializer after `const`, such as `const int a[2]{1, 2,};`.
|
|
13
|
+
- Brace casts on built-in types, such as `size_t{0}` and `char{}`.
|
|
14
|
+
- Nested qualified templates closed by `>>>`, such as `std::vector<std::vector<std::vector<int>>>`.
|
|
15
|
+
- Template arguments before a brace initializer, such as `constexpr std::array<int, 3> dirs{-1, 0, 1};`.
|
|
16
|
+
- Braced default arguments, such as `std::pair<int, int> p = {0, 0}`.
|
|
17
|
+
- A stray semicolon after a member function body, such as `Foo() {};`.
|
|
18
|
+
- The `not` operator, a comma expression in a `?:` branch, explicit template instantiation (`template struct X<int>;`) and C's `int a[static N]` parameters.
|
|
19
|
+
|
|
20
|
+
The fork also adds an `objc` dialect for Objective-C. To use it, call
|
|
21
|
+
`parser.configure({dialect: "objc"})`. The dialect reads `#import`, `@import`,
|
|
22
|
+
`@interface`, `@implementation`, `@protocol` and `@end`, methods, `@property`
|
|
23
|
+
and `@synthesize`, message sends such as `[list addObject:x]`, `@"strings"`,
|
|
24
|
+
`@[...]`, `@{...}`, `@(...)` and `@42` literals, `@selector(...)`, blocks such
|
|
25
|
+
as `^(id obj) { ... }` and block types such as `void (^done)(void)`, `for ... in`
|
|
26
|
+
loops, `@try`, `@throw`, `@autoreleasepool`, nullability qualifiers and
|
|
27
|
+
`NS_ENUM`. Every Objective-C rule starts with a token produced only by the dialect, so without the dialect the parser reads no Objective-C syntax.
|
|
28
|
+
|
|
29
|
+
Each fix has a test in `test/`, and the Objective-C tests are in `test/objc.txt`.
|
|
30
|
+
|
|
31
|
+
## Install and use
|
|
32
|
+
|
|
33
|
+
To install it, run:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install @exercism/lezer-cpp
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The package exports a Lezer `parser`. To use the parser in CodeMirror, install `@exercism/codemirror-lang-cpp`, which wraps the parser. To parse code directly:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import {parser} from "@exercism/lezer-cpp"
|
|
43
|
+
|
|
44
|
+
const tree = parser.parse("int main() { return 0; }")
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To build and test it from a checkout, run `npm install` (which also builds the parser), then `npm test`.
|
|
48
|
+
|
|
49
|
+
The upstream README follows.
|
|
50
|
+
|
|
51
|
+
## @lezer/cpp
|
|
52
|
+
|
|
53
|
+
This is a C++ grammar for the
|
|
54
|
+
[Lezer](https://lezer.codemirror.net/) parser system.
|
|
55
|
+
|
|
56
|
+
The grammar used is based in a large part on the corresponding
|
|
57
|
+
[tree-sitter grammar](https://github.com/tree-sitter/tree-sitter-cpp).
|
|
58
|
+
|
|
59
|
+
It should be noted that really parsing C++ without a symbol table and
|
|
60
|
+
a preprocessor is not really something that is _possible_. The
|
|
61
|
+
language is very, very ambiguous when parsed like that. This grammar
|
|
62
|
+
tries to pick a likely parse, but is entirely capable of picking the
|
|
63
|
+
wrong one.
|
|
64
|
+
|
|
65
|
+
The code is licensed under an MIT license.
|