apple / swift-book

The Swift Programming Language book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reconcile Keywords with Grammar

tadbyt opened this issue · comments

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure#Keywords-and-Punctuation
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/summaryofthegrammar

Description

The following keywords are not identified as such in the Keywords and Punctuation subsection although they are given in various grammar productions in the Summary of the Grammar section:

actor, any (with lowercase a), arch, arm, arm64, assignment, async, borrowing, canImport, compiler, consuming, higherThan, i386, iOS, iOSApplicationExtension, Linux, lowerThan, macCatalyst, macOS, macOSApplicationExtension, macro, nonisolated, os, package, safe, simulator, swift, targetEnvironment, tvOS, tvOSApplicationExtension, unsafe, visionOS, watchOS, watchOSApplicationExtension, Windows, x86_64

(This list assumes that issue #230 (#unavailable not Listed as Keyword) is being handled separately.

The specifics of which keyword list they are missing from is given in the attachment along with the rationale.

throw and switch are reversed in Keywords used in statements
private and precedencegroup are reversed in Keywords used in declarations

Correction

See attachment.
Reconcile Keywords with Grammar.pdf

Also, update the second sentence in the Keywords and Punctuation subsection of the Lexical Structure section to read:

Keywords other than inout, borrowing, consuming, var, and let can be used as parameter names in a function declaration or function call without being escaped with backticks.

Also, remove catch and throw from the Keywords used in expressions and types. (They remain in Keywords used in statements.)

Also, add case, default, else, if, and switch to the Keywords used in expressions and types. (This is due to conditional expressions; these all remain in Keywords used in statements.)

Also, add throws to the Keywords used in declarations. (It remains in Keywords used in expressions and types.)

Also, remove precedence from the Keywords used in particular contexts. (It is not currently contained anywhere in the grammar.)