Skip to content

Add basic code point parsers #88

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 5 commits into from
Mar 7, 2022
Merged

Add basic code point parsers #88

merged 5 commits into from
Mar 7, 2022

Conversation

chtenb
Copy link
Member

@chtenb chtenb commented Mar 5, 2022

Fix #85


Checklist:

  • Added the change to the changelog's "Unreleased" section with a link to this PR and your username
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation in the README and/or documentation directory
  • Added a test for the contribution (if applicable)

@chtenb chtenb requested a review from jamesdbrock March 5, 2022 10:42
cp <- anyCodePoint
case toChar cp of
Just chr -> pure chr
Nothing -> fail $ "Code point " <> show cp <> " is not a character"
where
toChar = fromCharCode <<< fromEnum
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed and uncommented the test I added for that earlier :)

-- | Match any code point.
anyCodePoint :: Parser CodePoint
anyCodePoint = Parser \{ substring, position } ->
case SCP.codePointAt 0 substring of
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

That's better indeed

@chtenb chtenb merged commit efbe004 into main Mar 7, 2022
@chtenb chtenb deleted the codepointParsers branch March 7, 2022 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add anyCodePoint
2 participants