@@ -26,6 +26,7 @@ class Child {
26
26
let classification : SyntaxClassification ?
27
27
/// A restricted set of token kinds that will be accepted for this child.
28
28
let tokenChoices : [ Token ]
29
+ let tokenCanContainArbitraryText : Bool
29
30
30
31
var swiftName : String {
31
32
return lowercaseFirstWord ( name: name)
@@ -95,14 +96,18 @@ class Child {
95
96
self . requiresLeadingNewline = requiresLeadingNewline
96
97
self . isOptional = isOptional
97
98
98
- var mappedTokenChoices = [ Token] ( )
99
+ let isToken = syntaxKind. hasSuffix ( " Token " )
100
+ var mappedTokenChoices = [ Token? ] ( )
99
101
100
- if syntaxKind . hasSuffix ( " Token " ) , let token = SYNTAX_TOKEN_MAP [ syntaxKind] {
102
+ if isToken , let token = SYNTAX_TOKEN_MAP [ syntaxKind] {
101
103
mappedTokenChoices. append ( token)
102
104
}
103
105
104
- mappedTokenChoices. append ( contentsOf: tokenChoices. compactMap { SYNTAX_TOKEN_MAP [ " \( $0) Token " ] } )
105
- self . tokenChoices = mappedTokenChoices
106
+ mappedTokenChoices. append ( contentsOf: tokenChoices. map { SYNTAX_TOKEN_MAP [ " \( $0) Token " ] } )
107
+ self . tokenChoices = mappedTokenChoices. compactMap { $0 }
108
+
109
+ // If mappedTokenChoices contains `nil`, the token can contain arbitrary text
110
+ self . tokenCanContainArbitraryText = mappedTokenChoices. count != self . tokenChoices. count
106
111
107
112
// A list of valid text for tokens, if specified.
108
113
// This will force validation logic to check the text passed into the
0 commit comments