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

Rename built-in rules to be all lowercase #21

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomtau
Copy link
Contributor

@tomtau tomtau commented Oct 21, 2024

Fixes #9


For more details, open the Copilot Workspace session.

Summary by CodeRabbit

  • New Features
    • Introduced new rule variants and structures in the grammar definitions for enhanced clarity and usability.
  • Bug Fixes
    • Improved consistency in naming conventions for ASCII-related constructs across various files.
  • Documentation
    • Updated comments to clarify the purpose of parsers and grammar rules.
  • Chores
    • Added newline characters to the end of several files for proper formatting.

Copy link

coderabbitai bot commented Oct 21, 2024

Walkthrough

The pull request includes a significant refactoring of type aliases and grammar definitions across multiple files, primarily focusing on renaming public type aliases and tokens from uppercase to lowercase for consistency. This includes ASCII-related constructs and built-in rules in the pest parser. Documentation comments have been removed, and some files have minor formatting adjustments, such as ensuring newline characters at the end. Overall, the changes aim to standardize naming conventions without altering existing functionality.

Changes

File Path Change Summary
core/src/typed/template/mod.rs Renamed public type aliases from uppercase to lowercase (e.g., ASCII_DIGIT to ascii_digit).
derive/tests/calc.pest Changed pest::SOI and pest::EOI to lowercase; added newline at end of file.
derive/tests/grammar.pest Renamed predicates/constants to lowercase (e.g., ASCII_DIGIT to ascii_digit).
derive/tests/json.pest Changed pest::SOI and pest::EOI to lowercase; updated comment header.
generator/src/typed/module.rs Replaced built-in rules SOI and EOI with lowercase versions; no other structural changes.
generator/src/typed/output.rs Updated collect methods to use lowercase ASCII constants; minor logic adjustments.
generator/tests/dag/*.pest Various minor formatting changes, including newline additions; no logical changes.
generator/tests/expected_import_inline.rs Added new enum variant and structs; modified imports to use lowercase names for ASCII constants.

Assessment against linked issues

Objective Addressed Explanation
Rename built-in rules to be all lowercase (9)

Possibly related PRs

  • Remove need of pest3_core as a dependency for pest3 users #18: The changes in this PR involve renaming and standardizing type aliases for ASCII character ranges, which directly relates to the modifications made in the core/src/typed/template/mod.rs file of the main PR, where similar ASCII-related type aliases were renamed to lowercase.

Poem

In the land of code where rabbits play,
We’ve renamed our types in a tidy way.
From ASCII DIGIT to ascii_digit,
Consistency reigns, oh what a hit!
With every newline, our files feel light,
Hopping through changes, everything's right! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tomtau tomtau marked this pull request as draft October 21, 2024 08:43
@tomtau
Copy link
Contributor Author

tomtau commented Oct 21, 2024

I was playing with Copilot Workspace, it seems it doesn't work that well 🤣

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (9)
derive/tests/calc.pest (1)

17-17: Minor: Improved file formatting

Although not visible in the diff, the addition of a newline character at the end of the file is a good practice for consistent file formatting. This minor change improves the overall code quality without affecting the grammar's functionality.

derive/tests/json.pest (1)

Inconsistent comment styles found in derive/tests/json.pest

Multiple comment styles (#! and //!) are used within the same file, which may lead to documentation inconsistencies or processing issues.

  • derive/tests/json.pest: 1 line(s) with #!, 5 line(s) with //!
🔗 Analysis chain

Line range hint 1-7: Verify comment style consistency

The comment style for the first line has been changed from //! to #!. While this change aligns with the pest grammar syntax, it's important to ensure that this doesn't affect documentation generation or violate any project-wide documentation standards.

Please confirm that:

  1. This change is intentional and aligns with the project's documentation practices.
  2. It doesn't negatively impact any automated documentation generation processes.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in comment styles across pest files

# Test: Count occurrences of different comment styles
echo "Comment style usage in .pest files:"
rg -c '^#!' --type pest
rg -c '^//!' --type pest

Length of output: 191


Script:

#!/bin/bash
# Description: Check for consistency in comment styles across .pest files

# Test: Count occurrences of different comment styles in .pest files
echo "Comment style usage in .pest files:"
rg -c '^#!' -g "*.pest"
rg -c '^//!' -g "*.pest"

Length of output: 274

core/src/typed/template/mod.rs (6)

6-10: LGTM: Consistent renaming, but consider removing redundant attributes

The renaming of ASCII_NONZERO_DIGIT to ascii_nonzero_digit and ASCII_BIN_DIGIT to ascii_bin_digit aligns with the PR objectives. However, the individual #[allow(non_camel_case_types)] attributes are now redundant due to the module-level attribute.

Consider removing the redundant #[allow(non_camel_case_types)] attributes for each type alias, as they're covered by the module-level attribute on line 1.


14-19: LGTM: Consistent renaming and definition update

The renaming of ASCII_OCT_DIGIT to ascii_oct_digit and ASCII_HEX_DIGIT to ascii_hex_digit is consistent with the PR objectives. The definition of ascii_hex_digit has been correctly updated to use the renamed ascii_digit, maintaining internal consistency.

As mentioned earlier, consider removing the redundant #[allow(non_camel_case_types)] attributes for each type alias.


23-27: LGTM: Consistent renaming continues

The renaming of ASCII_ALPHA_LOWER to ascii_alpha_lower and ASCII_ALPHA_UPPER to ascii_alpha_upper maintains consistency with the PR objectives.

As previously noted, the #[allow(non_camel_case_types)] attributes for each type alias are redundant and can be removed.


31-35: LGTM: Consistent renaming and definition updates

The renaming of ASCII_ALPHA to ascii_alpha and ASCII_ALPHANUMERIC to ascii_alphanumeric continues to align with the PR objectives. The definitions have been correctly updated to use the renamed type aliases, maintaining internal consistency.

The redundant #[allow(non_camel_case_types)] attributes can be removed, as mentioned in previous comments.


39-39: LGTM: Final consistent renaming

The renaming of ASCII to ascii completes the consistent application of lowercase naming for built-in rules, aligning with the PR objectives.

As with previous instances, the #[allow(non_camel_case_types)] attribute here is redundant and can be removed.


1-39: Overall: Consistent implementation of PR objectives with minor improvements needed

The changes in this file successfully implement the PR objective of renaming built-in rules to lowercase, improving naming consistency across the codebase without altering functionality. All ASCII-related type aliases have been consistently renamed, and their usages in definitions have been updated accordingly.

Suggestions for improvement:

  1. Remove the redundant individual #[allow(non_camel_case_types)] attributes for each type alias, as they're covered by the module-level attribute on line 1.
  2. Consider reinstating or updating the removed documentation comments to maintain code readability and documentation quality.

Would you like assistance in implementing these suggestions?

derive/tests/grammar.pest (1)

Line range hint 70-83: Consider cleaning up or adding a TODO for the commented-out section

The commented-out section at the end of the file mentions an "Invalid segment of grammar below (repeated rule)". Consider either removing this section if it's no longer needed or adding a TODO comment if it's meant to be addressed in the future. This will help maintain the cleanliness and clarity of the grammar file.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d8843cc and 7cb30db.

📒 Files selected for processing (13)
  • core/src/typed/template/mod.rs (1 hunks)
  • derive/tests/calc.pest (2 hunks)
  • derive/tests/grammar.pest (2 hunks)
  • derive/tests/json.pest (2 hunks)
  • generator/src/typed/module.rs (0 hunks)
  • generator/src/typed/output.rs (2 hunks)
  • generator/tests/dag/a.pest (1 hunks)
  • generator/tests/dag/b.pest (1 hunks)
  • generator/tests/dag/c.pest (1 hunks)
  • generator/tests/dag/d.pest (1 hunks)
  • generator/tests/dag/e.pest (1 hunks)
  • generator/tests/dag/f.pest (1 hunks)
  • generator/tests/expected_import_inline.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • generator/src/typed/module.rs
✅ Files skipped from review due to trivial changes (6)
  • generator/tests/dag/a.pest
  • generator/tests/dag/b.pest
  • generator/tests/dag/c.pest
  • generator/tests/dag/d.pest
  • generator/tests/dag/e.pest
  • generator/tests/dag/f.pest
🧰 Additional context used
🔇 Additional comments (13)
derive/tests/calc.pest (2)

5-5: LGTM: Consistent renaming of built-in rules

The change from pest::SOI and pest::EOI to pest::soi and pest::eoi aligns perfectly with the PR objective of renaming built-in rules to be all lowercase. This enhances consistency across the codebase without altering the grammar's functionality.


Line range hint 1-17: Overall: Consistent implementation of naming convention changes

The changes in this file successfully implement the PR objective of renaming built-in rules to lowercase. This contributes to a more consistent naming convention across the project without altering the grammar's functionality. The minor formatting improvement further enhances code quality. These changes align well with similar modifications made in other files, demonstrating a comprehensive approach to improving code consistency and readability throughout the codebase.

core/src/typed/template/mod.rs (1)

1-2: LGTM: Changes align with PR objectives

The addition of the module-level #![allow(non_camel_case_types)] attribute and the renaming of ASCII_DIGIT to ascii_digit are consistent with the PR's goal of standardizing built-in rules to lowercase. This change improves naming consistency without altering functionality.

derive/tests/grammar.pest (6)

27-27: LGTM: Consistent renaming of built-in rule

The change from SOI to soi aligns with the PR objective of renaming built-in rules to lowercase. This improves naming consistency without altering the functionality.


38-38: LGTM: Consistent renaming of built-in rule

The change from EOI to eoi is in line with the PR objective of renaming built-in rules to lowercase. This enhances naming consistency while preserving the existing functionality.


46-50: LGTM: Consistent renaming of ASCII-related constructs

The changes to lowercase for ascii_digit, ascii_nonzero_digit, ascii_bin_digit, ascii_oct_digit, and ascii_hex_digit are in line with the PR objective. This improves naming consistency across ASCII-related constructs while maintaining functionality.


51-53: LGTM: Consistent renaming of ASCII-related constructs

The changes to lowercase for ascii_alpha_lower, ascii_alpha_upper, and ascii_alpha align with the PR objective. This enhances naming consistency across ASCII-related constructs while preserving functionality.


54-55: LGTM: Consistent renaming of ASCII-related constructs

The changes to lowercase for ascii_alphanumeric and ascii are in line with the PR objective. This improves naming consistency across ASCII-related constructs while maintaining functionality.


56-56: LGTM: Consistent renaming of built-in rule

The change from NEWLINE to newline aligns with the PR objective of renaming built-in rules to lowercase. This improves naming consistency without altering the functionality.

generator/src/typed/output.rs (1)

Line range hint 151-164: LGTM! Improved naming consistency.

The changes in the collect method of the Tracker struct align well with the PR objective of renaming built-in rules to be all lowercase. This enhances consistency across the codebase and improves readability. The modifications maintain existing functionality while standardizing the naming convention.

Specifically, the following constants have been renamed:

  • SOI to soi
  • EOI to eoi
  • ANY to any
  • PEEK to peek
  • PEEK_ALL to peek_all
  • DROP to drop
  • PUSH to push
  • POP to pop
  • POP_ALL to pop_all
  • ASCII_* constants to their lowercase equivalents

These changes contribute to a more uniform and consistent codebase.

generator/tests/expected_import_inline.rs (3)

Line range hint 70-247: New rule structures are correctly defined and consistent

The addition of structs r#x0 through r#x4 in the rules module enhances the grammar definitions. The helper methods and implementations adhere to the project's coding standards and correctly use lifetimes and generics.


646-647: Verify all references to renamed built-in rules are updated

The imports have been updated to use lowercase identifiers (e.g., ascii_alpha, ascii_digit). Please ensure that all usages of the old uppercase identifiers have been replaced to prevent any unresolved import errors.

Run the following script to check for any remaining references to the old identifiers:

#!/bin/bash
# Description: Search for usages of old uppercase built-in rule names that should have been renamed.

# Test: Look for any occurrences of `ASCII_` prefixed identifiers.
rg 'ASCII_[A-Z_]+'

Line range hint 9-11: Ensure the new r#minimal variant integrates without conflicts

The addition of r#minimal(rules::r#minimal::Rule) to the Rule enum enhances modularity by nesting rules. Please verify that this new variant does not introduce any pattern matching conflicts or overlap with existing variants in the codebase.

Run the following script to identify any pattern matching statements that might be affected:

@@ -8,7 +8,7 @@
// FIXME: some should be under pest::*
use common::base as p

json = pest::SOI ~ value ~ pest::EOI
json = pest::soi ~ value ~ pest::eoi
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Action Required: Remaining uppercase 'SOI' and 'EOI' found

  • File: meta/src/grammar.pest
    • Lines: 2, 4
  • File: generator/tests/syntax.pest
    • Lines: 1, 2

Please update SOI and EOI to lowercase soi and eoi in the above files to ensure consistent usage across the codebase.

🔗 Analysis chain

LGTM: Consistent renaming of built-in rules

The changes from pest::SOI to pest::soi and pest::EOI to pest::eoi are in line with the PR objective of renaming built-in rules to be all lowercase. This change enhances consistency across the codebase.

To ensure these changes are applied consistently across the project, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify consistent usage of lowercase 'soi' and 'eoi' across the project

# Test: Check for any remaining uppercase usage of SOI and EOI
echo "Checking for any remaining uppercase SOI and EOI usage:"
rg -i '\b(SOI|EOI)\b' --type pest

# Test: Confirm the usage of lowercase soi and eoi
echo "Confirming usage of lowercase soi and eoi:"
rg '\b(soi|eoi)\b' --type pest

Length of output: 342


Script:

#!/bin/bash
# Description: Verify consistent usage of lowercase 'soi' and 'eoi' across the project

# Find all .pest files and check for any remaining uppercase SOI and EOI usage
echo "Checking for any remaining uppercase SOI and EOI usage:"
fd --extension pest | xargs rg -i '\b(SOI|EOI)\b'

# Confirm the usage of lowercase soi and eoi
echo "Confirming usage of lowercase soi and eoi:"
fd --extension pest | xargs rg '\b(soi|eoi)\b'

Length of output: 1777

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.

Rename built-in rules to be all lowercase
1 participant