[swift-evolution] [Proposal] Refining Identifier and Operator Symbology
jtbandes at gmail.com
Wed Oct 19 23:44:07 CDT 2016
On Wed, Oct 19, 2016 at 10:12 AM, Alex Martini <amartini at apple.com> wrote:
> Grammar changes
> operator → operator-head operator-characters[opt]
> operator-head → ! % & * + - / < = > ? ^ | ~
> operator-head → operator-dot operator-dots
> operator-character → operator-head
> operator-characters → operator-character operator-character[opt]
> operator-dot → .
> operator-dots → operator-dot operator-dots[opt]
> I think there's a mismatch between the English and grammar. For example,
> is +..+ allowed or not?
> The English rule does allow +..+ because its dots appear in a run of two.
> The grammar allows a run of one or more dots as an operator head, but
> never allows dots as characters appearing in the middle of an operator,
> regardless of how many dots appear next to each other. The grammar
> wouldn't allow +..+ because the dots don't come at the beginning.
> Here's an alternate version of the grammar that matches the "two or more"
> rule. Because we no longer distinguish between which characters are
> allowed as the first character of an operator vs a character inside,
> there's no longer a need for a separate operator-head.
> operator --> operator-character operator-OPT
> operator-character --> ! % & * + - / < = > ? ^ | ~
> operator-character --> operator-dots
> operator-dots --> .. operator-additional-dots-OPT
> operator-additional-dots --> . operator-additional-dots-OPT
There is a typo in that operator-character[opt] should be
operator-characters[opt]. Aside from that, though, I believe the grammar as
written accepts +..+ already. Take a look at the following series of
substitutions based on the grammar rules:
+ operator-character operator-characters[opt]
+ operator-head operator-head
+ operator-dot operator-dots operator-head
+ . . +
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution