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 {
5252 }
5353 }
5454
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.
5757 ///
5858 /// - Parameters
5959 /// - 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 {
2121 /// item.
2222 ///
2323 /// - Parameters:
24- /// - allowRecovery: Whether to attempt to perform recovery.
2524 /// - preferExpr: If either an expression or statement could be
2625 /// parsed and this parameter is `true`, the function returns `false`
2726 /// such that an expression can be parsed.
@@ -1022,7 +1021,6 @@ extension Parser.Lookahead {
10221021 /// item.
10231022 ///
10241023 /// - Parameters:
1025- /// - allowRecovery: Whether to attempt to perform recovery.
10261024 /// - preferExpr: If either an expression or statement could be
10271025 /// parsed and this parameter is `true`, the function returns `false`
10281026 /// such that an expression can be parsed.
Original file line number Diff line number Diff line change @@ -38,16 +38,16 @@ enum TokenPrecedence: Comparable {
3838 case mediumPunctuator
3939 /// The closing delimiter of `weakBracketed`
4040 case weakBracketClose
41- /// Keywords that start a new statement.
42- case stmtKeyword
4341 /// The '{' token because it typically marks the body of a declaration.
4442 /// `closingDelimiter` must have type `strongPunctuator`
4543 case openingBrace( closingDelimiter: RawTokenKind )
4644 /// A punctuator that is a strong indicator that it separates two distinct parts of the source code, like two statements
4745 case strongPunctuator
4846 /// The closing delimiter of `strongBracketed`
4947 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
5151 case declKeyword
5252 case openingPoundIf
5353 case closingPoundIf
@@ -85,17 +85,17 @@ enum TokenPrecedence: Comparable {
8585 case . weakBracketClose:
8686 return 6
8787 case . strongPunctuator:
88- return 8
88+ return 7
8989 case . openingBrace:
90- return 9
90+ return 8
9191 case . declKeyword, . stmtKeyword:
92- return 10
92+ return 9
9393 case . closingBrace:
94- return 11
94+ return 10
9595 case . openingPoundIf:
96- return 12
96+ return 11
9797 case . closingPoundIf:
98- return 13
98+ return 12
9999 }
100100 }
101101
Original file line number Diff line number Diff line change @@ -133,24 +133,6 @@ extension Parser {
133133 )
134134 }
135135
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-
154136 /// Parse an individual item - either in a code block or at the top level.
155137 ///
156138 /// 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