Use more specific node kinds for literals. (#3419)

Sounding out the approach, to make it clearer what a literal node
corresponds to.
This commit is contained in:
Jon Ross-Perkins
2023-11-22 01:27:28 +00:00
committed by GitHub
parent f1ddded3a1
commit a204689893
107 changed files with 463 additions and 383 deletions
@@ -17,7 +17,7 @@ var x: {.a: i32,,} = {};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ',', has_error: yes},
@@ -17,7 +17,7 @@ var x: {.a = 0,,} = {};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ',', has_error: yes},
@@ -17,12 +17,12 @@ var x: {."hello": i32, .y: i32} = {};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: '"hello"', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ':', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'y'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 13},
@@ -17,12 +17,12 @@ var x: {."hello" = 0, .y = 4} = {};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: '"hello"', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: '=', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'y'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '4'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 13},
@@ -17,7 +17,7 @@ var x: {.a: i32 banana} = {.a = 0};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 8},
@@ -25,7 +25,7 @@ var x: {.a: i32 banana} = {.a = 0};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
@@ -17,7 +17,7 @@ var x: {.a: i32} = {.a = 0 banana};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 8},
@@ -25,7 +25,7 @@ var x: {.a: i32} = {.a = 0 banana};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
@@ -17,7 +17,7 @@ var x: {.a: i32, .b = 0} = {};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'b'},
@@ -17,7 +17,7 @@ var x: {.a = 0, b: i32} = {};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: 'b', has_error: yes},
@@ -25,13 +25,13 @@ var x: i32 = {.a: i32, .b, .c = 1};
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'Name', text: 'x'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '1'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '1'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'b'},
@@ -45,13 +45,13 @@ var x: i32 = {.a: i32, .b, .c = 1};
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 20},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'Name', text: 'x'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'b'},
+2 -2
View File
@@ -14,7 +14,7 @@ var z: {.n: i32} = {.n = 4};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 8},
@@ -22,7 +22,7 @@ var z: {.n: i32} = {.n = 4};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '4'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 17},
@@ -14,7 +14,7 @@ var z: {.n: i32,} = {.n = 4,};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7},
@@ -23,7 +23,7 @@ var z: {.n: i32,} = {.n = 4,};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '4'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 7},
+4 -4
View File
@@ -14,12 +14,12 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'IntegerTypeLiteral', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 13},
@@ -27,12 +27,12 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'Name', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '1'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '1'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'Name', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '2'},
// CHECK:STDOUT: {kind: 'IntegerLiteral', text: '2'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 27},