@@ -22,27 +22,36 @@ import SwiftSyntax
2222
2323/// Namespace for commonly used tokens with default trivia.
2424enum Tokens {
25- // MARK: Keywords
26-
2725% for token in SYNTAX_TOKENS:
2826% if token. is_keyword:
29- /// The `${token.text}` keyword
30- static let `${lowercase_first_word(token.name)}` = SyntaxFactory . make${ token. name} Keyword( ) . withTrailingTrivia ( . spaces( 1 ) )
27+ /// The `${token.text.encode('utf-8').decode('unicode_escape')}` keyword
28+ static let `${lowercase_first_word(token.name)}` = SyntaxFactory . make${ token. name} Keyword( )
29+ % if token. requires_leading_space:
30+ . withLeadingTrivia ( . spaces( 1 ) )
31+ % end
32+ % if token. requires_trailing_space:
33+ . withTrailingTrivia ( . spaces( 1 ) )
34+ % end
35+ % elif token. text:
36+ /// The `${token.text.encode('utf-8').decode('unicode_escape')}` token
37+ static let `${lowercase_first_word(token.name)}` = SyntaxFactory . make ${ token. name} Token( )
38+ % if token. requires_leading_space:
39+ . withLeadingTrivia ( . spaces( 1 ) )
40+ % end
41+ % if token. requires_trailing_space:
42+ . withTrailingTrivia ( . spaces( 1 ) )
43+ % end
44+ % else:
45+ static func `${lowercase_first_word(token.name)}`( _ text: String) - > TokenSyntax {
46+ SyntaxFactory . make ${ token. name} ( text)
47+ % if token. requires_leading_space:
48+ . withLeadingTrivia ( . spaces( 1 ) )
49+ % end
50+ % if token. requires_trailing_space:
51+ . withTrailingTrivia ( . spaces( 1 ) )
52+ % end
53+ }
3154% end
32- % end
33-
34- // MARK: Punctuations and Signs
35-
36- /// `":"`
37- static let colon = SyntaxFactory . makeColonToken ( ) . withTrailingTrivia ( . spaces( 1 ) )
38-
39- /// `" = "`
40- static let equal = SyntaxFactory . makeEqualToken ( ) . withLeadingTrivia ( . spaces( 1 ) )
41- . withTrailingTrivia ( . spaces( 1 ) )
42-
43- /// `"{"`
44- static let leftBrace = SyntaxFactory . makeLeftBraceToken ( )
4555
46- /// `"}"`
47- static let rightBrace = SyntaxFactory . makeRightBraceToken ( )
56+ % end
4857}
0 commit comments