Skip to content

Commit 14242cf

Browse files
committed
feat: add support for editions
In addition to adding support for edition keyword, this also adds support for the new grammer rules introduced such as skipping `"` (quotation) marks around reserved field names.
1 parent 83e8a85 commit 14242cf

File tree

5 files changed

+1203
-1059
lines changed

5 files changed

+1203
-1059
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22

33
[![CI][ci]](https://github.com/coder3101/tree-sitter-proto/actions/workflows/ci.yml)
44
[![crates][crates]](https://crates.io/coder3101/tree-sitter-proto)
5-
[![npm][npm]](https://www.npmjs.com/package/tree-sitter-proto)
6-
[![pypi][pypi]](https://pypi.org/project/tree-sitter-proto)
75

86
Protocol buffer grammer for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
97

8+
9+
## ✨ Features
10+
11+
- ✅ Basic Proto2 support
12+
- ✅ Proto3 support
13+
- ✅ Support for editions
14+
15+
16+
### Special Thanks
17+
18+
Special thanks to the following people for their amazing work in this grammer.
19+
20+
- [mitchellh](https://github.com/mitchellh/tree-sitter-proto) for their original work.
21+
- [treywood](https://github.com/treywood/tree-sitter-proto) for basic proto2 support.
22+
1023
[ci]: https://img.shields.io/github/actions/workflow/status/coder3101/tree-sitter-proto/ci.yml?logo=github&label=CI
11-
[npm]: https://img.shields.io/npm/v/tree-sitter-proto?logo=npm
12-
[crates]: https://img.shields.io/crates/v/tree-sitter-proto?logo=rust
13-
[pypi]: https://img.shields.io/pypi/v/tree-sitter-proto?logo=pypi&logoColor=ffd242
24+
[crates]: https://img.shields.io/crates/v/tree-sitter-proto?logo=rust

grammar.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,17 +413,27 @@ module.exports = grammar({
413413
))),
414414
)),
415415

416-
// reserved_identifier = \" letter { letter | decimalDigit | "_" } \"
417-
reserved_identifier: $ => token(seq(
418-
'"',
419-
letter,
420-
optional(repeat(choice(
421-
letter,
422-
decimal_digit,
423-
'_',
424-
))),
425-
'"',
426-
)),
416+
// reserved_identifier = \" | ' letter { letter | decimalDigit | "_" } ' | \"
417+
reserved_identifier: $ => token(
418+
choice(
419+
seq(
420+
'"',
421+
letter,
422+
optional(repeat(choice(letter, decimal_digit, '_'))),
423+
'"'
424+
),
425+
seq(
426+
"'",
427+
letter,
428+
optional(repeat(choice(letter, decimal_digit, '_'))),
429+
"'"
430+
),
431+
seq(
432+
letter,
433+
optional(repeat(choice(letter, decimal_digit, '_')))
434+
)
435+
)
436+
),
427437
_identifier_or_string: $ => choice($.identifier, $.string),
428438

429439
// fullIdent = ident { "." ident }

src/grammar.json

Lines changed: 115 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)