Move parse tree tests to files. (#2437)

I think it'd be helpful to examine what the parse tree looks like in failure cases.

Note, I'm not sure that the behavior of the recovery situations is correct; the test had been asserting that the parse tree should indicate it's error free. However, this means that the only signal the the driver that the input is invalid is that the diagnostic emitter was used. I think it may be important to have it return a non-zero error to prevent compile, or we can turn these into warnings but then "requiring a space" is wrong.

Either way, that's a concern I have with the pre-existing recovery behavior: I'm just trying to highlight it as I make this change, because now the test is really that nodes aren't tagged with has_error.
This commit is contained in:
Jon Ross-Perkins
2022-12-05 08:30:53 -08:00
committed by GitHub
parent 814ae3d419
commit 991dadcbed
60 changed files with 1130 additions and 214 deletions
-35
View File
@@ -1,35 +0,0 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageApi', text: 'api'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 4},
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageImpl', text: 'impl'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 4},
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'Literal', text: '"Shapes"'},
// CHECK:STDOUT: {kind: 'PackageLibrary', text: 'library', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PackageApi', text: 'api'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 6},
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'Literal', text: '"Shapes"'},
// CHECK:STDOUT: {kind: 'PackageLibrary', text: 'library', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PackageImpl', text: 'impl'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 6},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// NOTE: Move to its own directory when more tests are added.
package Geometry api;
package Geometry impl;
package Geometry library "Shapes" api;
package Geometry library "Shapes" impl;
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', has_error: yes, subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// TODO: We could figure out that this first Failed example is infix
// with one-token lookahead.
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_infix_uneven_space_after.carbon:[[@LINE+1]]:16: Expected `;` after expression.
var n: i8 = n* n;
@@ -21,6 +21,6 @@
// CHECK:STDOUT: ]
fn F() {
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_missing_precedence_and_or.carbon:[[@LINE+1]]:11: Parentheses are required to disambiguate operator precedence.
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_precedence_and_or.carbon:[[@LINE+1]]:11: Parentheses are required to disambiguate operator precedence.
a and b or c;
}
@@ -21,6 +21,6 @@
// CHECK:STDOUT: ]
fn F() {
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_missing_precedence_or_and.carbon:[[@LINE+1]]:10: Parentheses are required to disambiguate operator precedence.
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_precedence_or_and.carbon:[[@LINE+1]]:10: Parentheses are required to disambiguate operator precedence.
a or b and c;
}
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '-', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_precedence_star_minus.carbon:[[@LINE+1]]:16: Parentheses are required to disambiguate operator precedence.
var n: i8 = n* -n;
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'NameReference', text: 'p'},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '*', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_precedence_star_star.carbon:[[@LINE+1]]:16: Parentheses are required to disambiguate operator precedence.
var n: i8 = n* *p;
@@ -0,0 +1,25 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', has_error: yes, subtree_size: 9},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// TODO: We try to form (n*)*p and reject due to missing parentheses
// before we notice the missing whitespace around the second `*`.
// It'd be better to (somehow) form n*(*p) and reject due to the missing
// whitespace around the first `*`.
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/fail_star_star_no_space.carbon:[[@LINE+1]]:16: Expected `;` after expression.
var n: i8 = n**p;
+20
View File
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '*', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 9},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var n: i8 = n * n;
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '*', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 9},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var n: i8 = n*n;
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Literal', text: '3'},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'ParenExpression', text: ')', subtree_size: 3},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '*', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 11},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var n: i8 = 3*(n);
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'ParenExpression', text: ')', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Literal', text: '3'},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '*', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 11},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var n: i8 = (n)*3;
+19
View File
@@ -0,0 +1,19 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'v'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'Type'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var v: Type = i8*;
@@ -0,0 +1,19 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'v'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'Type'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var v: Type = i8* ;
+19
View File
@@ -0,0 +1,19 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: '-', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var n: i8 = -n;
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: '-', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var n: i8 =-n;
// Valid
@@ -0,0 +1,21 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'InfixOperator', text: '*', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 9},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_infix_uneven_space_before.carbon:[[@LINE+1]]:15: Whitespace missing after binary operator.
var n: i8 = n *n;
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'v'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'Type'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_postfix_space.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator.
var v: Type = i8 *;
@@ -0,0 +1,25 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'F'},
// CHECK:STDOUT: {kind: 'CallExpressionStart', text: '(', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'CallExpressionComma', text: ','},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'CallExpression', text: ')', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 13},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_postfix_space_before_comma.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator.
var n: i8 = F(i8 *, 0);
@@ -0,0 +1,23 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'F'},
// CHECK:STDOUT: {kind: 'CallExpressionStart', text: '(', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'CallExpression', text: ')', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 11},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_postfix_space_in_call.carbon:[[@LINE+1]]:18: Whitespace is not allowed before this unary operator.
var n: i8 = F(i8 *);
@@ -0,0 +1,21 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'v'},
// CHECK:STDOUT: {kind: 'NameReference', text: 'Type'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PostfixOperator', text: '*', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_postfix_space_surrounding.carbon:[[@LINE+2]]:18: Whitespace is not allowed before this unary operator.
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_postfix_space_surrounding.carbon:[[@LINE+1]]:18: Whitespace is required after this unary operator.
var v: Type = i8 * ;
@@ -0,0 +1,21 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: '-', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_prefix_space.carbon:[[@LINE+2]]:13: Whitespace is not allowed after this unary operator.
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_prefix_space.carbon:[[@LINE+1]]:13: Whitespace is required before this unary operator.
var n: i8 = - n;
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'n'},
// CHECK:STDOUT: {kind: 'Literal', text: 'i8'},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NameReference', text: 'n'},
// CHECK:STDOUT: {kind: 'PrefixOperator', text: '-', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/operators/recover_prefix_uneven_space_with_assign.carbon:[[@LINE+1]]:12: Whitespace is not allowed after this unary operator.
var n: i8 =- n;
+15
View File
@@ -0,0 +1,15 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageApi', text: 'api'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 4},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
package Geometry api;
+17
View File
@@ -0,0 +1,17 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'Literal', text: '"Shapes"'},
// CHECK:STDOUT: {kind: 'PackageLibrary', text: 'library', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PackageApi', text: 'api'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 6},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
package Geometry library "Shapes" api;
@@ -0,0 +1,17 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Foo'},
// CHECK:STDOUT: {kind: 'Literal', text: '"bar"'},
// CHECK:STDOUT: {kind: 'PackageLibrary', text: 'library', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 5},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_extra_string.carbon:[[@LINE+1]]:27: Expected a `api` or `impl`.
package Foo library "bar" "baz";
@@ -0,0 +1,15 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_library_is_identifier.carbon:[[@LINE+1]]:26: Expected a string literal to specify the library name.
package Geometry library Shapes api;
@@ -0,0 +1,14 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 2},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_library_skips_name.carbon:[[@LINE+1]]:9: Expected identifier after `package`.
package library "Shapes" api;
@@ -0,0 +1,14 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 2},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_name_is_keyword.carbon:[[@LINE+1]]:9: Expected identifier after `package`.
package fn;
+14
View File
@@ -0,0 +1,14 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 2},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_no_name.carbon:[[@LINE+1]]:8: Expected identifier after `package`.
package;
+16
View File
@@ -0,0 +1,16 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageApi', text: 'api'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: 'package', has_error: yes, subtree_size: 4},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_no_semi.carbon:[[@LINE+1]]:21: Expected `;` to end package directive.
package Geometry api
+15
View File
@@ -0,0 +1,15 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_no_type.carbon:[[@LINE+1]]:17: Expected a `api` or `impl`.
package Geometry;
@@ -0,0 +1,15 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 3},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/package/fail_omit_library_keyword.carbon:[[@LINE+1]]:18: Missing `library` keyword.
package Geometry "Shapes" api;
+15
View File
@@ -0,0 +1,15 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'PackageImpl', text: 'impl'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 4},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
package Geometry impl;
+17
View File
@@ -0,0 +1,17 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'Geometry'},
// CHECK:STDOUT: {kind: 'Literal', text: '"Shapes"'},
// CHECK:STDOUT: {kind: 'PackageLibrary', text: 'library', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PackageImpl', text: 'impl'},
// CHECK:STDOUT: {kind: 'PackageDirective', text: ';', subtree_size: 6},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
package Geometry library "Shapes" impl;
+23
View File
@@ -0,0 +1,23 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 4},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 6},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 11},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_comma_only.carbon:[[@LINE+1]]:9: Expected `.field: type` or `.field = value`.
var x: {,} = {};
@@ -0,0 +1,28 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 9},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 11},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 16},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_comma_repeat_in_type.carbon:[[@LINE+1]]:17: Expected `.field: type`.
var x: {.a: i32,,} = {};
@@ -0,0 +1,28 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ',', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 9},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 11},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 16},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_comma_repeat_in_value.carbon:[[@LINE+1]]:16: Expected `.field = value`.
var x: {.a = 0,,} = {};
+24
View File
@@ -0,0 +1,24 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: '}', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: '.', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 12},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_dot_only.carbon:[[@LINE+1]]:10: Expected identifier after `.`.
var x: {.} = {};
@@ -0,0 +1,30 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: '"hello"', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ':', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', 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},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 18},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_dot_string_colon.carbon:[[@LINE+1]]:10: Expected identifier after `.`.
var x: {."hello": i32, .y: i32} = {};
@@ -0,0 +1,30 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: '"hello"', has_error: yes},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: '=', has_error: yes},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', 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},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 18},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_dot_string_equals.carbon:[[@LINE+1]]:10: Expected identifier after `.`.
var x: {."hello" = 0, .y = 4} = {};
@@ -0,0 +1,29 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', 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},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_extra_token_in_type.carbon:[[@LINE+1]]:17: Expected `,` or `}`.
var x: {.a: i32 banana} = {.a = 0};
@@ -0,0 +1,29 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', 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},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', has_error: yes, subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_extra_token_in_value.carbon:[[@LINE+1]]:28: Expected `,` or `}`.
var x: {.a: i32} = {.a = 0 banana};
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: 'a', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 3},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_identifier_colon.carbon:[[@LINE+1]]:9: Expected `.field: type` or `.field = value`.
var x: {a:} = {};
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: 'a', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 3},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_identifier_equals.carbon:[[@LINE+1]]:9: Expected `.field: type` or `.field = value`.
var x: {a=} = {};
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: 'a', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 3},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_identifier_only.carbon:[[@LINE+1]]:9: Expected `.field: type` or `.field = value`.
var x: {a} = {};
@@ -0,0 +1,24 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: ':', has_error: yes},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 12},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_missing_type.carbon:[[@LINE+1]]:12: Expected expression.
var x: {.a:} = {};
@@ -0,0 +1,24 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: '=', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 12},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_missing_value.carbon:[[@LINE+1]]:12: Expected expression.
var x: {.a=} = {};
@@ -0,0 +1,29 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'b'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: '.', has_error: yes},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 10},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 12},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_mix_type_and_value.carbon:[[@LINE+1]]:21: Expected `.field: type`.
var x: {.a: i32, .b = 0} = {};
@@ -0,0 +1,27 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '0'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: 'b', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 8},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 10},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 15},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_mix_value_and_type.carbon:[[@LINE+1]]:17: Expected `.field = value`.
var x: {.a = 0, b: i32} = {};
@@ -0,0 +1,24 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'a'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: '.', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 12},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_no_colon_or_equals.carbon:[[@LINE+1]]:11: Expected `.field: type` or `.field = value`.
var x: {.a} = {};
@@ -0,0 +1,22 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{not} %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructFieldUnknown', text: 'i32', has_error: yes},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 3},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 5},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 10},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// CHECK:STDERR: {{.*}}/toolchain/parser/testdata/struct/fail_type_no_designator.carbon:[[@LINE+1]]:9: Expected `.field: type` or `.field = value`.
var x: {i32} = {};
+20
View File
@@ -0,0 +1,20 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 9},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var y: {} = {};
@@ -0,0 +1,28 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'z'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', 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},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 17},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var z: {.n: i32} = {.n = 4};
@@ -0,0 +1,30 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'z'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 9},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 19},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var z: {.n: i32,} = {.n = 4,};
@@ -32,38 +32,7 @@
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 11},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 12},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 27},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'y'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 2},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 3},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 9},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'z'},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'StructFieldType', text: ':', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructTypeLiteral', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 9},
// CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'},
// CHECK:STDOUT: {kind: 'DesignatedName', text: 'n'},
// CHECK:STDOUT: {kind: 'StructFieldDesignator', text: '.', subtree_size: 2},
// CHECK:STDOUT: {kind: 'Literal', text: '4'},
// CHECK:STDOUT: {kind: 'StructFieldValue', text: '=', subtree_size: 4},
// CHECK:STDOUT: {kind: 'StructComma', text: ','},
// CHECK:STDOUT: {kind: 'StructLiteral', text: '}', subtree_size: 7},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 8},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 19},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// NOTE: Move to its own directory when more tests are added.
var x: {.a: i32, .b: i32} = {.a = 1, .b = 2};
var y: {} = {};
var z: {.n: i32,} = {.n = 4,};
@@ -6,21 +6,6 @@
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'Literal', text: '1'},
// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','},
// CHECK:STDOUT: {kind: 'Literal', text: '2'},
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 15},
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'y'},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
@@ -37,6 +22,4 @@
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
// NOTE: Move to its own directory when more tests are added.
var x: (i32, i32) = (1, 2);
var y: ((), (), ());
+26
View File
@@ -0,0 +1,26 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-parser}
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
// CHECK:STDOUT: {kind: 'DeclaredName', text: 'x'},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','},
// CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5},
// CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 7},
// CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('},
// CHECK:STDOUT: {kind: 'Literal', text: '1'},
// CHECK:STDOUT: {kind: 'TupleLiteralComma', text: ','},
// CHECK:STDOUT: {kind: 'Literal', text: '2'},
// CHECK:STDOUT: {kind: 'TupleLiteral', text: ')', subtree_size: 5},
// CHECK:STDOUT: {kind: 'VariableInitializer', text: '=', subtree_size: 6},
// CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 15},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
var x: (i32, i32) = (1, 2);