@@ -41,8 +41,8 @@ public protocol TokenConsumer {
41
41
struct TokenConsumptionHandle {
42
42
/// The kind that is expected to be consumed if the handle is eaten.
43
43
var tokenKind : RawTokenKind
44
- /// Whether the token should be remapped to a contextual keyword when eaten
45
- var remapToContextualKeyword : Bool
44
+ /// When not `nil`, the token's kind will be remapped to this kind when consumed.
45
+ var remappedKind : RawTokenKind ?
46
46
}
47
47
48
48
extension TokenConsumer {
@@ -106,7 +106,7 @@ extension TokenConsumer {
106
106
if let matchedKind = Subset ( self . currentToken) {
107
107
return ( matchedKind, TokenConsumptionHandle (
108
108
tokenKind: matchedKind. rawTokenKind,
109
- remapToContextualKeyword : matchedKind. contextualKeyword != nil
109
+ remappedKind : matchedKind. remappedKind
110
110
) )
111
111
}
112
112
return nil
@@ -115,8 +115,8 @@ extension TokenConsumer {
115
115
/// Eat a token that we know we are currently positioned at, based on `at(anyIn:)`.
116
116
mutating func eat( _ handle: TokenConsumptionHandle ) -> Token {
117
117
assert ( self . at ( handle. tokenKind) )
118
- if handle. remapToContextualKeyword {
119
- return consumeAnyToken ( remapping: . contextualKeyword )
118
+ if let remappedKind = handle. remappedKind {
119
+ return consumeAnyToken ( remapping: remappedKind )
120
120
} else {
121
121
return consumeAnyToken ( )
122
122
}
0 commit comments