mirror of
https://github.com/apple/swift.git
synced 2026-06-27 12:25:55 +02:00
e0d167f1dd
Variable declarations are declarations led by either 'var' or 'let'. It can contain multiple pattern bindings as children. For patterns, this patch only creates syntax nodes for simple identifier patterns, e.g. 'a = 3'. The rest of the pattern kinds are still left unknown (UnknownPattern).
568 lines
26 KiB
JSON
568 lines
26 KiB
JSON
{
|
|
"kind": "SourceFile",
|
|
"layout": [
|
|
{
|
|
"kind": "DeclList",
|
|
"layout": [
|
|
{
|
|
"kind": "TopLevelCodeDecl",
|
|
"layout": [
|
|
{
|
|
"kind": "StmtList",
|
|
"layout": [
|
|
{
|
|
"kind": "DeclarationStmt",
|
|
"layout": [
|
|
{
|
|
"kind": "StructDecl",
|
|
"layout": [
|
|
{
|
|
"kind": "AttributeList",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "DeclModifier",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "kw_struct"
|
|
},
|
|
"leadingTrivia": [
|
|
{
|
|
"kind": "LineComment",
|
|
"value": "\/\/ RUN: %swift-syntax-test -input-source-filename %s -serialize-raw-tree > %t"
|
|
},
|
|
{
|
|
"kind": "Newline",
|
|
"value": 1
|
|
},
|
|
{
|
|
"kind": "LineComment",
|
|
"value": "\/\/ RUN: diff %t %S\/Inputs\/serialize_struct_decl.json"
|
|
},
|
|
{
|
|
"kind": "Newline",
|
|
"value": 2
|
|
}
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "identifier",
|
|
"text": "Foo"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "GenericParameterClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "TypeInheritanceClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "GenericWhereClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "MemberDeclBlock",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "l_brace"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "DeclList",
|
|
"layout": [
|
|
{
|
|
"kind": "VariableDecl",
|
|
"layout": [
|
|
{
|
|
"kind": "AttributeList",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "ModifierList",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "kw_let"
|
|
},
|
|
"leadingTrivia": [
|
|
{
|
|
"kind": "Newline",
|
|
"value": 1
|
|
},
|
|
{
|
|
"kind": "Space",
|
|
"value": 2
|
|
}
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 3
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "PatternBindingList",
|
|
"layout": [
|
|
{
|
|
"kind": "PatternBinding",
|
|
"layout": [
|
|
{
|
|
"kind": "IdentifierPattern",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "identifier",
|
|
"text": "bar"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "TypeAnnotation",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "colon"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "SimpleTypeIdentifier",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "identifier",
|
|
"text": "Int"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "GenericArgumentClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "InitializerClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "AccessorBlock",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "comma"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "VariableDecl",
|
|
"layout": [
|
|
{
|
|
"kind": "AttributeList",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "ModifierList",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "kw_let"
|
|
},
|
|
"leadingTrivia": [
|
|
{
|
|
"kind": "Newline",
|
|
"value": 2
|
|
},
|
|
{
|
|
"kind": "Space",
|
|
"value": 2
|
|
}
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "PatternBindingList",
|
|
"layout": [
|
|
{
|
|
"kind": "PatternBinding",
|
|
"layout": [
|
|
{
|
|
"kind": "IdentifierPattern",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "identifier",
|
|
"text": "baz"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "TypeAnnotation",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "colon"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "SimpleTypeIdentifier",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "identifier",
|
|
"text": "Array"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "GenericArgumentClause",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "l_angle"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "GenericArgumentList",
|
|
"layout": [
|
|
{
|
|
"kind": "GenericArgument",
|
|
"layout": [
|
|
{
|
|
"kind": "SimpleTypeIdentifier",
|
|
"layout": [
|
|
{
|
|
"tokenKind": {
|
|
"kind": "identifier",
|
|
"text": "Int"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
{
|
|
"kind": "Space",
|
|
"value": 1
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "GenericArgumentClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "comma"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "r_angle"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"kind": "InitializerClause",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"kind": "AccessorBlock",
|
|
"layout": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "comma"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "r_brace"
|
|
},
|
|
"leadingTrivia": [
|
|
{
|
|
"kind": "Newline",
|
|
"value": 1
|
|
},
|
|
{
|
|
"kind": "Space",
|
|
"value": 6
|
|
}
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "semi"
|
|
},
|
|
"leadingTrivia": [
|
|
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Missing"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
},
|
|
{
|
|
"tokenKind": {
|
|
"kind": "eof"
|
|
},
|
|
"leadingTrivia": [
|
|
{
|
|
"kind": "Newline",
|
|
"value": 1
|
|
}
|
|
],
|
|
"trailingTrivia": [
|
|
|
|
],
|
|
"presence": "Present"
|
|
}
|
|
],
|
|
"presence": "Present"
|
|
}
|