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

update fixes vol 2 #3

Closed
wants to merge 1 commit into from

Conversation

tomtau
Copy link
Contributor

@tomtau tomtau commented Mar 27, 2024

Summary by CodeRabbit

  • Refactor
    • Upgraded the parser library from pest to pest3 across various files, enhancing token handling, parser derivation, and parsing logic.

Copy link

coderabbitai bot commented Mar 27, 2024

Walkthrough

The overarching change involves transitioning from the pest and pest_derive libraries to their next major versions, pest3 and pest3_derive, across various files. This upgrade encompasses updates to import statements, function calls, and parser types to align with the new versions, ensuring that the parsing functionality remains effective and up-to-date.

Changes

Files Change Summary
derive/.../reader.rs,
derive/tests/grammar.rs,
derive/tests/sample.rs
Updated imports from pest to pest3 and pest_derive to pest3_derive.
derive/src/lib.rs Changed pest_generator to pest3_generator in derive_typed_parser function.
derive/tests/json.rs Switched to pest3_derive and updated parser type to pest3::typed in the JSON module.
derive/tests/sequence.rs,
derive/tests/skip.rs
Moved from pest and pest_derive to pest3 and pest3_derive for parsing.
generator/.../common.rs,
generator/.../generator.rs,
generator/.../module.rs
Updated imports from pest_meta to pest3_meta and pest to pest3.
generator/src/types.rs,
generator/tests/generator.rs,
pest/tests/predefined_node.rs
Updated references and imports to use pest3 and pest3_generator.

🐇🎉
In the land of code where parsers play,
A leap to pest3 we make today.
From pest and derive, we now depart,
With pest3's embrace, a fresh start.
Through files and tests, changes we thread,
A rabbit's joy on upgrade's stead.
🎈🌟

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0f33163 and adfd6ae.
Files ignored due to path filters (5)
  • Cargo.toml is excluded by: !**/*.toml
  • derive/Cargo.toml is excluded by: !**/*.toml
  • generator/Cargo.toml is excluded by: !**/*.toml
  • meta/Cargo.toml is excluded by: !**/*.toml
  • pest/Cargo.toml is excluded by: !**/*.toml
Files selected for processing (14)
  • derive/examples/reader.rs (1 hunks)
  • derive/src/lib.rs (1 hunks)
  • derive/tests/grammar.rs (1 hunks)
  • derive/tests/json.rs (2 hunks)
  • derive/tests/sample.rs (1 hunks)
  • derive/tests/sequence.rs (2 hunks)
  • derive/tests/skip.rs (1 hunks)
  • generator/src/common.rs (1 hunks)
  • generator/src/typed/generator.rs (2 hunks)
  • generator/src/typed/module.rs (2 hunks)
  • generator/src/types.rs (1 hunks)
  • generator/tests/expected.rs (37 hunks)
  • generator/tests/generator.rs (1 hunks)
  • pest/tests/predefined_node.rs (1 hunks)
Files not summarized due to errors (1)
  • generator/tests/expected.rs: Error: Message exceeds token limit
Additional comments: 20
generator/src/types.rs (1)
  • 6-6: The update from ::pest to ::pest3 in the pest() function aligns with the PR's objectives and appears correctly implemented.
derive/src/lib.rs (1)
  • 16-16: The update from pest_generator to pest3_generator in the derive_typed_parser function is correctly implemented and aligns with the PR's objectives.
derive/examples/reader.rs (1)
  • 1-2: The updates to imports from pest to pest3 and pest_derive to pest3_derive are correctly implemented and align with the PR's objectives.
derive/tests/sample.rs (1)
  • 3-4: The updates to imports from pest to pest3 for TypedNode and Parser are correctly implemented and align with the PR's objectives.
generator/src/common.rs (3)
  • 3-3: The update of the import statement from pest_meta to pest3_meta aligns with the PR objectives to transition to newer library versions. This change looks good.
  • 1-6: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [6-20]

The generate_include function correctly generates Rust include_str! for grammar files, making paths relative to the current directory. This approach enhances portability and maintainability.

  • 1-6: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [22-42]

The generate_rule_enum function effectively generates an enum for parser rules, with appropriate handling of documentation comments and exclusion of special rules. The use of the quote! macro for code generation is correctly applied.

pest/tests/predefined_node.rs (2)
  • 9-9: The update of the import statement from pest to pest3 aligns with the PR objectives to transition to newer library versions. This change looks good.
  • 6-12: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [11-117]

The test implementations in predefined_node.rs are well-structured and cover a variety of cases to verify the functionality of predefined nodes using the pest3 library. The tests appear to be comprehensive and correctly implemented.

generator/src/typed/module.rs (2)
  • 5-6: The update of the import statements from pest and pest_meta to pest3 and pest3_meta aligns with the PR objectives to transition to newer library versions. These changes look good.
  • 235-235: The temporary change to make "pest" paths refer to the pest3 crate is a reasonable workaround to ensure compatibility during the transition period. This approach facilitates a smoother update process.
derive/tests/grammar.rs (2)
  • 14-18: The update of the import statements from pest to pest3 and from pest_derive to pest3_derive aligns with the PR objectives to transition to newer library versions. These changes look good.
  • 11-21: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [20-454]

The test implementations in derive/tests/grammar.rs are well-structured and cover a wide range of parsing scenarios to verify the functionality of grammar parsing using the pest3 library. The tests appear to be comprehensive and correctly implemented.

generator/src/typed/generator.rs (2)
  • 13-13: The update from pest_meta to pest3_meta in the import statements aligns with the PR objectives to transition to the newer library versions. This change is crucial for ensuring compatibility with the updated pest3 ecosystem.
  • 10-16: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [590-590]

The use of unwrap in derive_typed_parser for parsing the input token stream is risky and could lead to panics if parsing fails. Consider handling this error more gracefully to provide clearer error messages or to allow for error propagation, enhancing the robustness of the code.

generator/tests/expected.rs (5)
  • 42-42: The implementation of ::pest3::typed::RuleType for Rule correctly updates the library usage to pest3. However, it's essential to ensure that all references to Rule throughout the codebase are updated to reflect any changes in the enum's variants or their usage.
  • 57-57: The implementation for ::pest3::typed::wrapper::String for W0 correctly specifies the content as a single space character. This is a good use of the pest3 library's typed wrapper functionality. Ensure that all such wrappers are consistently used across the codebase for similar purposes.
  • 129-129: The struct r#Regular correctly defines a rule with its content and span. It's important to ensure that the grammar specified in the documentation comment matches the actual implementation and usage of this rule in the parsing logic.
  • 1022-1022: The r#Push rule demonstrates an advanced use of the pest3 library's stack manipulation features. It's essential to verify that the stack operations (push, pop, pop_all) are used correctly and that their interactions are well-understood and tested, especially in complex sequences.
  • 1506-1511: The generics module re-exports several utilities from pest3. This is a good practice for simplifying imports elsewhere in the code. However, ensure that these re-exports are used consistently throughout the project to avoid confusion.

derive/tests/skip.rs Show resolved Hide resolved
generator/tests/expected.rs Show resolved Hide resolved
@@ -232,6 +232,7 @@ impl<'g> ModuleSystem<'g> {
("stack", Rc::new(ModuleNode::Collection(pest_stack))),
("unicode", Rc::new(pest_unicode)),
]);
// FIXME: make "pest" paths to refer to pest3 crate for the moment
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TheVeryDarkness I tried to quickly rename the crates to pest3*, so that the prototype can later be published on crates.io independently of existing pest crates, but it managed to break generator/derive due to the intermingling with "pest" path imports in the grammar (to be clear, the paths in the grammars should still be "pest::", not "pest3").

Anyway, as you were previously asking about the modules or working on them #2 (comment) , feel free to revert this change or refactor it as you see fit

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, and that's fine. I've been working on that for days but haven't made any commit, so it won't affect me.

@tomtau tomtau closed this Apr 11, 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