Skip to content

Update PatternConverter #359

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

Merged
merged 2 commits into from
Apr 28, 2022
Merged

Update PatternConverter #359

merged 2 commits into from
Apr 28, 2022

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Apr 26, 2022

This updates the pattern converter to generate DSLs that are updated with the current proposed (and implemented) API. There are some character classes that are "unprintable" which kind of complicate the printing process.

// For example: '[\d[:upper:]abc](a|b)'

Regex {
  #/\d[:upper:]abc]/#
  Capture {
    ChoiceOf {
      "a"
      "b"
    }
  }
}

That being said, character classes that we support print pretty well!

// For example: [a-z--[^a-c]]

Regex {
  ("a"..."z")
    .subtraction(("a"..."c").inverted)
}

@Azoy Azoy requested review from natecook1000 and DaveEwing April 26, 2022 22:12
Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

Quick look over and LGTM

}

case .trivia:
// What should we do? Maybe keep comments, etc?
print("")
// We never print trivia
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not print them as a comment (since that's what they are)?

@Azoy
Copy link
Contributor Author

Azoy commented Apr 28, 2022

@swift-ci please test

@Azoy Azoy merged commit 40c177f into swiftlang:main Apr 28, 2022
@Azoy Azoy deleted the update-patternconverter branch April 28, 2022 16:35
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.

3 participants