-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add parsing of lookarounds #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This pull request adds parsing, AST generation, HIR translation, and testing support for lookaround assertions (specifically lookbehinds) in regular expressions. Key changes include:
- Updating the parser (and related group parsing functions) to handle lookaround syntax.
- Implementing HIR translation for the new LookAround AST node.
- Adding and updating tests for lookaround parsing and printing.
Reviewed Changes
File | Description |
---|---|
regex-syntax/src/hir/print.rs | Updated lookaround tests by removing the ignore attribute and introducing a dedicated test helper function. |
regex-syntax/src/ast/parse.rs | Modified group parsing (renamed to grouping) to support lookaround syntax and added error handling for unsupported lookahead. |
regex-syntax/src/hir/translate.rs | Implemented HIR translation for LookAround AST nodes with separate handling for positive and negative lookbehinds. |
regex-syntax/src/ast/mod.rs | Introduced a new LookAroundUnclosed error variant and updated function naming for consistency. |
regex-syntax/src/hir/literal.rs | Updated tests to validate lookaround handling in literal printing. |
regex-syntax/src/hir/mod.rs | Minor comment updates reflecting the new "look-around" terminology in the HIR module. |
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
regex-syntax/src/hir/print.rs:489
- [nitpick] Consider rephrasing the comment for clarity. For example, 'We do not perform a roundtrip for lookarounds because they cannot contain capture groups, which are unsupported by the parser.'
// we do not want to do a roundtrip: printed lookarounds are not
// can contain capture groups which are unsupported by the parser.
regex-syntax/src/hir/translate.rs:449
- [nitpick] Ensure that the translation logic for LookAround covers both positive and negative lookbehinds in all edge cases; consider adding a clarifying comment to explain the branching logic.
Ast::LookAround(ref x) => {
regex-syntax/src/hir/literal.rs:2458
- [nitpick] Verify that the tests for lookaround in literal handling accurately reflect the intended behavior, and consider adding tests for lookarounds with non-empty sub-patterns.
fn lookaround() { assert_eq!(exact(["ab"]), e(r"a(?<=qwe)b")); ... }
83f2697
to
cea6425
Compare
0b66651
to
b2e3222
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.