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

Prefer single quotes for terminals #125

Merged
merged 1 commit into from
Feb 15, 2023
Merged

Prefer single quotes for terminals #125

merged 1 commit into from
Feb 15, 2023

Conversation

CrockAgile
Copy link
Collaborator

@CrockAgile CrockAgile commented Feb 15, 2023

An even more silly PR, but maybe a style question. Most of BNF's examples and tests use double quotes for the string literal of terminals. This leads to a lot of escaping, and takes more space than a single quote (\" vs ').

This PR changes examples and tests to use single quotes. I don't think this matters much, but it does look better to my arbitrary eyes/brain.

The one controversial part to his that I see is that the existing Display implementations default to double quotes. So users who call Grammar.to_string() or similar will see the terminals in double quotes.

An alternative to this PR would be to update examples / tests to use r# string literals. This would allow for double quotes, without the need to escape:

r#"<zip-part> ::= <town-name> "," <state-code> <ZIP-code> <EOL>"#

@CrockAgile CrockAgile self-assigned this Feb 15, 2023
@coveralls
Copy link

Coverage Status

Coverage: 91.063%. Remained the same when pulling d6b5254 on prefer-single-quotes into 50cfb26 on main.

Copy link
Owner

@shnewto shnewto left a comment

Choose a reason for hiding this comment

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

oh mannnn this is so great. aside from it being great cleanup feeling, and even tho I think it's good we support both, I'm glad abt the idea that anyone reading the docs will be set up w ' as a place to start instead of "\"

@CrockAgile CrockAgile merged commit 9db5aaa into main Feb 15, 2023
@CrockAgile CrockAgile deleted the prefer-single-quotes branch February 15, 2023 15:59
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