shnewto / bnf

Parse BNF grammar definitions
MIT License
256 stars 22 forks source link

Prefer single quotes for terminals #125

Closed CrockAgile closed 1 year ago

CrockAgile commented 1 year ago

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>"#

coveralls commented 1 year ago

Coverage Status

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