Skip to content

Commit

Permalink
feat: add support for editions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
asharkhan3101 committed Oct 25, 2024
1 parent 83e8a85 commit 14242cf
Show file tree
Hide file tree
Showing 5 changed files with 1,203 additions and 1,059 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

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

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


## ✨ Features

- ✅ Basic Proto2 support
- ✅ Proto3 support
- ✅ Support for editions


### Special Thanks

Special thanks to the following people for their amazing work in this grammer.

- [mitchellh](https://github.com/mitchellh/tree-sitter-proto) for their original work.
- [treywood](https://github.com/treywood/tree-sitter-proto) for basic proto2 support.

[ci]: https://img.shields.io/github/actions/workflow/status/coder3101/tree-sitter-proto/ci.yml?logo=github&label=CI
[npm]: https://img.shields.io/npm/v/tree-sitter-proto?logo=npm
[crates]: https://img.shields.io/crates/v/tree-sitter-proto?logo=rust
[pypi]: https://img.shields.io/pypi/v/tree-sitter-proto?logo=pypi&logoColor=ffd242
[crates]: https://img.shields.io/crates/v/tree-sitter-proto?logo=rust
32 changes: 21 additions & 11 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,17 +413,27 @@ module.exports = grammar({
))),
)),

// reserved_identifier = \" letter { letter | decimalDigit | "_" } \"
reserved_identifier: $ => token(seq(
'"',
letter,
optional(repeat(choice(
letter,
decimal_digit,
'_',
))),
'"',
)),
// reserved_identifier = \" | ' letter { letter | decimalDigit | "_" } ' | \"
reserved_identifier: $ => token(
choice(
seq(
'"',
letter,
optional(repeat(choice(letter, decimal_digit, '_'))),
'"'

Check failure on line 423 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),
seq(
"'",

Check failure on line 426 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
letter,
optional(repeat(choice(letter, decimal_digit, '_'))),
"'"

Check failure on line 429 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 429 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),
seq(
letter,
optional(repeat(choice(letter, decimal_digit, '_')))

Check failure on line 433 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)

Check failure on line 434 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
)

Check failure on line 435 in grammar.js

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
),
_identifier_or_string: $ => choice($.identifier, $.string),

// fullIdent = ident { "." ident }
Expand Down
143 changes: 115 additions & 28 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 14242cf

Please sign in to comment.