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

Add an Escaped character parser combinator #6

Open
oleiade opened this issue Sep 8, 2022 · 0 comments
Open

Add an Escaped character parser combinator #6

oleiade opened this issue Sep 8, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@oleiade
Copy link
Owner

oleiade commented Sep 8, 2022

As we've been implementing an example JSON parser, we encountered the need to manage "escaped" strings.

Go strings are escaped, and when parsing the following string: {"abc": "123"}, it is interpreted as {\"abc\": \"123\"}.

Its prototype would probably be:

func Escaped[I Bytes, PO, EO any](parse Parser[I, PO], control rune, escape Parser[I, EO]) Result[I, I] 

And would behave in the following way:

func main() {
    result := Escaped(Alpha1(), '\\', OneOf(""n\"))("\"abc\"")
    result.Output == "abc"
}
@oleiade oleiade added the enhancement New feature or request label Sep 8, 2022
@oleiade oleiade added this to the v0.2.0 milestone Sep 8, 2022
@oleiade oleiade self-assigned this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant