@exercism/lezer-cpp 0.0.0-stage → 1.0.1

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 ADDED
@@ -0,0 +1,151 @@
1
+ ## 1.0.1
2
+
3
+ The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
4
+
5
+ ## 1.0.0
6
+
7
+ This is Exercism's first release of the package, published as
8
+ `@exercism/lezer-cpp`. It parses more of the C and C++ in Exercism's tracks,
9
+ which upstream reports as errors, and adds an `objc` dialect for Objective-C.
10
+
11
+ ## 1.1.6 (2026-05-28)
12
+
13
+ ### Bug fixes
14
+
15
+ Support comma-separated identifiers in `using` declarations.
16
+
17
+ Fix highlighting of preprocessor directive arguments.
18
+
19
+ Allow line comments after preprocessor arguments.
20
+
21
+ ## 1.1.5 (2026-01-05)
22
+
23
+ ### Bug fixes
24
+
25
+ Improve handling of unclosed block comments.
26
+
27
+ ## 1.1.4 (2025-12-09)
28
+
29
+ ### Bug fixes
30
+
31
+ Fix a bug where the parser would get stuck trying to parse a big expression with multiple less-than operators as a template type.
32
+
33
+ ## 1.1.3 (2025-03-16)
34
+
35
+ ### Bug fixes
36
+
37
+ Enable delimiter detection for the grammar, improving bracket matching and by-syntax cursor navigation.
38
+
39
+ ## 1.1.2 (2023-12-28)
40
+
41
+ ### Bug fixes
42
+
43
+ Tag comments and strings as isolating for the purpose of bidirectional text.
44
+
45
+ ## 1.1.1 (2023-07-03)
46
+
47
+ ### Bug fixes
48
+
49
+ Make the package work with new TS resolution styles.
50
+
51
+ ## 1.1.0 (2023-02-08)
52
+
53
+ ### New features
54
+
55
+ Add support for a number of C++20 constructs.
56
+
57
+ ## 1.0.0 (2022-06-06)
58
+
59
+ ### New features
60
+
61
+ First stable version.
62
+
63
+ ## 0.16.0 (2022-04-20)
64
+
65
+ ### Breaking changes
66
+
67
+ Move to 0.16 serialized parser format.
68
+
69
+ ## 0.15.3 (2022-03-28)
70
+
71
+ ### Bug fixes
72
+
73
+ Properly parse braced initializer lists in assignment expressions.
74
+
75
+ ### New features
76
+
77
+ The parser now includes syntax highlighting information in its node types.
78
+
79
+ >>>>>>> 9081cc7 (Mark version 0.16.0)
80
+ ## 0.15.2 (2022-01-24)
81
+
82
+ ### Bug fixes
83
+
84
+ Allow more explicit operator names, stop treating the 'operator' keyword as part of the operator name token.
85
+
86
+ Allow comment after simple preprocessor directives.
87
+
88
+ Support friend declarations in template declarations.
89
+
90
+ Improve the parsing of some ambiguous cases in struct/enum/class specifiers.
91
+
92
+ ## 0.15.1 (2022-01-21)
93
+
94
+ ### Bug fixes
95
+
96
+ Regenerate with \@lezer/generator 0.15.3 to fix a problem with parsing macros.
97
+
98
+ ## 0.15.0 (2021-08-11)
99
+
100
+ ### Breaking changes
101
+
102
+ The module's name changed from `lezer-cpp` to `@lezer/cpp`.
103
+
104
+ Upgrade to the 0.15.0 lezer interfaces.
105
+
106
+ ## 0.13.2 (2021-03-23)
107
+
108
+ ### Bug fixes
109
+
110
+ Fix a crash that sometimes occurred during error-recovery around strings.
111
+
112
+ ## 0.13.1 (2020-12-04)
113
+
114
+ ### Bug fixes
115
+
116
+ Fix versions of lezer packages depended on.
117
+
118
+ ## 0.13.0 (2020-12-04)
119
+
120
+ ## 0.12.0 (2020-10-23)
121
+
122
+ ### Breaking changes
123
+
124
+ Adjust to changed serialized parser format.
125
+
126
+ ## 0.11.1 (2020-09-26)
127
+
128
+ ### Bug fixes
129
+
130
+ Fix lezer depencency versions
131
+
132
+ ## 0.11.0 (2020-09-26)
133
+
134
+ ### Breaking changes
135
+
136
+ Follow change in serialized parser format.
137
+
138
+ ## 0.10.1 (2020-09-10)
139
+
140
+ ### Bug fixes
141
+
142
+ Fix meaningless names for preprocessor directive tokens.
143
+
144
+ Make `++`/`--` operators `UpdateOp` tokens.
145
+
146
+ ## 0.10.0 (2020-09-02)
147
+
148
+ ### Breaking changes
149
+
150
+ First numbered release.
151
+
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,73 @@
1
- # Temporary Holding Version
1
+ # @lezer/cpp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Exercism's fork
4
+
5
+ This is Exercism's fork of [@lezer/cpp](https://code.haverbeke.berlin/lezer/cpp).
6
+ Exercism uses it, through `@exercism/codemirror-lang-cpp`, to parse the code in the C, C++ and Objective-C editors on [exercism.org](https://exercism.org).
7
+ It is published on npm as `@exercism/lezer-cpp`.
8
+ Our changes are on the `exercism` branch, and the `main` branch follows upstream.
9
+ Below this section, the README is upstream's.
10
+
11
+ The fork parses these, which upstream reports as errors:
12
+
13
+ - A preprocessor directive on the last line of a file with no newline after it, such as a final `#endif`.
14
+ - Empty brace initializers on fields, such as `int x{};` in a class body.
15
+ - A trailing comma in a brace initializer after `const`, such as `const int a[2]{1, 2,};`.
16
+ - Brace casts on built-in types, such as `size_t{0}` and `char{}`.
17
+ - Nested qualified templates closed by `>>>`, such as `std::vector<std::vector<std::vector<int>>>`.
18
+ - Template arguments before a brace initializer, such as `constexpr std::array<int, 3> dirs{-1, 0, 1};`.
19
+ - Braced default arguments, such as `std::pair<int, int> p = {0, 0}`.
20
+ - A stray semicolon after a member function body, such as `Foo() {};`.
21
+ - The `not` operator, a comma expression in a `?:` branch, explicit template instantiation (`template struct X<int>;`) and C's `int a[static N]` parameters.
22
+
23
+ The fork also adds an `objc` dialect for Objective-C. To use it, call
24
+ `parser.configure({dialect: "objc"})`. The dialect reads `#import`, `@import`,
25
+ `@interface`, `@implementation`, `@protocol` and `@end`, methods, `@property`
26
+ and `@synthesize`, message sends such as `[list addObject:x]`, `@"strings"`,
27
+ `@[...]`, `@{...}`, `@(...)` and `@42` literals, `@selector(...)`, blocks such
28
+ as `^(id obj) { ... }` and block types such as `void (^done)(void)`, `for ... in`
29
+ loops, `@try`, `@throw`, `@autoreleasepool`, nullability qualifiers and
30
+ `NS_ENUM`. Only the dialect produces the tokens that start Objective-C rules, so the parser reads no Objective-C unless the dialect is on.
31
+
32
+ Each fix has a test in `test/`, and the Objective-C tests are in `test/objc.txt`.
33
+
34
+ ### Install and use
35
+
36
+ To install it, run:
37
+
38
+ ```
39
+ npm install @exercism/lezer-cpp
40
+ ```
41
+
42
+ 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:
43
+
44
+ ```javascript
45
+ import {parser} from "@exercism/lezer-cpp"
46
+
47
+ const tree = parser.parse("int main() { return 0; }")
48
+ ```
49
+
50
+ ### Building and testing
51
+
52
+ To build and test it from a checkout, run `npm install` (which also builds the parser), then `npm test`.
53
+
54
+ ### Contributing
55
+
56
+ Contributions to this fork follow the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
57
+ Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
58
+
59
+ ---
60
+
61
+ This is a C++ grammar for the
62
+ [Lezer](https://lezer.codemirror.net/) parser system.
63
+
64
+ The grammar used is based in a large part on the corresponding
65
+ [tree-sitter grammar](https://github.com/tree-sitter/tree-sitter-cpp).
66
+
67
+ It should be noted that really parsing C++ without a symbol table and
68
+ a preprocessor is not really something that is _possible_. The
69
+ language is very, very ambiguous when parsed like that. This grammar
70
+ tries to pick a likely parse, but is entirely capable of picking the
71
+ wrong one.
72
+
73
+ The code is licensed under an MIT license.