Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider a C rewrite of the scanner #44

Closed
alaviss opened this issue Sep 28, 2023 · 0 comments · Fixed by #50
Closed

Consider a C rewrite of the scanner #44

alaviss opened this issue Sep 28, 2023 · 0 comments · Fixed by #50
Labels
enhancement New feature or request

Comments

@alaviss
Copy link
Owner

alaviss commented Sep 28, 2023

Upstream maintainers made it clear that they don't want C++ parsers going forward: tree-sitter/tree-sitter#1246 (comment)

The scanner will have to be rewritten in C.

Bits that we use from C++

  • Namespacing: fixable with prefixes
  • Vectors: roll our own or just write a library
  • Strict enums: prefixes
  • Bitsets: back to C-style bitflags, maybe use a trick like struct with one member to enforce type checking.
  • Type inferred variables: manually type them
  • Classes: it's only for the .action() notation, convert back to struct and prefixed function names
  • char32_t: back to uint32_t. Lose a bit of type strictness.
  • References: back to pointers and see if there's an annotation to make compiler do compile-time NULL checks.
  • Easy-to-use pretty printers: drop them.
@alaviss alaviss added the enhancement New feature or request label Sep 28, 2023
alaviss added a commit that referenced this issue Oct 19, 2023
As the tree-sitter project actively discourage C++ scanners, it was
clear that we have to adapt our parser to C to maintain interop
with future direction of the ecosystem.

The logic and code structure of this rewrite is nearly identical to the
C++ version. This is intentional to prevent behavior bugs from creeping
in, and an overhaul will come at a later date.

Right now this code runs with no crashes and seems to work as well as
its C++ predecessor.

Fixes #44
alaviss added a commit that referenced this issue Oct 19, 2023
As the tree-sitter project actively discourage C++ scanners, it was
clear that we have to adapt our parser to C to maintain interop
with future direction of the ecosystem.

The logic and code structure of this rewrite is nearly identical to the
C++ version. This is intentional to prevent behavior bugs from creeping
in, and an overhaul will come at a later date.

Right now this code runs with no crashes and seems to work as well as
its C++ predecessor.

Fixes #44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant