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

Tree-sitter grammar: support the remaining signed and unsigned Int types #5315

Merged
merged 5 commits into from
Feb 28, 2024

Conversation

OceanOak
Copy link
Collaborator

@OceanOak OceanOak commented Feb 28, 2024

Changelog:

Tree-sitter-darklang
- Expand the grammar to support the remaining signed and unsigned Int types (Int8, Int16, Int32, Int64, Int128), and update the parser accordingly

#5321

@OceanOak OceanOak marked this pull request as ready for review February 28, 2024 09:43
@OceanOak
Copy link
Collaborator Author

Question:

We currently don't support negative integers (because of digits: $ => /\d+/,)

  • I've added positive_digits and negative_digits (because uints will only have positive numbers)
  • Made digits choice($.positive_digits, $.negative_digits)

The solution provided in this PR works. but I don't know if it is better to update the rule to something like the following instead. Feedback is appriciated

int64_literal: $ =>
  seq(
    field("sign", optional("-")
    field("digits", $.digits),
    field("suffix", alias("L", $.symbol)),
  ),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a single comment somewhere around the Ints, indicating that we're only using .NET suffixes for Ints temporarily until we can get rid of the old parser?

@StachuDotNet StachuDotNet merged commit b3cfef7 into darklang:main Feb 28, 2024
8 checks passed
@OceanOak OceanOak changed the title Expand the grammar to support the remaining signed and unsigned Int types Tree-sitter grammar: support the remaining signed and unsigned Int types Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants