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

parse to pattern #2512

Open
snotbubble opened this issue Aug 8, 2022 · 2 comments
Open

parse to pattern #2512

snotbubble opened this issue Aug 8, 2022 · 2 comments
Labels
Red compatibility Issues and changes required for compatibility with Red language Type.parse Parse related issues Type.wish

Comments

@snotbubble
Copy link

would be useful...

Current behavior:

a: "2. two" b: "" c: charset "0123456789" parse a [ to 1 5 c thru ". " copy b to end ] b
== ""

Expected behavior (same as Red):

a: "2. two" b: "" c: charset "0123456789" parse a [ to 1 5 c thru ". " copy b to end ] b
== "two"
@Oldes
Copy link
Owner

Oldes commented Aug 8, 2022

It would be nice for the compatibility reasons, but you can easily get the same result using:

a: "2. two" b: "" c: charset "0123456789" parse a [ to c 1 5 c ". " copy b to end ] b

To implement direct support would be much difficult and I think it would slow down all parsing because of additional checks, so I'm not sure if I want to do it.

Btw... there are some common bitsets predefined in system/catalog/bitsets.. so you can also use:

digit: system/catalog/bitsets/numeric
result: parse "2. two" [
    to  digit
    1 5 digit
    ". "
    return to end
]
;== "two"

@Oldes Oldes transferred this issue from Oldes/Rebol3 Aug 8, 2022
@Oldes Oldes added Type.wish Type.parse Parse related issues Red compatibility Issues and changes required for compatibility with Red language labels Aug 8, 2022
@snotbubble
Copy link
Author

understood, will use digit, and marks as a fallback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Red compatibility Issues and changes required for compatibility with Red language Type.parse Parse related issues Type.wish
Projects
None yet
Development

No branches or pull requests

2 participants