mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Store leading a trailing "trivia" around a token, such as whitespace, comments, doc comments, and escaping backticks. These are syntactically important for preserving formatting when printing ASTs but don't semantically affect the program. Tokens take all trailing trivia up to, but not including, the next newline. This is important to maintain checks that statements without semicolon separators start on a new line, among other things. Trivia are now data attached to the ends of tokens, not tokens themselves. Create a new Syntax sublibrary for upcoming immutable, persistent, thread-safe ASTs, which will contain only the syntactic information about source structure, as well as for generating new source code, and structural editing. Proactively move swift::Token into there. Since this patch is getting a bit large, a token fuzzer which checks for round-trip equivlence with the workflow: fuzzer => token stream => file1 => Lexer => token stream => file 2 => diff(file1, file2) Will arrive in a subsequent commit. This patch does not change the grammar.
60 lines
1.2 KiB
Plaintext
60 lines
1.2 KiB
Plaintext
{
|
|
key.offset: 0,
|
|
key.length: 114,
|
|
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
|
|
key.syntaxmap: [
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.comment,
|
|
key.offset: 0,
|
|
key.length: 21
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.comment,
|
|
key.offset: 22,
|
|
key.length: 57
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 81,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 87,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 97,
|
|
key.length: 3
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 101,
|
|
key.length: 4
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.typeidentifier,
|
|
key.offset: 108,
|
|
key.length: 3
|
|
}
|
|
]
|
|
}
|
|
{
|
|
key.offset: 81,
|
|
key.length: 15,
|
|
key.diagnostic_stage: source.diagnostic.stage.swift.parse,
|
|
key.syntaxmap: [
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.keyword,
|
|
key.offset: 81,
|
|
key.length: 5
|
|
},
|
|
{
|
|
key.kind: source.lang.swift.syntaxtype.identifier,
|
|
key.offset: 87,
|
|
key.length: 6
|
|
}
|
|
]
|
|
}
|