File tree Expand file tree Collapse file tree 4 files changed +11
-31
lines changed Expand file tree Collapse file tree 4 files changed +11
-31
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ extension TokenConsumer {
52
52
}
53
53
}
54
54
55
- /// Check if the current token is at a start of any declaration.
56
- ///
55
+ /// Returns `true` if the current token represents the start of a declaration
56
+ /// item.
57
57
///
58
58
/// - Parameters
59
59
/// - allowInitDecl: whether to consider 'init' a declaration in the context.
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ extension TokenConsumer {
21
21
/// item.
22
22
///
23
23
/// - Parameters:
24
- /// - allowRecovery: Whether to attempt to perform recovery.
25
24
/// - preferExpr: If either an expression or statement could be
26
25
/// parsed and this parameter is `true`, the function returns `false`
27
26
/// such that an expression can be parsed.
@@ -1022,7 +1021,6 @@ extension Parser.Lookahead {
1022
1021
/// item.
1023
1022
///
1024
1023
/// - Parameters:
1025
- /// - allowRecovery: Whether to attempt to perform recovery.
1026
1024
/// - preferExpr: If either an expression or statement could be
1027
1025
/// parsed and this parameter is `true`, the function returns `false`
1028
1026
/// such that an expression can be parsed.
Original file line number Diff line number Diff line change @@ -38,16 +38,16 @@ enum TokenPrecedence: Comparable {
38
38
case mediumPunctuator
39
39
/// The closing delimiter of `weakBracketed`
40
40
case weakBracketClose
41
- /// Keywords that start a new statement.
42
- case stmtKeyword
43
41
/// The '{' token because it typically marks the body of a declaration.
44
42
/// `closingDelimiter` must have type `strongPunctuator`
45
43
case openingBrace( closingDelimiter: RawTokenKind )
46
44
/// A punctuator that is a strong indicator that it separates two distinct parts of the source code, like two statements
47
45
case strongPunctuator
48
46
/// The closing delimiter of `strongBracketed`
49
47
case closingBrace
50
- /// Tokens that start a new declaration
48
+ /// Keywords that start a new statement.
49
+ case stmtKeyword
50
+ /// Keywords that start a new declaration
51
51
case declKeyword
52
52
case openingPoundIf
53
53
case closingPoundIf
@@ -85,17 +85,17 @@ enum TokenPrecedence: Comparable {
85
85
case . weakBracketClose:
86
86
return 6
87
87
case . strongPunctuator:
88
- return 8
88
+ return 7
89
89
case . openingBrace:
90
- return 9
90
+ return 8
91
91
case . declKeyword, . stmtKeyword:
92
- return 10
92
+ return 9
93
93
case . closingBrace:
94
- return 11
94
+ return 10
95
95
case . openingPoundIf:
96
- return 12
96
+ return 11
97
97
case . closingPoundIf:
98
- return 13
98
+ return 12
99
99
}
100
100
}
101
101
Original file line number Diff line number Diff line change @@ -133,24 +133,6 @@ extension Parser {
133
133
)
134
134
}
135
135
136
- mutating func fixWithSemi( codeBlockItem item: RawCodeBlockItemSyntax . Item ) -> RawCodeBlockItemSyntax ? {
137
- let semi = self . consume ( if: . semicolon)
138
- var trailingSemis : [ RawTokenSyntax ] = [ ]
139
- while let trailingSemi = self . consume ( if: . semicolon) {
140
- trailingSemis. append ( trailingSemi)
141
- }
142
-
143
- if item. raw. isEmpty && semi == nil && trailingSemis. isEmpty {
144
- return nil
145
- }
146
- return RawCodeBlockItemSyntax (
147
- item: item,
148
- semicolon: semi,
149
- RawUnexpectedNodesSyntax ( trailingSemis, arena: self . arena) ,
150
- arena: self . arena
151
- )
152
- }
153
-
154
136
/// Parse an individual item - either in a code block or at the top level.
155
137
///
156
138
/// Returns `nil` if the parser did not consume any tokens while trying to
You can’t perform that action at this time.
0 commit comments