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

More concise character set syntax (like version 0.5) #240

Open
jocutajar opened this issue Aug 23, 2020 · 0 comments
Open

More concise character set syntax (like version 0.5) #240

jocutajar opened this issue Aug 23, 2020 · 0 comments
Labels
feature Something not supported that perhaps should be

Comments

@jocutajar
Copy link

Hi Kevin,
In the move to 0.6 we've lost a substantial amount of eyecandy and readability. I appreciate that the redesign must have simplified many things in your code, or even improved performance. I'm struggling with the new syntax though.


        rule char_regular() -> u8
            = b:$(quiet!{[b'-' | b'!' | b'#' | b'$' | b'%' | b'&' |
                b'\'' | b'*' | b'+' | b'-' | b'`' | b'/' |
                    b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' |
                    b'=' | b'?' | b'~' | b'^' | b'_' | b'{' | b'}' | b'|' | 0x80..=0xFF
            ]} / expected!("regular character"))
            {debug_assert!(b.len()==1); b[0]}

I don't remember exactly, but this used to be something like

        rule char_regular() -> u8
            = b:$(quiet!{[-!#$%&\'*+`/0-9a-zA-Z=?~^_{}|\u80\uFF]} / expected!("regular character"))
            {debug_assert!(b.len()==1); b[0]}

Eyes hurt when I try to analyze the new set description. Could you include some macros perhaps that would take the old syntax or similar and produce the appropriate matching pattern? I can imagine this would be possible to adapt:

       rule char_regular() -> u8
            = b:$(quiet!{[any!("-!#$%&\'*+`/0-9a-zA-Z=?~^_{}|\u80\uFF")]} / expected!("regular character"))
            {debug_assert!(b.len()==1); b[0]}

Thank you. Ref https://gitlab.com/BrightOpen/BackYard/Samotop/-/blob/develop/samotop-parser/src/smtp.rs

@kevinmehall kevinmehall changed the title Restoring eyecandy syntax More concise character set syntax (like version 0.5) Jul 17, 2021
@kevinmehall kevinmehall added the feature Something not supported that perhaps should be label Jul 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something not supported that perhaps should be
Projects
None yet
Development

No branches or pull requests

2 participants