Skip to content

Commit 9945b3e

Browse files
committed
Remove Grammar doc comments
These grammars were most of the time incomplete, incorrect and in the case of recovery wrong by definition. Instead of having misleading doc comments, let’s delete them entirely.
1 parent 0c41fe6 commit 9945b3e

File tree

8 files changed

+1
-743
lines changed

8 files changed

+1
-743
lines changed

Sources/SwiftParser/Availability.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414

1515
extension Parser {
1616
/// Parse a list of availability arguments.
17-
///
18-
/// Grammar
19-
/// =======
20-
///
21-
/// availability-arguments → availability-argument | availability-argument , availability-arguments
2217
mutating func parseAvailabilitySpecList() -> RawAvailabilitySpecListSyntax {
2318
var elements = [RawAvailabilityArgumentSyntax]()
2419
do {
@@ -181,12 +176,6 @@ extension Parser {
181176
}
182177

183178
/// Parse an availability argument.
184-
///
185-
/// Grammar
186-
/// =======
187-
///
188-
/// availability-argument → platform-name platform-version
189-
/// availability-argument → *
190179
mutating func parseAvailabilitySpec() -> RawAvailabilityArgumentSyntax.Entry {
191180
if let star = self.consumeIfContextualPunctuator("*") {
192181
// FIXME: Use makeAvailabilityVersionRestriction here - but swift-format
@@ -201,11 +190,6 @@ extension Parser {
201190
///
202191
/// Availability macros are not an official part of the Swift language.
203192
///
204-
/// Grammar
205-
/// =======
206-
///
207-
/// availability-argument → macro-name platform-version
208-
///
209193
/// If `allowStarAsVersionNumber` is `true`, versions like `* 13.0` are accepted.
210194
/// This is to match the behavior of `@_originallyDefinedIn` in the old parser that accepted such versions
211195
mutating func parseAvailabilityMacro(allowStarAsVersionNumber: Bool = false) -> RawAvailabilityVersionRestrictionSyntax {
@@ -271,13 +255,6 @@ extension Parser {
271255
}
272256

273257
/// Parse a dot-separated list of version numbers.
274-
///
275-
/// Grammar
276-
/// =======
277-
///
278-
/// version-tuple -> integer-literal version-list?
279-
/// version-list -> version-tuple-element version-list?
280-
/// version-tuple-element -> '.' integer-literal
281258
mutating func parseVersionTuple(maxComponentCount: Int) -> RawVersionTupleSyntax {
282259
if self.at(.floatingLiteral),
283260
let periodIndex = self.currentToken.tokenText.firstIndex(of: UInt8(ascii: ".")),

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,6 @@ extension Parser {
168168

169169
/// Parse a declaration.
170170
///
171-
/// Grammar
172-
/// =======
173-
///
174-
/// declaration → import-declaration
175-
/// declaration → constant-declaration
176-
/// declaration → variable-declaration
177-
/// declaration → typealias-declaration
178-
/// declaration → function-declaration
179-
/// declaration → enum-declaration
180-
/// declaration → struct-declaration
181-
/// declaration → class-declaration
182-
/// declaration → actor-declaration
183-
/// declaration → protocol-declaration
184-
/// declaration → initializer-declaration
185-
/// declaration → deinitializer-declaration
186-
/// declaration → extension-declaration
187-
/// declaration → subscript-declaration
188-
/// declaration → operator-declaration
189-
/// declaration → precedence-group-declaration
190-
/// declaration → macro-declaration
191-
///
192-
/// declarations → declaration declarations?
193-
///
194171
/// If `inMemberDeclList` is `true`, we know that the next item must be a
195172
/// declaration and thus start with a keyword. This allows further recovery.
196173
mutating func parseDeclaration(inMemberDeclList: Bool = false) -> RawDeclSyntax {
@@ -313,13 +290,6 @@ extension Parser {
313290

314291
extension Parser {
315292
/// Parse an import declaration.
316-
///
317-
/// Grammar
318-
/// =======
319-
///
320-
/// import-declaration → attributes? 'import' import-kind? import-path
321-
/// import-kind → 'typealias' | 'struct' | 'class' | 'enum' | 'protocol' | 'let' | 'var' | 'func'
322-
/// import-path → identifier | identifier '.' import-path
323293
mutating func parseImportDeclaration(
324294
_ attrs: DeclAttributes,
325295
_ handle: RecoveryConsumptionHandle
@@ -363,14 +333,6 @@ extension Parser {
363333

364334
extension Parser {
365335
/// Parse an extension declaration.
366-
///
367-
/// Grammar
368-
/// =======
369-
///
370-
/// extension-declaration → attributes? access-level-modifier? 'extension' type-identifier type-inheritance-clause? generic-where-clause?t extension-body
371-
/// extension-body → '{' extension-members? '}'
372-
/// extension-members → extension-member extension-members?
373-
/// extension-member → declaration | compiler-control-statement
374336
mutating func parseExtensionDeclaration(
375337
_ attrs: DeclAttributes,
376338
_ handle: RecoveryConsumptionHandle
@@ -798,19 +760,6 @@ extension Parser {
798760

799761
extension Parser {
800762
/// Parse an enum 'case' declaration.
801-
///
802-
/// Grammar
803-
/// =======
804-
///
805-
/// union-style-enum-case-clause → attributes? 'indirect'? 'case' union-style-enum-case-list
806-
/// union-style-enum-case-list → union-style-enum-case | union-style-enum-case ',' union-style-enum-case-list
807-
/// union-style-enum-case → enum-case-name tuple-type?
808-
///
809-
/// raw-value-style-enum-case-clause → attributes? 'case' raw-value-style-enum-case-list
810-
/// raw-value-style-enum-case-list → raw-value-style-enum-case | raw-value-style-enum-case ',' raw-value-style-enum-case-list
811-
/// raw-value-style-enum-case → enum-case-name raw-value-assignment?
812-
/// raw-value-assignment → = raw-value-literal
813-
/// raw-value-literal → numeric-literal | static-string-literal | boolean-literal
814763
mutating func parseEnumCaseDeclaration(
815764
_ attrs: DeclAttributes,
816765
_ handle: RecoveryConsumptionHandle
@@ -872,11 +821,6 @@ extension Parser {
872821
}
873822

874823
/// Parse an associated type declaration.
875-
///
876-
/// Grammar
877-
/// =======
878-
///
879-
/// protocol-associated-type-declaration → attributes? access-level-modifier? 'associatedtype' typealias-name type-inheritance-clause? typealias-assignment? generic-where-clause?
880824
mutating func parseAssociatedTypeDeclaration(
881825
_ attrs: DeclAttributes,
882826
_ handle: RecoveryConsumptionHandle
@@ -956,17 +900,6 @@ extension Parser {
956900

957901
extension Parser {
958902
/// Parse an initializer declaration.
959-
///
960-
/// Grammar
961-
/// =======
962-
///
963-
/// initializer-declaration → initializer-head generic-parameter-clause? parameter-clause 'async'? 'throws'? generic-where-clause? initializer-body
964-
/// initializer-declaration → initializer-head generic-parameter-clause? parameter-clause 'async'? 'rethrows' generic-where-clause? initializer-body
965-
///
966-
/// initializer-head → attributes? declaration-modifiers? 'init'
967-
/// initializer-head → attributes? declaration-modifiers? 'init' '?'
968-
/// initializer-head → attributes? declaration-modifiers? 'init' '!'
969-
/// initializer-body → code-block
970903
mutating func parseInitializerDeclaration(
971904
_ attrs: DeclAttributes,
972905
_ handle: RecoveryConsumptionHandle
@@ -1017,11 +950,6 @@ extension Parser {
1017950
}
1018951

1019952
/// Parse a deinitializer declaration.
1020-
///
1021-
/// Grammar
1022-
/// =======
1023-
///
1024-
/// deinitializer-declaration → attributes? 'deinit' code-block
1025953
mutating func parseDeinitializerDeclaration(
1026954
_ attrs: DeclAttributes,
1027955
_ handle: RecoveryConsumptionHandle
@@ -1186,15 +1114,6 @@ extension Parser {
11861114

11871115
extension Parser {
11881116
/// Parse a subscript declaration.
1189-
///
1190-
/// Grammar
1191-
/// =======
1192-
///
1193-
/// subscript-declaration → subscript-head subscript-result generic-where-clause? code-block
1194-
/// subscript-declaration → subscript-head subscript-result generic-where-clause? getter-setter-block
1195-
/// subscript-declaration → subscript-head subscript-result generic-where-clause? getter-setter-keyword-block
1196-
/// subscript-head → attributes? declaration-modifiers? 'subscript' generic-parameter-clause? parameter-clause
1197-
/// subscript-result → '->' attributes? type
11981117
mutating func parseSubscriptDeclaration(
11991118
_ attrs: DeclAttributes,
12001119
_ handle: RecoveryConsumptionHandle
@@ -1257,14 +1176,6 @@ extension Parser {
12571176
extension Parser {
12581177
/// Parse a variable declaration starting with a leading 'let' or 'var' keyword.
12591178
///
1260-
/// Grammar
1261-
/// =======
1262-
///
1263-
/// constant-declaration → attributes? declaration-modifiers? 'let' pattern-initializer-list
1264-
/// pattern-initializer-list → pattern-initializer | pattern-initializer ',' pattern-initializer-list
1265-
/// pattern-initializer → pattern initializer?
1266-
/// initializer → = expression
1267-
///
12681179
/// If `inMemberDeclList` is `true`, we know that the next item needs to be a
12691180
/// declaration that is started by a keyword. Thus, we in the following case
12701181
/// we know that `set` can't start a new declaration and we can thus recover
@@ -1443,21 +1354,6 @@ extension Parser {
14431354
}
14441355

14451356
/// Parse an accessor once we know we have an introducer
1446-
///
1447-
/// Grammar
1448-
/// =======
1449-
///
1450-
/// getter-clause → attributes opt mutation-modifier opt get code-block
1451-
/// setter-clause → attributes opt mutation-modifier opt set setter-name opt code-block
1452-
/// setter-name → ( identifier )
1453-
/// getter-setter-keyword-block → { getter-keyword-clause setter-keyword-clause opt }
1454-
/// getter-setter-keyword-block → { setter-keyword-clause getter-keyword-clause }
1455-
/// getter-keyword-clause → attributes opt mutation-modifier opt get
1456-
/// setter-keyword-clause → attributes opt mutation-modifier opt set
1457-
/// willSet-didSet-block → { willSet-clause didSet-clause opt }
1458-
/// willSet-didSet-block → { didSet-clause willSet-clause opt }
1459-
/// willSet-clause → attributes opt willSet setter-name opt code-block
1460-
/// didSet-clause → attributes opt didSet setter-name opt code-block
14611357
private mutating func parseAccessorDecl(
14621358
introducer: AccessorIntroducer
14631359
) -> RawAccessorDeclSyntax {
@@ -1500,13 +1396,6 @@ extension Parser {
15001396

15011397
/// Parse the body of a variable declaration. This can include explicit
15021398
/// getters, setters, and observers, or the body of a computed property.
1503-
///
1504-
/// Grammar
1505-
/// =======
1506-
///
1507-
/// getter-setter-block → code-block
1508-
/// getter-setter-block → { getter-clause setter-clause opt }
1509-
/// getter-setter-block → { setter-clause getter-clause }
15101399
mutating func parseGetSet() -> RawSubscriptDeclSyntax.Accessors {
15111400
// Parse getter and setter.
15121401
let unexpectedBeforeLBrace: RawUnexpectedNodesSyntax?
@@ -1574,13 +1463,6 @@ extension Parser {
15741463

15751464
extension Parser {
15761465
/// Parse a typealias declaration.
1577-
///
1578-
/// Grammar
1579-
/// =======
1580-
///
1581-
/// typealias-declaration → attributes? access-level-modifier? 'typealias' typealias-name generic-parameter-clause? typealias-assignment
1582-
/// typealias-name → identifier
1583-
/// typealias-assignment → '=' type
15841466
mutating func parseTypealiasDeclaration(
15851467
_ attrs: DeclAttributes,
15861468
_ handle: RecoveryConsumptionHandle
@@ -1637,24 +1519,14 @@ extension Parser {
16371519
}
16381520

16391521
extension Parser {
1640-
/// Parse an operator declaration.
1641-
///
1642-
/// Grammar
1643-
/// =======
1644-
///
1645-
/// operator-declaration → prefix-operator-declaration | postfix-operator-declaration | infix-operator-declaration
1646-
/// prefix-operator-declaration → 'prefix' 'operator' operator
1647-
/// postfix-operator-declaration → 'postfix' 'operator' operator
1648-
/// infix-operator-declaration → 'infix' 'operator' operator infix-operator-group?
1649-
/// infix-operator-group → ':' precedence-group-name
1650-
16511522
struct OperatorDeclIntroducer {
16521523
var unexpectedBeforeFixity: RawUnexpectedNodesSyntax?
16531524
var fixity: RawTokenSyntax
16541525
var unexpectedBeforeOperatorKeyword: RawUnexpectedNodesSyntax?
16551526
var operatorKeyword: RawTokenSyntax
16561527
}
16571528

1529+
/// Parse an operator declaration.
16581530
mutating func parseOperatorDeclIntroducer(_ attrs: DeclAttributes, _ handle: RecoveryConsumptionHandle) -> OperatorDeclIntroducer {
16591531
func isFixity(_ modifier: RawDeclModifierSyntax) -> Bool {
16601532
switch modifier.name {
@@ -1809,28 +1681,6 @@ extension Parser {
18091681
}
18101682

18111683
/// Parse a precedence group declaration.
1812-
///
1813-
/// Grammar
1814-
/// =======
1815-
///
1816-
/// precedence-group-declaration → precedencegroup precedence-group-name '{' precedence-group-attributes? '}'
1817-
///
1818-
/// precedence-group-attributes → precedence-group-attribute precedence-group-attributes?
1819-
/// precedence-group-attribute → precedence-group-relation
1820-
/// precedence-group-attribute → precedence-group-assignment
1821-
/// precedence-group-attribute → precedence-group-associativity
1822-
///
1823-
/// precedence-group-relation → 'higherThan' ':' precedence-group-names
1824-
/// precedence-group-relation → 'lowerThan' ':' precedence-group-names
1825-
///
1826-
/// precedence-group-assignment → 'assignment' ':' boolean-literal
1827-
///
1828-
/// precedence-group-associativity → 'associativity' ':' 'left'
1829-
/// precedence-group-associativity → 'associativity' ':' 'right'
1830-
/// precedence-group-associativity → 'associativity' ':' 'none'
1831-
///
1832-
/// precedence-group-names → precedence-group-name | precedence-group-name ',' precedence-group-names
1833-
/// precedence-group-name → identifier
18341684
mutating func parsePrecedenceGroupDeclaration(
18351685
_ attrs: DeclAttributes,
18361686
_ handle: RecoveryConsumptionHandle
@@ -2031,12 +1881,6 @@ extension Parser {
20311881
}
20321882

20331883
/// Parse a macro expansion as a declaration.
2034-
///
2035-
///
2036-
/// Grammar
2037-
/// =======
2038-
///
2039-
/// macro-expansion-declaration → '#' identifier expr-call-suffix?
20401884
mutating func parseMacroExpansionDeclaration(
20411885
_ attrs: DeclAttributes,
20421886
_ handle: RecoveryConsumptionHandle

Sources/SwiftParser/Directives.swift

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,6 @@ extension Parser {
4545
/// parsing parses items and collects the items into a ``MemberDeclListSyntax``
4646
/// node.
4747
///
48-
/// Grammar
49-
/// =======
50-
///
51-
/// conditional-compilation-block → if-directive-clause elseif-directive-clauses? else-directive-clause? endif-directive
52-
///
53-
/// if-directive-clause → if-directive compilation-condition statements?
54-
/// elseif-directive-clauses → elseif-directive-clause elseif-directive-clauses?
55-
/// elseif-directive-clause → elseif-directive compilation-condition statements?
56-
/// else-directive-clause → else-directive statements?
57-
/// if-directive → '#if'
58-
/// elseif-directive → '#elseif'
59-
/// else-directive → '#else'
60-
/// endif-directive → '#endif'
61-
///
62-
/// compilation-condition → platform-condition
63-
/// compilation-condition → identifier
64-
/// compilation-condition → boolean-literal
65-
/// compilation-condition → '(' compilation-condition ')'
66-
/// compilation-condition → '!' compilation-condition
67-
/// compilation-condition → compilation-condition '&&' compilation-condition
68-
/// compilation-condition → compilation-condition '||' compilation-condition
69-
///
70-
/// platform-condition → 'os' '(' operating-system ')'
71-
/// platform-condition → 'arch' '(' architecture ')'
72-
/// platform-condition → 'swift' '(' '>=' swift-version ')' | 'swift' ( < swift-version )
73-
/// platform-condition → 'compiler' '(' '>=' swift-version ')' | 'compiler' ( < swift-version )
74-
/// platform-condition → 'canImport' '(' import-path ')'
75-
/// platform-condition → 'targetEnvironment' '(' environment ')'
76-
///
77-
/// operating-system → 'macOS' | 'iOS' | 'watchOS' | 'tvOS' | 'Linux' | 'Windows'
78-
/// architecture → 'i386' | 'x86_64' | 'arm' | 'arm64'
79-
/// swift-version → decimal-digits swift-version-continuation?
80-
/// swift-version-continuation → '.' decimal-digits swift-version-continuation?
81-
/// environment → 'simulator' | 'macCatalyst'
82-
///
8348
/// - Parameters:
8449
/// - parseElement: Parse an element of the conditional compilation block.
8550
/// - addSemicolonIfNeeded: If elements need to be separated by a newline, this
@@ -224,14 +189,6 @@ extension Parser {
224189

225190
extension Parser {
226191
/// Parse a line control directive.
227-
///
228-
/// Grammar
229-
/// =======
230-
///
231-
/// line-control-statement → '#sourceLocation' '(' 'file' ':' file-path ',' 'line' ':' line-number ')'
232-
/// line-control-statement → '#sourceLocation' '(' ')'
233-
/// line-number → `A decimal integer greater than zero`
234-
/// file-path → static-string-literal
235192
mutating func parsePoundSourceLocationDirective() -> RawPoundSourceLocationSyntax {
236193
let line = self.consumeAnyToken()
237194
let (unexpectedBeforeLParen, lparen) = self.expect(.leftParen)

0 commit comments

Comments
 (0)