From a46ca6bf7a731f4ff98647c6f132182837d7b787 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 4 Oct 2023 16:36:35 -0700 Subject: [PATCH] Add a start-of-file token and parse node. (#3263) This removes a (very) hot branch in the lexer where we need to special case when a token is the first token and can't look at its previous token. It also seems like a generally nice change to the structure of both the token buffer and parse tree as there are now bracketing elements for both ends and we should be able to avoid similar branching in the future. Mostly mechanical updates to the lexer and parser code to handle this, but also needed to special case the location information in the autoupdate code. And then the usual large body of auto-updated tests. No benchmark data for this change alone as in isolation and in the current lexer structure it doesn't make a big difference. But this branch was particularly difficult to handle when trying to update the whitespace skipping code to be faster, and so I think it is worth systematically avoiding the special case here. --- toolchain/check/handle_noop.cpp | 5 + toolchain/lex/testdata/basic_syntax.carbon | 25 ++-- .../fail_block_string_second_line.carbon | 15 ++- toolchain/lex/testdata/fail_multifile.carbon | 10 +- toolchain/lex/testdata/keywords.carbon | 127 +++++++++--------- toolchain/lex/testdata/multifile.carbon | 14 +- .../lex/testdata/numeric_literals.carbon | 111 +++++++-------- .../testdata/printing_digit_padding.carbon | 11 +- .../testdata/printing_integer_literal.carbon | 5 +- .../lex/testdata/printing_real_literal.carbon | 5 +- toolchain/lex/testdata/printing_token.carbon | 5 +- toolchain/lex/token_kind.def | 1 + toolchain/lex/tokenized_buffer.cpp | 20 ++- toolchain/lex/tokenized_buffer_test.cpp | 102 +++++++++----- toolchain/parse/node_kind.def | 3 + .../array/fail_require_close_bracket.carbon | 3 +- .../testdata/array/fail_require_semi.carbon | 1 + .../parse/testdata/array/with_length.carbon | 1 + .../testdata/array/without_length.carbon | 1 + .../testdata/basics/builtin_types.carbon | 1 + toolchain/parse/testdata/basics/empty.carbon | 1 + .../testdata/basics/empty_declaration.carbon | 1 + .../basics/fail_invalid_designators.carbon | 1 + .../basics/fail_no_intro_with_semi.carbon | 1 + .../basics/fail_no_intro_without_semi.carbon | 1 + .../basics/fail_paren_match_regression.carbon | 3 +- .../testdata/basics/function_call.carbon | 1 + .../parse/testdata/basics/multifile.carbon | 2 + .../testdata/basics/numeric_literals.carbon | 1 + toolchain/parse/testdata/basics/parens.carbon | 1 + toolchain/parse/testdata/class/basic.carbon | 1 + .../testdata/class/fn_definitions.carbon | 1 + toolchain/parse/testdata/class/var.carbon | 1 + .../for/fail_colon_instead_of_in.carbon | 1 + .../testdata/for/fail_missing_cond.carbon | 1 + .../parse/testdata/for/fail_missing_in.carbon | 1 + .../testdata/for/fail_missing_var.carbon | 1 + .../testdata/for/fail_square_brackets.carbon | 1 + toolchain/parse/testdata/for/nested.carbon | 1 + toolchain/parse/testdata/for/simple.carbon | 1 + .../testdata/function/declaration/addr.carbon | 1 + .../function/declaration/basic.carbon | 1 + .../function/declaration/deduced_empty.carbon | 1 + .../declaration/deduced_params.carbon | 1 + .../fail_identifier_instead_of_sig.carbon | 1 + .../fail_missing_deduced_close.carbon | 3 +- .../declaration/fail_missing_name.carbon | 1 + .../declaration/fail_no_sig_or_semi.carbon | 3 +- .../declaration/fail_only_fn_and_semi.carbon | 1 + .../fail_repeated_fn_and_semi.carbon | 1 + ...skip_indented_newline_until_outdent.carbon | 1 + ...ail_skip_indented_newline_with_semi.carbon | 1 + ..._skip_indented_newline_without_semi.carbon | 1 + .../fail_skip_to_newline_without_semi.carbon | 1 + .../fail_skip_without_semi_to_curly.carbon | 1 + .../fail_with_identifier_as_param.carbon | 1 + ...hout_name_and_many_tokens_in_params.carbon | 1 + .../function/declaration/params.carbon | 1 + .../declaration/with_return_type.carbon | 1 + .../testdata/function/definition/basic.carbon | 1 + .../fail_identifier_in_statements.carbon | 1 + .../function/definition/with_params.carbon | 1 + .../definition/with_return_type.carbon | 1 + .../generics/deduced_params/empty.carbon | 1 + .../deduced_params/fail_no_parens.carbon | 1 + .../generics/deduced_params/one.carbon | 1 + .../deduced_params/one_suffix_comma.carbon | 1 + .../generics/deduced_params/six.carbon | 1 + .../generics/deduced_params/two.carbon | 1 + .../deduced_params/two_suffix_comma.carbon | 1 + .../generics/generic_params/basic.carbon | 1 + .../generics/generic_params/template.carbon | 1 + .../generic_params/template_addr.carbon | 1 + .../testdata/generics/interface/basic.carbon | 1 + .../generics/interface/declaration.carbon | 1 + .../generics/interface/empty_body.carbon | 1 + .../interface/fail_missing_name.carbon | 1 + .../interface/fail_missing_open_curly.carbon | 3 +- .../interface/fail_no_impl_allowed.carbon | 1 + .../interface/fail_self_param_syntax.carbon | 1 + .../generics/interface/non_instance_fn.carbon | 1 + .../generics/interface/self_pointer.carbon | 1 + .../generics/named_constraint/basic.carbon | 1 + .../fail_no_impl_allowed.carbon | 1 + .../testdata/generics/params/empty.carbon | 1 + .../parse/testdata/generics/params/one.carbon | 1 + .../generics/params/one_suffix_comma.carbon | 1 + .../parse/testdata/generics/params/six.carbon | 1 + .../parse/testdata/generics/params/two.carbon | 1 + .../generics/params/two_suffix_comma.carbon | 1 + toolchain/parse/testdata/if/basic.carbon | 1 + toolchain/parse/testdata/if/else.carbon | 1 + .../testdata/if/fail_else_unbraced.carbon | 1 + .../parse/testdata/if/fail_errors.carbon | 1 + .../testdata/if/fail_missing_cond.carbon | 1 + .../testdata/if/fail_square_brackets.carbon | 1 + .../parse/testdata/if/fail_unbraced.carbon | 1 + .../parse/testdata/if_expression/basic.carbon | 1 + .../fail_condition_missing.carbon | 1 + .../fail_else_expr_missing.carbon | 1 + .../if_expression/fail_else_missing.carbon | 1 + .../fail_then_expr_missing.carbon | 1 + .../if_expression/fail_then_missing.carbon | 1 + .../if_expression/fail_top_level_if.carbon | 1 + .../testdata/if_expression/in_type.carbon | 1 + .../testdata/if_expression/precedence.carbon | 1 + .../parse/testdata/index/assign_to_var.carbon | 1 + .../testdata/index/fail_empty_expr.carbon | 1 + .../testdata/index/fail_malformed_expr.carbon | 1 + .../parse/testdata/namespace/basic.carbon | 1 + .../parse/testdata/namespace/fail_args.carbon | 1 + .../testdata/namespace/fail_arrow.carbon | 1 + .../namespace/fail_incomplete_name.carbon | 1 + .../testdata/namespace/fail_no_name.carbon | 1 + .../parse/testdata/namespace/nested.carbon | 1 + .../parse/testdata/operators/assign.carbon | 1 + .../testdata/operators/associative.carbon | 1 + .../operators/fail_chained_assign.carbon | 1 + .../fail_infix_uneven_space_after.carbon | 1 + .../operators/fail_invalid_infix.carbon | 1 + .../operators/fail_postincrement.carbon | 1 + .../operators/fail_precedence_and_or.carbon | 1 + .../operators/fail_precedence_as.carbon | 1 + .../operators/fail_precedence_assign.carbon | 1 + .../operators/fail_precedence_or_and.carbon | 1 + .../fail_precedence_star_minus.carbon | 1 + .../fail_precedence_star_star.carbon | 1 + .../operators/fail_star_star_no_space.carbon | 1 + .../testdata/operators/fail_variety.carbon | 1 + .../testdata/operators/fixity_in_call.carbon | 1 + .../operators/fixity_in_params.carbon | 1 + .../testdata/operators/fixity_in_var.carbon | 1 + .../operators/fixity_with_assign.carbon | 1 + .../parse/testdata/operators/infix.carbon | 1 + .../testdata/operators/infix_no_space.carbon | 1 + .../operators/infix_with_paren_after.carbon | 1 + .../operators/infix_with_paren_before.carbon | 1 + .../parse/testdata/operators/postfix.carbon | 1 + .../testdata/operators/postfix_repeat.carbon | 1 + .../operators/postfix_space_after_op.carbon | 1 + .../testdata/operators/precedence_as.carbon | 1 + .../operators/precedence_assign.carbon | 1 + .../testdata/operators/precedence_not.carbon | 1 + .../operators/precedence_unary.carbon | 1 + .../parse/testdata/operators/prefix.carbon | 1 + .../testdata/operators/prefix_no_space.carbon | 1 + .../testdata/operators/prefix_repeat.carbon | 1 + .../recover_infix_uneven_space_before.carbon | 1 + .../operators/recover_postfix_space.carbon | 1 + .../recover_postfix_space_before_comma.carbon | 1 + .../recover_postfix_space_in_call.carbon | 1 + .../recover_postfix_space_surrounding.carbon | 1 + .../operators/recover_prefix_repeat.carbon | 1 + .../operators/recover_prefix_space.carbon | 1 + ...ver_prefix_uneven_space_with_assign.carbon | 1 + toolchain/parse/testdata/package/api.carbon | 1 + .../parse/testdata/package/api_library.carbon | 1 + .../testdata/package/fail_extra_string.carbon | 1 + .../package/fail_library_is_identifier.carbon | 1 + .../package/fail_library_skips_name.carbon | 1 + .../package/fail_name_is_keyword.carbon | 1 + .../testdata/package/fail_no_name.carbon | 1 + .../testdata/package/fail_no_semi.carbon | 3 +- .../testdata/package/fail_no_type.carbon | 1 + .../package/fail_omit_library_keyword.carbon | 1 + toolchain/parse/testdata/package/impl.carbon | 1 + .../testdata/package/impl_library.carbon | 1 + .../testdata/pointer/const_pointer.carbon | 1 + .../fail_pointer_type_in_expression.carbon | 1 + .../testdata/pointer/pointer_type.carbon | 1 + .../testdata/pointer/pointer_value.carbon | 1 + toolchain/parse/testdata/return/basic.carbon | 1 + toolchain/parse/testdata/return/expr.carbon | 1 + .../testdata/return/fail_expr_no_semi.carbon | 1 + .../parse/testdata/return/fail_no_semi.carbon | 1 + .../testdata/struct/fail_comma_only.carbon | 1 + .../struct/fail_comma_repeat_in_type.carbon | 1 + .../struct/fail_comma_repeat_in_value.carbon | 1 + .../testdata/struct/fail_dot_only.carbon | 1 + .../struct/fail_dot_string_colon.carbon | 1 + .../struct/fail_dot_string_equals.carbon | 1 + .../struct/fail_extra_token_in_type.carbon | 1 + .../struct/fail_extra_token_in_value.carbon | 1 + .../struct/fail_identifier_colon.carbon | 1 + .../struct/fail_identifier_equals.carbon | 1 + .../struct/fail_identifier_only.carbon | 1 + .../testdata/struct/fail_missing_type.carbon | 1 + .../testdata/struct/fail_missing_value.carbon | 1 + .../struct/fail_mix_type_and_value.carbon | 1 + .../struct/fail_mix_value_and_type.carbon | 1 + .../struct/fail_mix_with_unknown.carbon | 1 + .../struct/fail_no_colon_or_equals.carbon | 1 + .../struct/fail_type_no_designator.carbon | 1 + .../parse/testdata/struct/no_entries.carbon | 1 + .../testdata/struct/one_entry_no_comma.carbon | 1 + .../struct/one_entry_with_comma.carbon | 1 + .../parse/testdata/struct/two_entries.carbon | 1 + toolchain/parse/testdata/tuple/nested.carbon | 1 + .../parse/testdata/tuple/two_entries.carbon | 1 + .../parse/testdata/var/fail_bad_name.carbon | 1 + .../parse/testdata/var/fail_empty.carbon | 1 + toolchain/parse/testdata/var/var.carbon | 1 + toolchain/parse/testdata/while/basic.carbon | 1 + .../parse/testdata/while/fail_no_semi.carbon | 1 + .../parse/testdata/while/fail_unbraced.carbon | 1 + toolchain/parse/tree.cpp | 3 + toolchain/parse/tree_test.cpp | 15 ++- toolchain/testing/file_test.cpp | 11 +- 208 files changed, 482 insertions(+), 209 deletions(-) diff --git a/toolchain/check/handle_noop.cpp b/toolchain/check/handle_noop.cpp index 536a10e21e0d..a7d323227015 100644 --- a/toolchain/check/handle_noop.cpp +++ b/toolchain/check/handle_noop.cpp @@ -12,6 +12,11 @@ auto HandleEmptyDeclaration(Context& /*context*/, Parse::Node /*parse_node*/) return true; } +auto HandleFileStart(Context& /*context*/, Parse::Node /*parse_node*/) -> bool { + // Do nothing, no need to balance this node. + return true; +} + auto HandleFileEnd(Context& /*context*/, Parse::Node /*parse_node*/) -> bool { // Do nothing, no need to balance this node. return true; diff --git a/toolchain/lex/testdata/basic_syntax.carbon b/toolchain/lex/testdata/basic_syntax.carbon index 8643fffd84bf..d77e5d5bbf07 100644 --- a/toolchain/lex/testdata/basic_syntax.carbon +++ b/toolchain/lex/testdata/basic_syntax.carbon @@ -5,21 +5,22 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: basic_syntax.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, fn run(String program) { -// CHECK:STDOUT: { index: 0, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 4, indent: 1, spelling: 'run', identifier: 0 }, -// CHECK:STDOUT: { index: 2, kind: 'OpenParen', line: {{ *}}[[@LINE-3]], column: 7, indent: 1, spelling: '(', closing_token: 5 }, -// CHECK:STDOUT: { index: 3, kind: 'StringTypeLiteral', line: {{ *}}[[@LINE-4]], column: 8, indent: 1, spelling: 'String', has_trailing_space: true }, -// CHECK:STDOUT: { index: 4, kind: 'Identifier', line: {{ *}}[[@LINE-5]], column: 15, indent: 1, spelling: 'program', identifier: 1 }, -// CHECK:STDOUT: { index: 5, kind: 'CloseParen', line: {{ *}}[[@LINE-6]], column: 22, indent: 1, spelling: ')', opening_token: 2, has_trailing_space: true }, -// CHECK:STDOUT: { index: 6, kind: 'OpenCurlyBrace', line: {{ *}}[[@LINE-7]], column: 24, indent: 1, spelling: '{', closing_token: 10, has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true }, +// CHECK:STDOUT: { index: 2, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 4, indent: 1, spelling: 'run', identifier: 0 }, +// CHECK:STDOUT: { index: 3, kind: 'OpenParen', line: {{ *}}[[@LINE-3]], column: 7, indent: 1, spelling: '(', closing_token: 6 }, +// CHECK:STDOUT: { index: 4, kind: 'StringTypeLiteral', line: {{ *}}[[@LINE-4]], column: 8, indent: 1, spelling: 'String', has_trailing_space: true }, +// CHECK:STDOUT: { index: 5, kind: 'Identifier', line: {{ *}}[[@LINE-5]], column: 15, indent: 1, spelling: 'program', identifier: 1 }, +// CHECK:STDOUT: { index: 6, kind: 'CloseParen', line: {{ *}}[[@LINE-6]], column: 22, indent: 1, spelling: ')', opening_token: 3, has_trailing_space: true }, +// CHECK:STDOUT: { index: 7, kind: 'OpenCurlyBrace', line: {{ *}}[[@LINE-7]], column: 24, indent: 1, spelling: '{', closing_token: 11, has_trailing_space: true }, return True; - // CHECK:STDOUT: { index: 7, kind: 'Return', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: 'return', has_trailing_space: true }, - // CHECK:STDOUT: { index: 8, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 10, indent: 3, spelling: 'True', identifier: 2 }, - // CHECK:STDOUT: { index: 9, kind: 'Semi', line: {{ *}}[[@LINE-3]], column: 14, indent: 3, spelling: ';', has_trailing_space: true }, + // CHECK:STDOUT: { index: 8, kind: 'Return', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: 'return', has_trailing_space: true }, + // CHECK:STDOUT: { index: 9, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 10, indent: 3, spelling: 'True', identifier: 2 }, + // CHECK:STDOUT: { index: 10, kind: 'Semi', line: {{ *}}[[@LINE-3]], column: 14, indent: 3, spelling: ';', has_trailing_space: true }, } -// CHECK:STDOUT: { index: 10, kind: 'CloseCurlyBrace', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '}', opening_token: 6, has_trailing_space: true }, +// CHECK:STDOUT: { index: 11, kind: 'CloseCurlyBrace', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '}', opening_token: 7, has_trailing_space: true }, -// CHECK:STDOUT: { index: 11, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 12, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/fail_block_string_second_line.carbon b/toolchain/lex/testdata/fail_block_string_second_line.carbon index 22cadfe7e6df..3f401b133aa7 100644 --- a/toolchain/lex/testdata/fail_block_string_second_line.carbon +++ b/toolchain/lex/testdata/fail_block_string_second_line.carbon @@ -12,13 +12,14 @@ // CHECK:STDERR: ^ var s: String = ''' error here: ''' -// CHECK:STDOUT: { index: 0, kind: 'Var', line: {{ *}}[[@LINE-2]], column: 1, indent: 1, spelling: 'var', has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'Identifier', line: {{ *}}[[@LINE-3]], column: 5, indent: 1, spelling: 's', identifier: 0 }, -// CHECK:STDOUT: { index: 2, kind: 'Colon', line: {{ *}}[[@LINE-4]], column: 6, indent: 1, spelling: ':', has_trailing_space: true }, -// CHECK:STDOUT: { index: 3, kind: 'StringTypeLiteral', line: {{ *}}[[@LINE-5]], column: 8, indent: 1, spelling: 'String', has_trailing_space: true }, -// CHECK:STDOUT: { index: 4, kind: 'Equal', line: {{ *}}[[@LINE-6]], column: 15, indent: 1, spelling: '=', has_trailing_space: true }, -// CHECK:STDOUT: { index: 5, kind: 'StringLiteral', line: {{ *}}[[@LINE-7]], column: 17, indent: 1, spelling: '''' +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: 1, column: 1, indent: 1, spelling: '', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Var', line: {{ *}}[[@LINE-3]], column: 1, indent: 1, spelling: 'var', has_trailing_space: true }, +// CHECK:STDOUT: { index: 2, kind: 'Identifier', line: {{ *}}[[@LINE-4]], column: 5, indent: 1, spelling: 's', identifier: 0 }, +// CHECK:STDOUT: { index: 3, kind: 'Colon', line: {{ *}}[[@LINE-5]], column: 6, indent: 1, spelling: ':', has_trailing_space: true }, +// CHECK:STDOUT: { index: 4, kind: 'StringTypeLiteral', line: {{ *}}[[@LINE-6]], column: 8, indent: 1, spelling: 'String', has_trailing_space: true }, +// CHECK:STDOUT: { index: 5, kind: 'Equal', line: {{ *}}[[@LINE-7]], column: 15, indent: 1, spelling: '=', has_trailing_space: true }, +// CHECK:STDOUT: { index: 6, kind: 'StringLiteral', line: {{ *}}[[@LINE-8]], column: 17, indent: 1, spelling: '''' // CHECK:STDOUT: error here: '''', value: `error here: `, has_trailing_space: true }, -// CHECK:STDOUT: { index: 6, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 7, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/fail_multifile.carbon b/toolchain/lex/testdata/fail_multifile.carbon index f7c71391170a..c8ef886ee5a2 100644 --- a/toolchain/lex/testdata/fail_multifile.carbon +++ b/toolchain/lex/testdata/fail_multifile.carbon @@ -7,22 +7,24 @@ // --- a.carbon // CHECK:STDOUT: - filename: a.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, // CHECK:STDERR: a.carbon:[[@LINE+3]]:3: ERROR: Empty digit sequence in numeric literal. // CHECK:STDERR: 1.a // CHECK:STDERR: ^ 1.a -// CHECK:STDOUT: { index: 0, kind: 'Error', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '1.a', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Error', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '1.a', has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] // --- b.carbon // CHECK:STDOUT: - filename: b.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, // CHECK:STDERR: b.carbon:[[@LINE+3]]:3: ERROR: Empty digit sequence in numeric literal. // CHECK:STDERR: 2.b // CHECK:STDERR: ^ 2.b -// CHECK:STDOUT: { index: 0, kind: 'Error', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '2.b', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Error', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '2.b', has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/keywords.carbon b/toolchain/lex/testdata/keywords.carbon index f12ec5ea8e57..b7be0e9f5e84 100644 --- a/toolchain/lex/testdata/keywords.carbon +++ b/toolchain/lex/testdata/keywords.carbon @@ -5,132 +5,133 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: keywords.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, abstract -// CHECK:STDOUT: { index: 0, kind: 'Abstract', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'abstract', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Abstract', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'abstract', has_trailing_space: true }, adapt -// CHECK:STDOUT: { index: 1, kind: 'Adapt', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'adapt', has_trailing_space: true }, +// CHECK:STDOUT: { index: 2, kind: 'Adapt', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'adapt', has_trailing_space: true }, addr -// CHECK:STDOUT: { index: 2, kind: 'Addr', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'addr', has_trailing_space: true }, +// CHECK:STDOUT: { index: 3, kind: 'Addr', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'addr', has_trailing_space: true }, alias -// CHECK:STDOUT: { index: 3, kind: 'Alias', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'alias', has_trailing_space: true }, +// CHECK:STDOUT: { index: 4, kind: 'Alias', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'alias', has_trailing_space: true }, and -// CHECK:STDOUT: { index: 4, kind: 'And', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'and', has_trailing_space: true }, +// CHECK:STDOUT: { index: 5, kind: 'And', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'and', has_trailing_space: true }, api -// CHECK:STDOUT: { index: 5, kind: 'Api', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'api', has_trailing_space: true }, +// CHECK:STDOUT: { index: 6, kind: 'Api', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'api', has_trailing_space: true }, as -// CHECK:STDOUT: { index: 6, kind: 'As', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'as', has_trailing_space: true }, +// CHECK:STDOUT: { index: 7, kind: 'As', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'as', has_trailing_space: true }, auto -// CHECK:STDOUT: { index: 7, kind: 'Auto', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'auto', has_trailing_space: true }, +// CHECK:STDOUT: { index: 8, kind: 'Auto', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'auto', has_trailing_space: true }, base -// CHECK:STDOUT: { index: 8, kind: 'Base', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'base', has_trailing_space: true }, +// CHECK:STDOUT: { index: 9, kind: 'Base', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'base', has_trailing_space: true }, bool -// CHECK:STDOUT: { index: 9, kind: 'Bool', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'bool', has_trailing_space: true }, +// CHECK:STDOUT: { index: 10, kind: 'Bool', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'bool', has_trailing_space: true }, break -// CHECK:STDOUT: { index: 10, kind: 'Break', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'break', has_trailing_space: true }, +// CHECK:STDOUT: { index: 11, kind: 'Break', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'break', has_trailing_space: true }, case -// CHECK:STDOUT: { index: 11, kind: 'Case', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'case', has_trailing_space: true }, +// CHECK:STDOUT: { index: 12, kind: 'Case', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'case', has_trailing_space: true }, choice -// CHECK:STDOUT: { index: 12, kind: 'Choice', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'choice', has_trailing_space: true }, +// CHECK:STDOUT: { index: 13, kind: 'Choice', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'choice', has_trailing_space: true }, class -// CHECK:STDOUT: { index: 13, kind: 'Class', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'class', has_trailing_space: true }, +// CHECK:STDOUT: { index: 14, kind: 'Class', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'class', has_trailing_space: true }, const -// CHECK:STDOUT: { index: 14, kind: 'Const', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'const', has_trailing_space: true }, +// CHECK:STDOUT: { index: 15, kind: 'Const', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'const', has_trailing_space: true }, constraint -// CHECK:STDOUT: { index: 15, kind: 'Constraint', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'constraint', has_trailing_space: true }, +// CHECK:STDOUT: { index: 16, kind: 'Constraint', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'constraint', has_trailing_space: true }, continue -// CHECK:STDOUT: { index: 16, kind: 'Continue', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'continue', has_trailing_space: true }, +// CHECK:STDOUT: { index: 17, kind: 'Continue', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'continue', has_trailing_space: true }, default -// CHECK:STDOUT: { index: 17, kind: 'Default', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'default', has_trailing_space: true }, +// CHECK:STDOUT: { index: 18, kind: 'Default', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'default', has_trailing_space: true }, destructor -// CHECK:STDOUT: { index: 18, kind: 'Destructor', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'destructor', has_trailing_space: true }, +// CHECK:STDOUT: { index: 19, kind: 'Destructor', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'destructor', has_trailing_space: true }, else -// CHECK:STDOUT: { index: 19, kind: 'Else', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'else', has_trailing_space: true }, +// CHECK:STDOUT: { index: 20, kind: 'Else', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'else', has_trailing_space: true }, extend -// CHECK:STDOUT: { index: 20, kind: 'Extend', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'extend', has_trailing_space: true }, +// CHECK:STDOUT: { index: 21, kind: 'Extend', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'extend', has_trailing_space: true }, false -// CHECK:STDOUT: { index: 21, kind: 'False', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'false', has_trailing_space: true }, +// CHECK:STDOUT: { index: 22, kind: 'False', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'false', has_trailing_space: true }, final -// CHECK:STDOUT: { index: 22, kind: 'Final', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'final', has_trailing_space: true }, +// CHECK:STDOUT: { index: 23, kind: 'Final', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'final', has_trailing_space: true }, fn -// CHECK:STDOUT: { index: 23, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true }, +// CHECK:STDOUT: { index: 24, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true }, for -// CHECK:STDOUT: { index: 24, kind: 'For', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'for', has_trailing_space: true }, +// CHECK:STDOUT: { index: 25, kind: 'For', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'for', has_trailing_space: true }, forall -// CHECK:STDOUT: { index: 25, kind: 'Forall', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'forall', has_trailing_space: true }, +// CHECK:STDOUT: { index: 26, kind: 'Forall', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'forall', has_trailing_space: true }, friend -// CHECK:STDOUT: { index: 26, kind: 'Friend', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'friend', has_trailing_space: true }, +// CHECK:STDOUT: { index: 27, kind: 'Friend', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'friend', has_trailing_space: true }, if -// CHECK:STDOUT: { index: 27, kind: 'If', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'if', has_trailing_space: true }, +// CHECK:STDOUT: { index: 28, kind: 'If', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'if', has_trailing_space: true }, impl -// CHECK:STDOUT: { index: 28, kind: 'Impl', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'impl', has_trailing_space: true }, +// CHECK:STDOUT: { index: 29, kind: 'Impl', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'impl', has_trailing_space: true }, impls -// CHECK:STDOUT: { index: 29, kind: 'Impls', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'impls', has_trailing_space: true }, +// CHECK:STDOUT: { index: 30, kind: 'Impls', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'impls', has_trailing_space: true }, import -// CHECK:STDOUT: { index: 30, kind: 'Import', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'import', has_trailing_space: true }, +// CHECK:STDOUT: { index: 31, kind: 'Import', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'import', has_trailing_space: true }, in -// CHECK:STDOUT: { index: 31, kind: 'In', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'in', has_trailing_space: true }, +// CHECK:STDOUT: { index: 32, kind: 'In', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'in', has_trailing_space: true }, interface -// CHECK:STDOUT: { index: 32, kind: 'Interface', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'interface', has_trailing_space: true }, +// CHECK:STDOUT: { index: 33, kind: 'Interface', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'interface', has_trailing_space: true }, let -// CHECK:STDOUT: { index: 33, kind: 'Let', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'let', has_trailing_space: true }, +// CHECK:STDOUT: { index: 34, kind: 'Let', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'let', has_trailing_space: true }, library -// CHECK:STDOUT: { index: 34, kind: 'Library', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'library', has_trailing_space: true }, +// CHECK:STDOUT: { index: 35, kind: 'Library', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'library', has_trailing_space: true }, like -// CHECK:STDOUT: { index: 35, kind: 'Like', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'like', has_trailing_space: true }, +// CHECK:STDOUT: { index: 36, kind: 'Like', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'like', has_trailing_space: true }, match -// CHECK:STDOUT: { index: 36, kind: 'Match', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'match', has_trailing_space: true }, +// CHECK:STDOUT: { index: 37, kind: 'Match', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'match', has_trailing_space: true }, namespace -// CHECK:STDOUT: { index: 37, kind: 'Namespace', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'namespace', has_trailing_space: true }, +// CHECK:STDOUT: { index: 38, kind: 'Namespace', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'namespace', has_trailing_space: true }, not -// CHECK:STDOUT: { index: 38, kind: 'Not', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'not', has_trailing_space: true }, +// CHECK:STDOUT: { index: 39, kind: 'Not', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'not', has_trailing_space: true }, observe -// CHECK:STDOUT: { index: 39, kind: 'Observe', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'observe', has_trailing_space: true }, +// CHECK:STDOUT: { index: 40, kind: 'Observe', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'observe', has_trailing_space: true }, or -// CHECK:STDOUT: { index: 40, kind: 'Or', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'or', has_trailing_space: true }, +// CHECK:STDOUT: { index: 41, kind: 'Or', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'or', has_trailing_space: true }, override -// CHECK:STDOUT: { index: 41, kind: 'Override', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'override', has_trailing_space: true }, +// CHECK:STDOUT: { index: 42, kind: 'Override', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'override', has_trailing_space: true }, package -// CHECK:STDOUT: { index: 42, kind: 'Package', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'package', has_trailing_space: true }, +// CHECK:STDOUT: { index: 43, kind: 'Package', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'package', has_trailing_space: true }, partial -// CHECK:STDOUT: { index: 43, kind: 'Partial', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'partial', has_trailing_space: true }, +// CHECK:STDOUT: { index: 44, kind: 'Partial', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'partial', has_trailing_space: true }, private -// CHECK:STDOUT: { index: 44, kind: 'Private', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'private', has_trailing_space: true }, +// CHECK:STDOUT: { index: 45, kind: 'Private', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'private', has_trailing_space: true }, protected -// CHECK:STDOUT: { index: 45, kind: 'Protected', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'protected', has_trailing_space: true }, +// CHECK:STDOUT: { index: 46, kind: 'Protected', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'protected', has_trailing_space: true }, require -// CHECK:STDOUT: { index: 46, kind: 'Require', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'require', has_trailing_space: true }, +// CHECK:STDOUT: { index: 47, kind: 'Require', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'require', has_trailing_space: true }, return -// CHECK:STDOUT: { index: 47, kind: 'Return', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'return', has_trailing_space: true }, +// CHECK:STDOUT: { index: 48, kind: 'Return', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'return', has_trailing_space: true }, returned -// CHECK:STDOUT: { index: 48, kind: 'Returned', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'returned', has_trailing_space: true }, +// CHECK:STDOUT: { index: 49, kind: 'Returned', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'returned', has_trailing_space: true }, Self -// CHECK:STDOUT: { index: 49, kind: 'SelfTypeIdentifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'Self', has_trailing_space: true }, +// CHECK:STDOUT: { index: 50, kind: 'SelfTypeIdentifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'Self', has_trailing_space: true }, self -// CHECK:STDOUT: { index: 50, kind: 'SelfValueIdentifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'self', has_trailing_space: true }, +// CHECK:STDOUT: { index: 51, kind: 'SelfValueIdentifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'self', has_trailing_space: true }, String -// CHECK:STDOUT: { index: 51, kind: 'StringTypeLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'String', has_trailing_space: true }, +// CHECK:STDOUT: { index: 52, kind: 'StringTypeLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'String', has_trailing_space: true }, template -// CHECK:STDOUT: { index: 52, kind: 'Template', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'template', has_trailing_space: true }, +// CHECK:STDOUT: { index: 53, kind: 'Template', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'template', has_trailing_space: true }, then -// CHECK:STDOUT: { index: 53, kind: 'Then', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'then', has_trailing_space: true }, +// CHECK:STDOUT: { index: 54, kind: 'Then', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'then', has_trailing_space: true }, true -// CHECK:STDOUT: { index: 54, kind: 'True', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'true', has_trailing_space: true }, +// CHECK:STDOUT: { index: 55, kind: 'True', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'true', has_trailing_space: true }, type -// CHECK:STDOUT: { index: 55, kind: 'Type', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'type', has_trailing_space: true }, +// CHECK:STDOUT: { index: 56, kind: 'Type', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'type', has_trailing_space: true }, _ -// CHECK:STDOUT: { index: 56, kind: 'Underscore', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '_', has_trailing_space: true }, +// CHECK:STDOUT: { index: 57, kind: 'Underscore', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '_', has_trailing_space: true }, var -// CHECK:STDOUT: { index: 57, kind: 'Var', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'var', has_trailing_space: true }, +// CHECK:STDOUT: { index: 58, kind: 'Var', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'var', has_trailing_space: true }, virtual -// CHECK:STDOUT: { index: 58, kind: 'Virtual', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'virtual', has_trailing_space: true }, +// CHECK:STDOUT: { index: 59, kind: 'Virtual', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'virtual', has_trailing_space: true }, where -// CHECK:STDOUT: { index: 59, kind: 'Where', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'where', has_trailing_space: true }, +// CHECK:STDOUT: { index: 60, kind: 'Where', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'where', has_trailing_space: true }, while -// CHECK:STDOUT: { index: 60, kind: 'While', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'while', has_trailing_space: true }, +// CHECK:STDOUT: { index: 61, kind: 'While', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'while', has_trailing_space: true }, notakeyword -// CHECK:STDOUT: { index: 61, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'notakeyword', identifier: 0, has_trailing_space: true }, +// CHECK:STDOUT: { index: 62, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'notakeyword', identifier: 0, has_trailing_space: true }, -// CHECK:STDOUT: { index: 62, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 63, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/multifile.carbon b/toolchain/lex/testdata/multifile.carbon index bd4b9f522449..3557ebb4ea4b 100644 --- a/toolchain/lex/testdata/multifile.carbon +++ b/toolchain/lex/testdata/multifile.carbon @@ -7,18 +7,20 @@ // --- a.carbon // CHECK:STDOUT: - filename: a.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, a; -// CHECK:STDOUT: { index: 0, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'a', identifier: 0 }, -// CHECK:STDOUT: { index: 1, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 2, indent: 1, spelling: ';', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'a', identifier: 0 }, +// CHECK:STDOUT: { index: 2, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 2, indent: 1, spelling: ';', has_trailing_space: true }, -// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 3, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] // --- b.carbon // CHECK:STDOUT: - filename: b.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, b; -// CHECK:STDOUT: { index: 0, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'b', identifier: 0 }, -// CHECK:STDOUT: { index: 1, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 2, indent: 1, spelling: ';', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Identifier', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'b', identifier: 0 }, +// CHECK:STDOUT: { index: 2, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 2, indent: 1, spelling: ';', has_trailing_space: true }, -// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 3, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/numeric_literals.carbon b/toolchain/lex/testdata/numeric_literals.carbon index a8d567b6d702..e49e28d275c0 100644 --- a/toolchain/lex/testdata/numeric_literals.carbon +++ b/toolchain/lex/testdata/numeric_literals.carbon @@ -5,81 +5,82 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: numeric_literals.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, fn F() { -// CHECK:STDOUT: { index: 0, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 4, indent: 1, spelling: 'F', identifier: 0 }, -// CHECK:STDOUT: { index: 2, kind: 'OpenParen', line: {{ *}}[[@LINE-3]], column: 5, indent: 1, spelling: '(', closing_token: 3 }, -// CHECK:STDOUT: { index: 3, kind: 'CloseParen', line: {{ *}}[[@LINE-4]], column: 6, indent: 1, spelling: ')', opening_token: 2, has_trailing_space: true }, -// CHECK:STDOUT: { index: 4, kind: 'OpenCurlyBrace', line: {{ *}}[[@LINE-5]], column: 8, indent: 1, spelling: '{', closing_token: 53, has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Fn', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: 'fn', has_trailing_space: true }, +// CHECK:STDOUT: { index: 2, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 4, indent: 1, spelling: 'F', identifier: 0 }, +// CHECK:STDOUT: { index: 3, kind: 'OpenParen', line: {{ *}}[[@LINE-3]], column: 5, indent: 1, spelling: '(', closing_token: 4 }, +// CHECK:STDOUT: { index: 4, kind: 'CloseParen', line: {{ *}}[[@LINE-4]], column: 6, indent: 1, spelling: ')', opening_token: 3, has_trailing_space: true }, +// CHECK:STDOUT: { index: 5, kind: 'OpenCurlyBrace', line: {{ *}}[[@LINE-5]], column: 8, indent: 1, spelling: '{', closing_token: 54, has_trailing_space: true }, // 8 and 9 trigger special behavior in APInt when mishandling signed versus // unsigned, so we pay extra attention to those. var ints: [i32; 5] = ( - // CHECK:STDOUT: { index: 5, kind: 'Var', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: 'var', has_trailing_space: true }, - // CHECK:STDOUT: { index: 6, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: 'ints', identifier: 1 }, - // CHECK:STDOUT: { index: 7, kind: 'Colon', line: {{ *}}[[@LINE-3]], column: 11, indent: 3, spelling: ':', has_trailing_space: true }, - // CHECK:STDOUT: { index: 8, kind: 'OpenSquareBracket', line: {{ *}}[[@LINE-4]], column: 13, indent: 3, spelling: '[', closing_token: 12 }, - // CHECK:STDOUT: { index: 9, kind: 'IntegerTypeLiteral', line: {{ *}}[[@LINE-5]], column: 14, indent: 3, spelling: 'i32' }, - // CHECK:STDOUT: { index: 10, kind: 'Semi', line: {{ *}}[[@LINE-6]], column: 17, indent: 3, spelling: ';', has_trailing_space: true }, - // CHECK:STDOUT: { index: 11, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-7]], column: 19, indent: 3, spelling: '5', value: `5` }, - // CHECK:STDOUT: { index: 12, kind: 'CloseSquareBracket', line: {{ *}}[[@LINE-8]], column: 20, indent: 3, spelling: ']', opening_token: 8, has_trailing_space: true }, - // CHECK:STDOUT: { index: 13, kind: 'Equal', line: {{ *}}[[@LINE-9]], column: 22, indent: 3, spelling: '=', has_trailing_space: true }, - // CHECK:STDOUT: { index: 14, kind: 'OpenParen', line: {{ *}}[[@LINE-10]], column: 24, indent: 3, spelling: '(', closing_token: 25, has_trailing_space: true }, + // CHECK:STDOUT: { index: 6, kind: 'Var', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: 'var', has_trailing_space: true }, + // CHECK:STDOUT: { index: 7, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: 'ints', identifier: 1 }, + // CHECK:STDOUT: { index: 8, kind: 'Colon', line: {{ *}}[[@LINE-3]], column: 11, indent: 3, spelling: ':', has_trailing_space: true }, + // CHECK:STDOUT: { index: 9, kind: 'OpenSquareBracket', line: {{ *}}[[@LINE-4]], column: 13, indent: 3, spelling: '[', closing_token: 13 }, + // CHECK:STDOUT: { index: 10, kind: 'IntegerTypeLiteral', line: {{ *}}[[@LINE-5]], column: 14, indent: 3, spelling: 'i32' }, + // CHECK:STDOUT: { index: 11, kind: 'Semi', line: {{ *}}[[@LINE-6]], column: 17, indent: 3, spelling: ';', has_trailing_space: true }, + // CHECK:STDOUT: { index: 12, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-7]], column: 19, indent: 3, spelling: '5', value: `5` }, + // CHECK:STDOUT: { index: 13, kind: 'CloseSquareBracket', line: {{ *}}[[@LINE-8]], column: 20, indent: 3, spelling: ']', opening_token: 9, has_trailing_space: true }, + // CHECK:STDOUT: { index: 14, kind: 'Equal', line: {{ *}}[[@LINE-9]], column: 22, indent: 3, spelling: '=', has_trailing_space: true }, + // CHECK:STDOUT: { index: 15, kind: 'OpenParen', line: {{ *}}[[@LINE-10]], column: 24, indent: 3, spelling: '(', closing_token: 26, has_trailing_space: true }, 8, - // CHECK:STDOUT: { index: 15, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '8', value: `8` }, - // CHECK:STDOUT: { index: 16, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 16, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '8', value: `8` }, + // CHECK:STDOUT: { index: 17, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: ',', has_trailing_space: true }, 9, - // CHECK:STDOUT: { index: 17, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '9', value: `9` }, - // CHECK:STDOUT: { index: 18, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 18, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '9', value: `9` }, + // CHECK:STDOUT: { index: 19, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 6, indent: 5, spelling: ',', has_trailing_space: true }, 0x8, - // CHECK:STDOUT: { index: 19, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '0x8', value: `8` }, - // CHECK:STDOUT: { index: 20, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 20, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '0x8', value: `8` }, + // CHECK:STDOUT: { index: 21, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: ',', has_trailing_space: true }, 0b1000, - // CHECK:STDOUT: { index: 21, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '0b1000', value: `8` }, - // CHECK:STDOUT: { index: 22, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 22, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '0b1000', value: `8` }, + // CHECK:STDOUT: { index: 23, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: ',', has_trailing_space: true }, 39999999999999999993, - // CHECK:STDOUT: { index: 23, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '39999999999999999993', value: `39999999999999999993` }, - // CHECK:STDOUT: { index: 24, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 25, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 24, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '39999999999999999993', value: `39999999999999999993` }, + // CHECK:STDOUT: { index: 25, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 25, indent: 5, spelling: ',', has_trailing_space: true }, ); - // CHECK:STDOUT: { index: 25, kind: 'CloseParen', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ')', opening_token: 14 }, - // CHECK:STDOUT: { index: 26, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ';', has_trailing_space: true }, + // CHECK:STDOUT: { index: 26, kind: 'CloseParen', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ')', opening_token: 15 }, + // CHECK:STDOUT: { index: 27, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ';', has_trailing_space: true }, var floats: [f64; 7] = ( - // CHECK:STDOUT: { index: 27, kind: 'Var', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: 'var', has_trailing_space: true }, - // CHECK:STDOUT: { index: 28, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: 'floats', identifier: 2 }, - // CHECK:STDOUT: { index: 29, kind: 'Colon', line: {{ *}}[[@LINE-3]], column: 13, indent: 3, spelling: ':', has_trailing_space: true }, - // CHECK:STDOUT: { index: 30, kind: 'OpenSquareBracket', line: {{ *}}[[@LINE-4]], column: 15, indent: 3, spelling: '[', closing_token: 34 }, - // CHECK:STDOUT: { index: 31, kind: 'FloatingPointTypeLiteral', line: {{ *}}[[@LINE-5]], column: 16, indent: 3, spelling: 'f64' }, - // CHECK:STDOUT: { index: 32, kind: 'Semi', line: {{ *}}[[@LINE-6]], column: 19, indent: 3, spelling: ';', has_trailing_space: true }, - // CHECK:STDOUT: { index: 33, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-7]], column: 21, indent: 3, spelling: '7', value: `7` }, - // CHECK:STDOUT: { index: 34, kind: 'CloseSquareBracket', line: {{ *}}[[@LINE-8]], column: 22, indent: 3, spelling: ']', opening_token: 30, has_trailing_space: true }, - // CHECK:STDOUT: { index: 35, kind: 'Equal', line: {{ *}}[[@LINE-9]], column: 24, indent: 3, spelling: '=', has_trailing_space: true }, - // CHECK:STDOUT: { index: 36, kind: 'OpenParen', line: {{ *}}[[@LINE-10]], column: 26, indent: 3, spelling: '(', closing_token: 51, has_trailing_space: true }, + // CHECK:STDOUT: { index: 28, kind: 'Var', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: 'var', has_trailing_space: true }, + // CHECK:STDOUT: { index: 29, kind: 'Identifier', line: {{ *}}[[@LINE-2]], column: 7, indent: 3, spelling: 'floats', identifier: 2 }, + // CHECK:STDOUT: { index: 30, kind: 'Colon', line: {{ *}}[[@LINE-3]], column: 13, indent: 3, spelling: ':', has_trailing_space: true }, + // CHECK:STDOUT: { index: 31, kind: 'OpenSquareBracket', line: {{ *}}[[@LINE-4]], column: 15, indent: 3, spelling: '[', closing_token: 35 }, + // CHECK:STDOUT: { index: 32, kind: 'FloatingPointTypeLiteral', line: {{ *}}[[@LINE-5]], column: 16, indent: 3, spelling: 'f64' }, + // CHECK:STDOUT: { index: 33, kind: 'Semi', line: {{ *}}[[@LINE-6]], column: 19, indent: 3, spelling: ';', has_trailing_space: true }, + // CHECK:STDOUT: { index: 34, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-7]], column: 21, indent: 3, spelling: '7', value: `7` }, + // CHECK:STDOUT: { index: 35, kind: 'CloseSquareBracket', line: {{ *}}[[@LINE-8]], column: 22, indent: 3, spelling: ']', opening_token: 31, has_trailing_space: true }, + // CHECK:STDOUT: { index: 36, kind: 'Equal', line: {{ *}}[[@LINE-9]], column: 24, indent: 3, spelling: '=', has_trailing_space: true }, + // CHECK:STDOUT: { index: 37, kind: 'OpenParen', line: {{ *}}[[@LINE-10]], column: 26, indent: 3, spelling: '(', closing_token: 52, has_trailing_space: true }, 0.9, - // CHECK:STDOUT: { index: 37, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '0.9', value: `9*10^-1` }, - // CHECK:STDOUT: { index: 38, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 38, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '0.9', value: `9*10^-1` }, + // CHECK:STDOUT: { index: 39, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: ',', has_trailing_space: true }, 8.0, - // CHECK:STDOUT: { index: 39, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '8.0', value: `80*10^-1` }, - // CHECK:STDOUT: { index: 40, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 40, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '8.0', value: `80*10^-1` }, + // CHECK:STDOUT: { index: 41, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 8, indent: 5, spelling: ',', has_trailing_space: true }, 80.0, - // CHECK:STDOUT: { index: 41, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '80.0', value: `800*10^-1` }, - // CHECK:STDOUT: { index: 42, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 9, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 42, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '80.0', value: `800*10^-1` }, + // CHECK:STDOUT: { index: 43, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 9, indent: 5, spelling: ',', has_trailing_space: true }, 1.0e7, - // CHECK:STDOUT: { index: 43, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '1.0e7', value: `10*10^6` }, - // CHECK:STDOUT: { index: 44, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 44, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '1.0e7', value: `10*10^6` }, + // CHECK:STDOUT: { index: 45, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: ',', has_trailing_space: true }, 1.0e8, - // CHECK:STDOUT: { index: 45, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '1.0e8', value: `10*10^7` }, - // CHECK:STDOUT: { index: 46, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 46, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '1.0e8', value: `10*10^7` }, + // CHECK:STDOUT: { index: 47, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 10, indent: 5, spelling: ',', has_trailing_space: true }, 1.0e-8, - // CHECK:STDOUT: { index: 47, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '1.0e-8', value: `10*10^-9` }, - // CHECK:STDOUT: { index: 48, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 48, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '1.0e-8', value: `10*10^-9` }, + // CHECK:STDOUT: { index: 49, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 11, indent: 5, spelling: ',', has_trailing_space: true }, 39999999999999999993.0e39999999999999999993, - // CHECK:STDOUT: { index: 49, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '39999999999999999993.0e39999999999999999993', value: `399999999999999999930*10^39999999999999999992` }, - // CHECK:STDOUT: { index: 50, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 48, indent: 5, spelling: ',', has_trailing_space: true }, + // CHECK:STDOUT: { index: 50, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 5, indent: 5, spelling: '39999999999999999993.0e39999999999999999993', value: `399999999999999999930*10^39999999999999999992` }, + // CHECK:STDOUT: { index: 51, kind: 'Comma', line: {{ *}}[[@LINE-2]], column: 48, indent: 5, spelling: ',', has_trailing_space: true }, ); - // CHECK:STDOUT: { index: 51, kind: 'CloseParen', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ')', opening_token: 36 }, - // CHECK:STDOUT: { index: 52, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ';', has_trailing_space: true }, + // CHECK:STDOUT: { index: 52, kind: 'CloseParen', line: {{ *}}[[@LINE-1]], column: 3, indent: 3, spelling: ')', opening_token: 37 }, + // CHECK:STDOUT: { index: 53, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 4, indent: 3, spelling: ';', has_trailing_space: true }, } -// CHECK:STDOUT: { index: 53, kind: 'CloseCurlyBrace', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '}', opening_token: 4, has_trailing_space: true }, +// CHECK:STDOUT: { index: 54, kind: 'CloseCurlyBrace', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '}', opening_token: 5, has_trailing_space: true }, -// CHECK:STDOUT: { index: 54, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 55, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/printing_digit_padding.carbon b/toolchain/lex/testdata/printing_digit_padding.carbon index c3fa210458d4..8594ff9c7c6e 100644 --- a/toolchain/lex/testdata/printing_digit_padding.carbon +++ b/toolchain/lex/testdata/printing_digit_padding.carbon @@ -5,15 +5,16 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: printing_digit_padding.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, ; -// CHECK:STDOUT: { index: 0, kind: 'Semi', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: ';', has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'Semi', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: ';', has_trailing_space: true }, // Test digit padding with values of 9, 10, and 11. ;;; - // CHECK:STDOUT: { index: 1, kind: 'Semi', line: {{ *}}[[@LINE-1]], column: 9, indent: 9, spelling: ';' }, - // CHECK:STDOUT: { index: 2, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 10, indent: 9, spelling: ';' }, - // CHECK:STDOUT: { index: 3, kind: 'Semi', line: {{ *}}[[@LINE-3]], column: 11, indent: 9, spelling: ';', has_trailing_space: true }, + // CHECK:STDOUT: { index: 2, kind: 'Semi', line: {{ *}}[[@LINE-1]], column: 9, indent: 9, spelling: ';' }, + // CHECK:STDOUT: { index: 3, kind: 'Semi', line: {{ *}}[[@LINE-2]], column: 10, indent: 9, spelling: ';' }, + // CHECK:STDOUT: { index: 4, kind: 'Semi', line: {{ *}}[[@LINE-3]], column: 11, indent: 9, spelling: ';', has_trailing_space: true }, -// CHECK:STDOUT: { index: 4, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 5, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/printing_integer_literal.carbon b/toolchain/lex/testdata/printing_integer_literal.carbon index b0da32c83d8d..3d9b1cfb7228 100644 --- a/toolchain/lex/testdata/printing_integer_literal.carbon +++ b/toolchain/lex/testdata/printing_integer_literal.carbon @@ -5,9 +5,10 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: printing_integer_literal.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, 123 -// CHECK:STDOUT: { index: 0, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '123', value: `123`, has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '123', value: `123`, has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/printing_real_literal.carbon b/toolchain/lex/testdata/printing_real_literal.carbon index 4f1bcfb39cdf..a59761771121 100644 --- a/toolchain/lex/testdata/printing_real_literal.carbon +++ b/toolchain/lex/testdata/printing_real_literal.carbon @@ -5,9 +5,10 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: printing_real_literal.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, 2.5 -// CHECK:STDOUT: { index: 0, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '2.5', value: `25*10^-1`, has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'RealLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '2.5', value: `25*10^-1`, has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/testdata/printing_token.carbon b/toolchain/lex/testdata/printing_token.carbon index 8ab728a490de..d28e931c9c80 100644 --- a/toolchain/lex/testdata/printing_token.carbon +++ b/toolchain/lex/testdata/printing_token.carbon @@ -5,9 +5,10 @@ // AUTOUPDATE // CHECK:STDOUT: - filename: printing_token.carbon // CHECK:STDOUT: tokens: [ +// CHECK:STDOUT: { index: 0, kind: 'StartOfFile', line: {{ *\d+}}, column: 1, indent: 1, spelling: '', has_trailing_space: true }, 0x9 -// CHECK:STDOUT: { index: 0, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '0x9', value: `9`, has_trailing_space: true }, +// CHECK:STDOUT: { index: 1, kind: 'IntegerLiteral', line: {{ *}}[[@LINE-1]], column: 1, indent: 1, spelling: '0x9', value: `9`, has_trailing_space: true }, -// CHECK:STDOUT: { index: 1, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, +// CHECK:STDOUT: { index: 2, kind: 'EndOfFile', line: {{ *}}[[@LINE+1]], column: {{ *\d+}}, indent: 1, spelling: '' }, // CHECK:STDOUT: ] diff --git a/toolchain/lex/token_kind.def b/toolchain/lex/token_kind.def index 7a501a26f29a..62c8808935b8 100644 --- a/toolchain/lex/token_kind.def +++ b/toolchain/lex/token_kind.def @@ -210,6 +210,7 @@ CARBON_TOKEN(IntegerTypeLiteral) CARBON_TOKEN(UnsignedIntegerTypeLiteral) CARBON_TOKEN(FloatingPointTypeLiteral) CARBON_TOKEN(Error) +CARBON_TOKEN(StartOfFile) CARBON_TOKEN(EndOfFile) #undef CARBON_TOKEN diff --git a/toolchain/lex/tokenized_buffer.cpp b/toolchain/lex/tokenized_buffer.cpp index 3bc12f17b816..9346bc915b83 100644 --- a/toolchain/lex/tokenized_buffer.cpp +++ b/toolchain/lex/tokenized_buffer.cpp @@ -268,9 +268,7 @@ class TokenizedBuffer::Lexer { } auto NoteWhitespace() -> void { - if (!buffer_->token_infos_.empty()) { - buffer_->token_infos_.back().has_trailing_space = true; - } + buffer_->token_infos_.back().has_trailing_space = true; } auto SkipWhitespace(llvm::StringRef& source_text) -> bool { @@ -709,6 +707,15 @@ class TokenizedBuffer::Lexer { .column = current_column_}); } + auto AddStartOfFileToken() -> void { + // Note that the start-of-file always has trailing space because it *is* + // whitespace. + buffer_->AddToken({.kind = TokenKind::StartOfFile, + .has_trailing_space = true, + .token_line = current_line_, + .column = current_column_}); + } + constexpr static auto MakeDispatchTable() -> DispatchTableT { DispatchTableT table = {}; auto dispatch_lex_error = +[](Lexer& lexer, llvm::StringRef& source_text) { @@ -831,6 +838,10 @@ auto TokenizedBuffer::Lex(SourceBuffer& source, DiagnosticConsumer& consumer) // dispatch structures. constexpr Lexer::DispatchTableT DispatchTable = Lexer::MakeDispatchTable(); + // Before lexing any source text, add the start-of-file token so that code can + // assume a non-empty token buffer for the rest of lexing. + lexer.AddStartOfFileToken(); + llvm::StringRef source_text = source.text(); while (lexer.SkipWhitespace(source_text)) { Lexer::LexResult result = @@ -914,7 +925,8 @@ auto TokenizedBuffer::GetTokenText(Token token) const -> llvm::StringRef { return llvm::StringRef(suffix.data() - 1, suffix.size() + 1); } - if (token_info.kind == TokenKind::EndOfFile) { + if (token_info.kind == TokenKind::StartOfFile || + token_info.kind == TokenKind::EndOfFile) { return llvm::StringRef(); } diff --git a/toolchain/lex/tokenized_buffer_test.cpp b/toolchain/lex/tokenized_buffer_test.cpp index 575cbcb85351..1ee64aca5991 100644 --- a/toolchain/lex/tokenized_buffer_test.cpp +++ b/toolchain/lex/tokenized_buffer_test.cpp @@ -56,8 +56,8 @@ class LexerTest : public ::testing::Test { TEST_F(LexerTest, HandlesEmptyBuffer) { auto buffer = Lex(""); EXPECT_FALSE(buffer.has_errors()); - EXPECT_THAT(buffer, - HasTokens(llvm::ArrayRef{{TokenKind::EndOfFile}})); + EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::EndOfFile}})); } TEST_F(LexerTest, TracksLinesAndColumns) { @@ -66,6 +66,10 @@ TEST_F(LexerTest, TracksLinesAndColumns) { EXPECT_THAT( buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, + .line = 1, + .column = 1, + .indent_column = 1}, {.kind = TokenKind::Semi, .line = 2, .column = 3, .indent_column = 3}, {.kind = TokenKind::Semi, .line = 2, .column = 4, .indent_column = 3}, {.kind = TokenKind::Semi, .line = 3, .column = 4, .indent_column = 4}, @@ -98,6 +102,7 @@ TEST_F(LexerTest, HandlesNumericLiteral) { EXPECT_FALSE(buffer.has_errors()); ASSERT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::IntegerLiteral, .line = 1, .column = 1, @@ -144,21 +149,22 @@ TEST_F(LexerTest, HandlesNumericLiteral) { .text = "1.5e9"}, {.kind = TokenKind::EndOfFile, .line = 6, .column = 6}, })); - auto token_12 = buffer.tokens().begin(); + auto token_start = buffer.tokens().begin(); + auto token_12 = token_start + 1; EXPECT_EQ(buffer.GetIntegerLiteral(*token_12), 12); - auto token_578 = buffer.tokens().begin() + 2; + auto token_578 = token_12 + 2; EXPECT_EQ(buffer.GetIntegerLiteral(*token_578), 578); - auto token_1 = buffer.tokens().begin() + 3; + auto token_1 = token_578 + 1; EXPECT_EQ(buffer.GetIntegerLiteral(*token_1), 1); - auto token_2 = buffer.tokens().begin() + 4; + auto token_2 = token_1 + 1; EXPECT_EQ(buffer.GetIntegerLiteral(*token_2), 2); - auto token_0x12_3abc = buffer.tokens().begin() + 5; + auto token_0x12_3abc = token_2 + 1; EXPECT_EQ(buffer.GetIntegerLiteral(*token_0x12_3abc), 0x12'3abc); - auto token_0b10_10_11 = buffer.tokens().begin() + 6; + auto token_0b10_10_11 = token_0x12_3abc + 1; EXPECT_EQ(buffer.GetIntegerLiteral(*token_0b10_10_11), 0b10'10'11); - auto token_1_234_567 = buffer.tokens().begin() + 7; + auto token_1_234_567 = token_0b10_10_11 + 1; EXPECT_EQ(buffer.GetIntegerLiteral(*token_1_234_567), 1'234'567); - auto token_1_5e9 = buffer.tokens().begin() + 8; + auto token_1_5e9 = token_1_234_567 + 1; auto value_1_5e9 = buffer.GetRealLiteral(*token_1_5e9); EXPECT_EQ(value_1_5e9.mantissa.getZExtValue(), 15); EXPECT_EQ(value_1_5e9.exponent.getSExtValue(), 8); @@ -170,6 +176,7 @@ TEST_F(LexerTest, HandlesInvalidNumericLiterals) { EXPECT_TRUE(buffer.has_errors()); ASSERT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::Error, .line = 1, .column = 1, @@ -218,6 +225,7 @@ TEST_F(LexerTest, SplitsNumericLiteralsProperly) { auto buffer = Lex(source_text); EXPECT_TRUE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile}, {.kind = TokenKind::IntegerLiteral, .text = "1"}, {.kind = TokenKind::Period}, // newline @@ -277,6 +285,7 @@ TEST_F(LexerTest, HandlesGarbageCharacters) { EXPECT_THAT( buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::Error, .line = 1, .column = 1, @@ -310,6 +319,7 @@ TEST_F(LexerTest, Symbols) { auto buffer = Lex("<<<"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::LessLess}, {TokenKind::Less}, {TokenKind::EndOfFile}, @@ -318,6 +328,7 @@ TEST_F(LexerTest, Symbols) { buffer = Lex("<<=>>"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::LessLessEqual}, {TokenKind::GreaterGreater}, {TokenKind::EndOfFile}, @@ -326,6 +337,7 @@ TEST_F(LexerTest, Symbols) { buffer = Lex("< <=> >"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::Less}, {TokenKind::LessEqualGreater}, {TokenKind::Greater}, @@ -335,6 +347,7 @@ TEST_F(LexerTest, Symbols) { buffer = Lex("\\/?@&^!"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::Backslash}, {TokenKind::Slash}, {TokenKind::Question}, @@ -350,6 +363,7 @@ TEST_F(LexerTest, Parens) { auto buffer = Lex("()"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::OpenParen}, {TokenKind::CloseParen}, {TokenKind::EndOfFile}, @@ -358,6 +372,7 @@ TEST_F(LexerTest, Parens) { buffer = Lex("((()()))"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::OpenParen}, {TokenKind::OpenParen}, {TokenKind::OpenParen}, @@ -374,6 +389,7 @@ TEST_F(LexerTest, CurlyBraces) { auto buffer = Lex("{}"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::OpenCurlyBrace}, {TokenKind::CloseCurlyBrace}, {TokenKind::EndOfFile}, @@ -382,6 +398,7 @@ TEST_F(LexerTest, CurlyBraces) { buffer = Lex("{{{}{}}}"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::OpenCurlyBrace}, {TokenKind::OpenCurlyBrace}, {TokenKind::OpenCurlyBrace}, @@ -398,7 +415,7 @@ TEST_F(LexerTest, MatchingGroups) { { TokenizedBuffer buffer = Lex("(){}"); ASSERT_FALSE(buffer.has_errors()); - auto it = buffer.tokens().begin(); + auto it = ++buffer.tokens().begin(); auto open_paren_token = *it++; auto close_paren_token = *it++; EXPECT_EQ(close_paren_token, @@ -419,7 +436,7 @@ TEST_F(LexerTest, MatchingGroups) { { TokenizedBuffer buffer = Lex("({x}){(y)} {{((z))}}"); ASSERT_FALSE(buffer.has_errors()); - auto it = buffer.tokens().begin(); + auto it = ++buffer.tokens().begin(); auto open_paren_token = *it++; auto open_curly_token = *it++; ASSERT_EQ("x", buffer.GetIdentifierText(buffer.GetIdentifier(*it++))); @@ -485,6 +502,7 @@ TEST_F(LexerTest, MismatchedGroups) { EXPECT_TRUE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::OpenCurlyBrace}, {.kind = TokenKind::CloseCurlyBrace, .recovery = true}, {TokenKind::EndOfFile}, @@ -493,6 +511,7 @@ TEST_F(LexerTest, MismatchedGroups) { buffer = Lex("}"); EXPECT_TRUE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Error, .text = "}"}, {TokenKind::EndOfFile}, })); @@ -502,6 +521,7 @@ TEST_F(LexerTest, MismatchedGroups) { EXPECT_THAT( buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::OpenCurlyBrace, .column = 1}, {.kind = TokenKind::OpenParen, .column = 2}, {.kind = TokenKind::CloseParen, .column = 3, .recovery = true}, @@ -514,6 +534,7 @@ TEST_F(LexerTest, MismatchedGroups) { EXPECT_THAT( buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Error, .column = 1, .text = ")"}, {.kind = TokenKind::OpenParen, .column = 2}, {.kind = TokenKind::OpenCurlyBrace, .column = 3}, @@ -528,6 +549,8 @@ TEST_F(LexerTest, Whitespace) { // Whether there should be whitespace before/after each token. bool space[] = {true, + // start-of-file + true, // { false, // ( @@ -562,6 +585,7 @@ TEST_F(LexerTest, Keywords) { EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Fn, .column = 4, .indent_column = 4}, {TokenKind::EndOfFile}, })); @@ -569,6 +593,7 @@ TEST_F(LexerTest, Keywords) { buffer = Lex("and or not if else for return var break continue _"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::And}, {TokenKind::Or}, {TokenKind::Not}, @@ -590,6 +615,7 @@ TEST_F(LexerTest, Comments) { EXPECT_THAT( buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::Semi, .line = 1, .column = 2, .indent_column = 2}, {.kind = TokenKind::Semi, .line = 3, .column = 3, .indent_column = 3}, {.kind = TokenKind::EndOfFile, .line = 3, .column = 4}, @@ -597,20 +623,20 @@ TEST_F(LexerTest, Comments) { buffer = Lex("// foo\n//\n// bar"); EXPECT_FALSE(buffer.has_errors()); - EXPECT_THAT(buffer, - HasTokens(llvm::ArrayRef{{TokenKind::EndOfFile}})); + EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::EndOfFile}})); // Make sure weird characters aren't a problem. buffer = Lex(" // foo#$!^?@-_💩🍫⃠ [̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]"); EXPECT_FALSE(buffer.has_errors()); - EXPECT_THAT(buffer, - HasTokens(llvm::ArrayRef{{TokenKind::EndOfFile}})); + EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::EndOfFile}})); // Make sure we can lex a comment at the end of the input. buffer = Lex("//"); EXPECT_FALSE(buffer.has_errors()); - EXPECT_THAT(buffer, - HasTokens(llvm::ArrayRef{{TokenKind::EndOfFile}})); + EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {TokenKind::EndOfFile}})); } TEST_F(LexerTest, InvalidComments) { @@ -630,6 +656,7 @@ TEST_F(LexerTest, Identifiers) { auto buffer = Lex(" foobar"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Identifier, .column = 4, .indent_column = 4, @@ -641,6 +668,7 @@ TEST_F(LexerTest, Identifiers) { buffer = Lex("_foo_bar"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Identifier, .text = "_foo_bar"}, {TokenKind::EndOfFile}, })); @@ -648,6 +676,7 @@ TEST_F(LexerTest, Identifiers) { buffer = Lex("foo2bar00"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Identifier, .text = "foo2bar00"}, {TokenKind::EndOfFile}, })); @@ -656,6 +685,7 @@ TEST_F(LexerTest, Identifiers) { buffer = Lex("fnord"); EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {TokenKind::StartOfFile}, {.kind = TokenKind::Identifier, .text = "fnord"}, {TokenKind::EndOfFile}, })); @@ -665,6 +695,7 @@ TEST_F(LexerTest, Identifiers) { EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::Identifier, .line = 1, .column = 4, @@ -717,6 +748,7 @@ TEST_F(LexerTest, StringLiterals) { EXPECT_FALSE(buffer.has_errors()); EXPECT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::StringLiteral, .line = 2, .column = 5, @@ -817,6 +849,8 @@ TEST_F(LexerTest, TypeLiterals) { EXPECT_FALSE(buffer.has_errors()); ASSERT_THAT(buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, + {.kind = TokenKind::Identifier, .line = 2, .column = 5, @@ -894,21 +928,21 @@ TEST_F(LexerTest, TypeLiterals) { {.kind = TokenKind::EndOfFile, .line = 6, .column = 3}, })); - auto token_i1 = buffer.tokens().begin() + 1; + auto token_i1 = buffer.tokens().begin() + 2; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_i1), 1); - auto token_i20 = buffer.tokens().begin() + 2; + auto token_i20 = buffer.tokens().begin() + 3; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_i20), 20); - auto token_i999999999999 = buffer.tokens().begin() + 3; + auto token_i999999999999 = buffer.tokens().begin() + 4; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_i999999999999), 999999999999ULL); - auto token_u1 = buffer.tokens().begin() + 6; + auto token_u1 = buffer.tokens().begin() + 7; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_u1), 1); - auto token_u64 = buffer.tokens().begin() + 7; + auto token_u64 = buffer.tokens().begin() + 8; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_u64), 64); - auto token_f32 = buffer.tokens().begin() + 9; + auto token_f32 = buffer.tokens().begin() + 10; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_f32), 32); - auto token_f80 = buffer.tokens().begin() + 10; + auto token_f80 = buffer.tokens().begin() + 11; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_f80), 80); - auto token_f1 = buffer.tokens().begin() + 11; + auto token_f1 = buffer.tokens().begin() + 12; EXPECT_EQ(buffer.GetTypeLiteralSize(*token_f1), 1); } @@ -927,6 +961,7 @@ TEST_F(LexerTest, TypeLiteralTooManyDigits) { ASSERT_THAT( buffer, HasTokens(llvm::ArrayRef{ + {.kind = TokenKind::StartOfFile, .line = 1, .column = 1}, {.kind = TokenKind::Error, .line = 1, .column = 1, @@ -1011,22 +1046,27 @@ TEST_F(LexerTest, PrintingAsYaml) { Pair("tokens", Yaml::Sequence(ElementsAre( Yaml::Mapping(ElementsAre( - Pair("index", "0"), Pair("kind", "Semi"), - Pair("line", "2"), Pair("column", "2"), - Pair("indent", "2"), Pair("spelling", ";"), + Pair("index", "0"), Pair("kind", "StartOfFile"), + Pair("line", "1"), Pair("column", "1"), + Pair("indent", "1"), Pair("spelling", ""), Pair("has_trailing_space", "true"))), Yaml::Mapping( ElementsAre(Pair("index", "1"), Pair("kind", "Semi"), + Pair("line", "2"), Pair("column", "2"), + Pair("indent", "2"), Pair("spelling", ";"), + Pair("has_trailing_space", "true"))), + Yaml::Mapping( + ElementsAre(Pair("index", "2"), Pair("kind", "Semi"), Pair("line", "5"), Pair("column", "1"), Pair("indent", "1"), Pair("spelling", ";"), Pair("has_trailing_space", "true"))), Yaml::Mapping( - ElementsAre(Pair("index", "2"), Pair("kind", "Semi"), + ElementsAre(Pair("index", "3"), Pair("kind", "Semi"), Pair("line", "5"), Pair("column", "3"), Pair("indent", "1"), Pair("spelling", ";"), Pair("has_trailing_space", "true"))), Yaml::Mapping(ElementsAre( - Pair("index", "3"), Pair("kind", "EndOfFile"), + Pair("index", "4"), Pair("kind", "EndOfFile"), Pair("line", "15"), Pair("column", "1"), Pair("indent", "1"), Pair("spelling", ""))))))))))))); } diff --git a/toolchain/parse/node_kind.def b/toolchain/parse/node_kind.def index 5428ca046708..fbcea53915b7 100644 --- a/toolchain/parse/node_kind.def +++ b/toolchain/parse/node_kind.def @@ -40,6 +40,9 @@ CARBON_PARSE_NODE_KIND(Name) #endif +// The start of the file. +CARBON_PARSE_NODE_KIND_CHILD_COUNT(FileStart, 0) + // The end of the file. CARBON_PARSE_NODE_KIND_CHILD_COUNT(FileEnd, 0) diff --git a/toolchain/parse/testdata/array/fail_require_close_bracket.carbon b/toolchain/parse/testdata/array/fail_require_close_bracket.carbon index 03ca4762c9ff..caa32b680008 100644 --- a/toolchain/parse/testdata/array/fail_require_close_bracket.carbon +++ b/toolchain/parse/testdata/array/fail_require_close_bracket.carbon @@ -16,11 +16,12 @@ // CHECK:STDERR: ^ var x: [i32;; -// CHECK:STDERR: fail_require_close_bracket.carbon:[[@LINE+15]]:21: ERROR: `var` declarations must end with a `;`. +// CHECK:STDERR: fail_require_close_bracket.carbon:[[@LINE+16]]:21: ERROR: `var` declarations must end with a `;`. // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDOUT: - filename: fail_require_close_bracket.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'ArrayExpressionStart', text: '['}, diff --git a/toolchain/parse/testdata/array/fail_require_semi.carbon b/toolchain/parse/testdata/array/fail_require_semi.carbon index 285a507aa79c..10e19c90495d 100644 --- a/toolchain/parse/testdata/array/fail_require_semi.carbon +++ b/toolchain/parse/testdata/array/fail_require_semi.carbon @@ -11,6 +11,7 @@ var x: [i32]; // CHECK:STDOUT: - filename: fail_require_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'ArrayExpressionStart', text: '['}, diff --git a/toolchain/parse/testdata/array/with_length.carbon b/toolchain/parse/testdata/array/with_length.carbon index 4cc224f3dd80..77cbd2272162 100644 --- a/toolchain/parse/testdata/array/with_length.carbon +++ b/toolchain/parse/testdata/array/with_length.carbon @@ -8,6 +8,7 @@ var x: [i32; 10]; // CHECK:STDOUT: - filename: with_length.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'ArrayExpressionStart', text: '['}, diff --git a/toolchain/parse/testdata/array/without_length.carbon b/toolchain/parse/testdata/array/without_length.carbon index 68854dbc800a..fb60c726df1d 100644 --- a/toolchain/parse/testdata/array/without_length.carbon +++ b/toolchain/parse/testdata/array/without_length.carbon @@ -8,6 +8,7 @@ var x: [i32;]; // CHECK:STDOUT: - filename: without_length.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'ArrayExpressionStart', text: '['}, diff --git a/toolchain/parse/testdata/basics/builtin_types.carbon b/toolchain/parse/testdata/basics/builtin_types.carbon index e1121b5affb6..9b53a5b7e12d 100644 --- a/toolchain/parse/testdata/basics/builtin_types.carbon +++ b/toolchain/parse/testdata/basics/builtin_types.carbon @@ -10,6 +10,7 @@ var test_str: String = "Test"; // CHECK:STDOUT: - filename: builtin_types.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'test_i32'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/basics/empty.carbon b/toolchain/parse/testdata/basics/empty.carbon index 7c4b52970f03..3329ba12087e 100644 --- a/toolchain/parse/testdata/basics/empty.carbon +++ b/toolchain/parse/testdata/basics/empty.carbon @@ -6,5 +6,6 @@ // CHECK:STDOUT: - filename: empty.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/empty_declaration.carbon b/toolchain/parse/testdata/basics/empty_declaration.carbon index ad7c9e37a985..74688e76a16d 100644 --- a/toolchain/parse/testdata/basics/empty_declaration.carbon +++ b/toolchain/parse/testdata/basics/empty_declaration.carbon @@ -8,6 +8,7 @@ // CHECK:STDOUT: - filename: empty_declaration.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'EmptyDeclaration', text: ';'}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/fail_invalid_designators.carbon b/toolchain/parse/testdata/basics/fail_invalid_designators.carbon index e1790096f701..0612a5aaa4d1 100644 --- a/toolchain/parse/testdata/basics/fail_invalid_designators.carbon +++ b/toolchain/parse/testdata/basics/fail_invalid_designators.carbon @@ -22,6 +22,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_invalid_designators.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/basics/fail_no_intro_with_semi.carbon b/toolchain/parse/testdata/basics/fail_no_intro_with_semi.carbon index 2a1f28d01265..130e75e553cb 100644 --- a/toolchain/parse/testdata/basics/fail_no_intro_with_semi.carbon +++ b/toolchain/parse/testdata/basics/fail_no_intro_with_semi.carbon @@ -11,6 +11,7 @@ foo; // CHECK:STDOUT: - filename: fail_no_intro_with_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'EmptyDeclaration', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/fail_no_intro_without_semi.carbon b/toolchain/parse/testdata/basics/fail_no_intro_without_semi.carbon index 644d665525fd..aac5cdbcf42e 100644 --- a/toolchain/parse/testdata/basics/fail_no_intro_without_semi.carbon +++ b/toolchain/parse/testdata/basics/fail_no_intro_without_semi.carbon @@ -11,6 +11,7 @@ foo bar baz // CHECK:STDOUT: - filename: fail_no_intro_without_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'EmptyDeclaration', text: 'foo', has_error: yes}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, // CHECK:STDOUT: ] diff --git a/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon b/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon index 3bee32871f7c..79c8800681a1 100644 --- a/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon +++ b/toolchain/parse/testdata/basics/fail_paren_match_regression.carbon @@ -12,11 +12,12 @@ // CHECK:STDERR: ^ var = (foo {}) -// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+15]]:21: ERROR: `var` declarations must end with a `;`. +// CHECK:STDERR: fail_paren_match_regression.carbon:[[@LINE+16]]:21: ERROR: `var` declarations must end with a `;`. // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDOUT: - filename: fail_paren_match_regression.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: '=', has_error: yes}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '=', has_error: yes}, diff --git a/toolchain/parse/testdata/basics/function_call.carbon b/toolchain/parse/testdata/basics/function_call.carbon index f67e6e8b61b8..725ff9bcf184 100644 --- a/toolchain/parse/testdata/basics/function_call.carbon +++ b/toolchain/parse/testdata/basics/function_call.carbon @@ -11,6 +11,7 @@ fn F() { // CHECK:STDOUT: - filename: function_call.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/basics/multifile.carbon b/toolchain/parse/testdata/basics/multifile.carbon index 7b9bca444add..ac81cdce07cd 100644 --- a/toolchain/parse/testdata/basics/multifile.carbon +++ b/toolchain/parse/testdata/basics/multifile.carbon @@ -12,6 +12,7 @@ fn B() {} // CHECK:STDOUT: - filename: a.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'A'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, @@ -22,6 +23,7 @@ fn B() {} // CHECK:STDOUT: ] // CHECK:STDOUT: - filename: b.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'B'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/basics/numeric_literals.carbon b/toolchain/parse/testdata/basics/numeric_literals.carbon index fc6edbe84ae0..30ce2b0ee0f1 100644 --- a/toolchain/parse/testdata/basics/numeric_literals.carbon +++ b/toolchain/parse/testdata/basics/numeric_literals.carbon @@ -27,6 +27,7 @@ fn F() { // CHECK:STDOUT: - filename: numeric_literals.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/basics/parens.carbon b/toolchain/parse/testdata/basics/parens.carbon index 82914ffade5f..cfb220f449bc 100644 --- a/toolchain/parse/testdata/basics/parens.carbon +++ b/toolchain/parse/testdata/basics/parens.carbon @@ -10,6 +10,7 @@ fn F(n: i32) -> i32 { // CHECK:STDOUT: - filename: parens.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/class/basic.carbon b/toolchain/parse/testdata/class/basic.carbon index 38ab7f843b41..0b3de4b836f8 100644 --- a/toolchain/parse/testdata/class/basic.carbon +++ b/toolchain/parse/testdata/class/basic.carbon @@ -10,6 +10,7 @@ class Foo { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ClassDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/class/fn_definitions.carbon b/toolchain/parse/testdata/class/fn_definitions.carbon index f4dcea56142a..8ed390623b8a 100644 --- a/toolchain/parse/testdata/class/fn_definitions.carbon +++ b/toolchain/parse/testdata/class/fn_definitions.carbon @@ -14,6 +14,7 @@ class Foo { // CHECK:STDOUT: - filename: fn_definitions.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ClassDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/class/var.carbon b/toolchain/parse/testdata/class/var.carbon index f10c84bee717..ad61a7e26d17 100644 --- a/toolchain/parse/testdata/class/var.carbon +++ b/toolchain/parse/testdata/class/var.carbon @@ -10,6 +10,7 @@ class Foo { // CHECK:STDOUT: - filename: var.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ClassDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon b/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon index cf2ca651a448..07745b1ef5c0 100644 --- a/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon +++ b/toolchain/parse/testdata/for/fail_colon_instead_of_in.carbon @@ -15,6 +15,7 @@ fn foo() { // CHECK:STDOUT: - filename: fail_colon_instead_of_in.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/for/fail_missing_cond.carbon b/toolchain/parse/testdata/for/fail_missing_cond.carbon index 5d63e87d8d5f..beb0fa1c8c57 100644 --- a/toolchain/parse/testdata/for/fail_missing_cond.carbon +++ b/toolchain/parse/testdata/for/fail_missing_cond.carbon @@ -23,6 +23,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_missing_cond.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/for/fail_missing_in.carbon b/toolchain/parse/testdata/for/fail_missing_in.carbon index a4762676e4b4..d2c7fe74bd06 100644 --- a/toolchain/parse/testdata/for/fail_missing_in.carbon +++ b/toolchain/parse/testdata/for/fail_missing_in.carbon @@ -15,6 +15,7 @@ fn foo() { // CHECK:STDOUT: - filename: fail_missing_in.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/for/fail_missing_var.carbon b/toolchain/parse/testdata/for/fail_missing_var.carbon index d09cac5cfd85..7691c108be4b 100644 --- a/toolchain/parse/testdata/for/fail_missing_var.carbon +++ b/toolchain/parse/testdata/for/fail_missing_var.carbon @@ -15,6 +15,7 @@ fn foo() { // CHECK:STDOUT: - filename: fail_missing_var.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/for/fail_square_brackets.carbon b/toolchain/parse/testdata/for/fail_square_brackets.carbon index 4d37eca88400..259ab6c341dc 100644 --- a/toolchain/parse/testdata/for/fail_square_brackets.carbon +++ b/toolchain/parse/testdata/for/fail_square_brackets.carbon @@ -23,6 +23,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_square_brackets.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/for/nested.carbon b/toolchain/parse/testdata/for/nested.carbon index 087fe7a9ae73..34cdb1d034d2 100644 --- a/toolchain/parse/testdata/for/nested.carbon +++ b/toolchain/parse/testdata/for/nested.carbon @@ -14,6 +14,7 @@ fn foo() { // CHECK:STDOUT: - filename: nested.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/for/simple.carbon b/toolchain/parse/testdata/for/simple.carbon index 5b097fa79177..7f740e6e6ac7 100644 --- a/toolchain/parse/testdata/for/simple.carbon +++ b/toolchain/parse/testdata/for/simple.carbon @@ -12,6 +12,7 @@ fn foo() { // CHECK:STDOUT: - filename: simple.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/declaration/addr.carbon b/toolchain/parse/testdata/function/declaration/addr.carbon index 5dd4f70c827f..c7ddce2df946 100644 --- a/toolchain/parse/testdata/function/declaration/addr.carbon +++ b/toolchain/parse/testdata/function/declaration/addr.carbon @@ -8,6 +8,7 @@ fn foo(addr a: i32*); // CHECK:STDOUT: - filename: addr.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/declaration/basic.carbon b/toolchain/parse/testdata/function/declaration/basic.carbon index 1cabd9fa9b3b..cd9a75462415 100644 --- a/toolchain/parse/testdata/function/declaration/basic.carbon +++ b/toolchain/parse/testdata/function/declaration/basic.carbon @@ -8,6 +8,7 @@ fn F(); // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/declaration/deduced_empty.carbon b/toolchain/parse/testdata/function/declaration/deduced_empty.carbon index 8fdf6804f1a2..5f90f62bdac0 100644 --- a/toolchain/parse/testdata/function/declaration/deduced_empty.carbon +++ b/toolchain/parse/testdata/function/declaration/deduced_empty.carbon @@ -8,6 +8,7 @@ fn foo[](); // CHECK:STDOUT: - filename: deduced_empty.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/function/declaration/deduced_params.carbon b/toolchain/parse/testdata/function/declaration/deduced_params.carbon index 953cc28ff912..5d34f584761a 100644 --- a/toolchain/parse/testdata/function/declaration/deduced_params.carbon +++ b/toolchain/parse/testdata/function/declaration/deduced_params.carbon @@ -8,6 +8,7 @@ fn foo[a: i32, b: i32](); // CHECK:STDOUT: - filename: deduced_params.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/function/declaration/fail_identifier_instead_of_sig.carbon b/toolchain/parse/testdata/function/declaration/fail_identifier_instead_of_sig.carbon index a96ee02db3cb..6bb2f77da740 100644 --- a/toolchain/parse/testdata/function/declaration/fail_identifier_instead_of_sig.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_identifier_instead_of_sig.carbon @@ -11,6 +11,7 @@ fn foo bar; // CHECK:STDOUT: - filename: fail_identifier_instead_of_sig.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_missing_deduced_close.carbon b/toolchain/parse/testdata/function/declaration/fail_missing_deduced_close.carbon index fbc8911e2336..1f323b1882f2 100644 --- a/toolchain/parse/testdata/function/declaration/fail_missing_deduced_close.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_missing_deduced_close.carbon @@ -13,11 +13,12 @@ // CHECK:STDERR: ^ fn Div[(); -// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+14]]:21: ERROR: A `(` for parameters is required after deduced parameters. +// CHECK:STDERR: fail_missing_deduced_close.carbon:[[@LINE+15]]:21: ERROR: A `(` for parameters is required after deduced parameters. // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDOUT: - filename: fail_missing_deduced_close.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'Div'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/function/declaration/fail_missing_name.carbon b/toolchain/parse/testdata/function/declaration/fail_missing_name.carbon index 2b0a3afcce4e..c167165c60de 100644 --- a/toolchain/parse/testdata/function/declaration/fail_missing_name.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_missing_name.carbon @@ -11,6 +11,7 @@ fn (); // CHECK:STDOUT: - filename: fail_missing_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '('}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_no_sig_or_semi.carbon b/toolchain/parse/testdata/function/declaration/fail_no_sig_or_semi.carbon index 9776e0ea3e45..315bf3e97e7b 100644 --- a/toolchain/parse/testdata/function/declaration/fail_no_sig_or_semi.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_no_sig_or_semi.carbon @@ -6,11 +6,12 @@ fn foo -// CHECK:STDERR: fail_no_sig_or_semi.carbon:[[@LINE+9]]:21: ERROR: `fn` requires a `(` for parameters. +// CHECK:STDERR: fail_no_sig_or_semi.carbon:[[@LINE+10]]:21: ERROR: `fn` requires a `(` for parameters. // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDOUT: - filename: fail_no_sig_or_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: 'fn', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_only_fn_and_semi.carbon b/toolchain/parse/testdata/function/declaration/fail_only_fn_and_semi.carbon index 66b9022848ea..f4a148ade67c 100644 --- a/toolchain/parse/testdata/function/declaration/fail_only_fn_and_semi.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_only_fn_and_semi.carbon @@ -11,6 +11,7 @@ fn; // CHECK:STDOUT: - filename: fail_only_fn_and_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';'}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_repeated_fn_and_semi.carbon b/toolchain/parse/testdata/function/declaration/fail_repeated_fn_and_semi.carbon index 0b9813b1945b..be06d77bda6c 100644 --- a/toolchain/parse/testdata/function/declaration/fail_repeated_fn_and_semi.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_repeated_fn_and_semi.carbon @@ -11,6 +11,7 @@ fn fn; // CHECK:STDOUT: - filename: fail_repeated_fn_and_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: 'fn'}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon b/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon index f99a01867429..bdbe3c8b26f4 100644 --- a/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_until_outdent.carbon @@ -14,6 +14,7 @@ fn F(); // CHECK:STDOUT: - filename: fail_skip_indented_newline_until_outdent.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '('}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: 'fn', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon b/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon index a209832a4750..48af24f52b0c 100644 --- a/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_with_semi.carbon @@ -14,6 +14,7 @@ fn F(); // CHECK:STDOUT: - filename: fail_skip_indented_newline_with_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '('}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon b/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon index c4bd0febd00d..a31fda0816b0 100644 --- a/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_skip_indented_newline_without_semi.carbon @@ -14,6 +14,7 @@ fn F(); // CHECK:STDOUT: - filename: fail_skip_indented_newline_without_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '('}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: 'fn', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon b/toolchain/parse/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon index 08df140ebde4..4793e4586ba2 100644 --- a/toolchain/parse/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_skip_to_newline_without_semi.carbon @@ -12,6 +12,7 @@ fn F(); // CHECK:STDOUT: - filename: fail_skip_to_newline_without_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '('}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: 'fn', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon b/toolchain/parse/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon index 972129f1b449..33712921c63a 100644 --- a/toolchain/parse/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_skip_without_semi_to_curly.carbon @@ -12,6 +12,7 @@ fn F(); // CHECK:STDOUT: - filename: fail_skip_without_semi_to_curly.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'EmptyDeclaration', text: 'struct', has_error: yes}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, diff --git a/toolchain/parse/testdata/function/declaration/fail_with_identifier_as_param.carbon b/toolchain/parse/testdata/function/declaration/fail_with_identifier_as_param.carbon index 53cf9897a752..e602252c3151 100644 --- a/toolchain/parse/testdata/function/declaration/fail_with_identifier_as_param.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_with_identifier_as_param.carbon @@ -11,6 +11,7 @@ fn foo(bar); // CHECK:STDOUT: - filename: fail_with_identifier_as_param.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon b/toolchain/parse/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon index f970fc0cac3a..836b0dca6725 100644 --- a/toolchain/parse/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon +++ b/toolchain/parse/testdata/function/declaration/fail_without_name_and_many_tokens_in_params.carbon @@ -11,6 +11,7 @@ fn (a tokens c d e f g h i j k l m n o p q r s t u v w x y z); // CHECK:STDOUT: - filename: fail_without_name_and_many_tokens_in_params.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '('}, // CHECK:STDOUT: {kind: 'FunctionDeclaration', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/function/declaration/params.carbon b/toolchain/parse/testdata/function/declaration/params.carbon index 88f27c17431a..b27b8f93162a 100644 --- a/toolchain/parse/testdata/function/declaration/params.carbon +++ b/toolchain/parse/testdata/function/declaration/params.carbon @@ -8,6 +8,7 @@ fn foo(a: i32, b: i32); // CHECK:STDOUT: - filename: params.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/declaration/with_return_type.carbon b/toolchain/parse/testdata/function/declaration/with_return_type.carbon index 13b962934614..371e1a81c723 100644 --- a/toolchain/parse/testdata/function/declaration/with_return_type.carbon +++ b/toolchain/parse/testdata/function/declaration/with_return_type.carbon @@ -8,6 +8,7 @@ fn foo() -> u32; // CHECK:STDOUT: - filename: with_return_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/definition/basic.carbon b/toolchain/parse/testdata/function/definition/basic.carbon index 8361dc77b65d..33e29196bc87 100644 --- a/toolchain/parse/testdata/function/definition/basic.carbon +++ b/toolchain/parse/testdata/function/definition/basic.carbon @@ -9,6 +9,7 @@ fn F() { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/definition/fail_identifier_in_statements.carbon b/toolchain/parse/testdata/function/definition/fail_identifier_in_statements.carbon index b9452867de09..847f826afe14 100644 --- a/toolchain/parse/testdata/function/definition/fail_identifier_in_statements.carbon +++ b/toolchain/parse/testdata/function/definition/fail_identifier_in_statements.carbon @@ -15,6 +15,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_identifier_in_statements.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/definition/with_params.carbon b/toolchain/parse/testdata/function/definition/with_params.carbon index b81b4dd00db0..45b22eeeb3a3 100644 --- a/toolchain/parse/testdata/function/definition/with_params.carbon +++ b/toolchain/parse/testdata/function/definition/with_params.carbon @@ -10,6 +10,7 @@ fn foo(bar: i64, baz: i64) { // CHECK:STDOUT: - filename: with_params.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/function/definition/with_return_type.carbon b/toolchain/parse/testdata/function/definition/with_return_type.carbon index ab9342b185f6..ad8b2936822d 100644 --- a/toolchain/parse/testdata/function/definition/with_return_type.carbon +++ b/toolchain/parse/testdata/function/definition/with_return_type.carbon @@ -10,6 +10,7 @@ fn foo() -> f64 { // CHECK:STDOUT: - filename: with_return_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/deduced_params/empty.carbon b/toolchain/parse/testdata/generics/deduced_params/empty.carbon index 00c9c8006eb4..022387078386 100644 --- a/toolchain/parse/testdata/generics/deduced_params/empty.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/empty.carbon @@ -10,6 +10,7 @@ interface Bar[]() {} // CHECK:STDOUT: - filename: empty.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/deduced_params/fail_no_parens.carbon b/toolchain/parse/testdata/generics/deduced_params/fail_no_parens.carbon index d4e34b20531c..62598f580722 100644 --- a/toolchain/parse/testdata/generics/deduced_params/fail_no_parens.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/fail_no_parens.carbon @@ -26,6 +26,7 @@ interface Bar[a: i32] {} // CHECK:STDOUT: - filename: fail_no_parens.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/deduced_params/one.carbon b/toolchain/parse/testdata/generics/deduced_params/one.carbon index 5de55bede627..fb57825f2eb4 100644 --- a/toolchain/parse/testdata/generics/deduced_params/one.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/one.carbon @@ -10,6 +10,7 @@ interface Bar[a: i32]() {} // CHECK:STDOUT: - filename: one.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/deduced_params/one_suffix_comma.carbon b/toolchain/parse/testdata/generics/deduced_params/one_suffix_comma.carbon index c53c1a122a30..d18eb7750c06 100644 --- a/toolchain/parse/testdata/generics/deduced_params/one_suffix_comma.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/one_suffix_comma.carbon @@ -10,6 +10,7 @@ interface Bar[a: i32,]() {} // CHECK:STDOUT: - filename: one_suffix_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/deduced_params/six.carbon b/toolchain/parse/testdata/generics/deduced_params/six.carbon index 3ee537e95677..0481f1f04226 100644 --- a/toolchain/parse/testdata/generics/deduced_params/six.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/six.carbon @@ -10,6 +10,7 @@ interface Bar[a: i32, b: i32, c: i32, d: i32, e: i32, f: i32]() {} // CHECK:STDOUT: - filename: six.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/deduced_params/two.carbon b/toolchain/parse/testdata/generics/deduced_params/two.carbon index 32c045528eda..f94ab44b458d 100644 --- a/toolchain/parse/testdata/generics/deduced_params/two.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/two.carbon @@ -10,6 +10,7 @@ interface Bar[a: i32, b: i32]() {} // CHECK:STDOUT: - filename: two.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/deduced_params/two_suffix_comma.carbon b/toolchain/parse/testdata/generics/deduced_params/two_suffix_comma.carbon index d205185f9b04..5cf863d7f937 100644 --- a/toolchain/parse/testdata/generics/deduced_params/two_suffix_comma.carbon +++ b/toolchain/parse/testdata/generics/deduced_params/two_suffix_comma.carbon @@ -10,6 +10,7 @@ interface Bar[a: i32, b: i32,]() {} // CHECK:STDOUT: - filename: two_suffix_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'DeducedParameterListStart', text: '['}, diff --git a/toolchain/parse/testdata/generics/generic_params/basic.carbon b/toolchain/parse/testdata/generics/generic_params/basic.carbon index 1247199833e5..cba6d89edf90 100644 --- a/toolchain/parse/testdata/generics/generic_params/basic.carbon +++ b/toolchain/parse/testdata/generics/generic_params/basic.carbon @@ -8,6 +8,7 @@ fn foo(a:! i32); // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/generic_params/template.carbon b/toolchain/parse/testdata/generics/generic_params/template.carbon index ae09e77ce9ae..2f0d50614ce4 100644 --- a/toolchain/parse/testdata/generics/generic_params/template.carbon +++ b/toolchain/parse/testdata/generics/generic_params/template.carbon @@ -8,6 +8,7 @@ fn foo(template a:! i32); // CHECK:STDOUT: - filename: template.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/generic_params/template_addr.carbon b/toolchain/parse/testdata/generics/generic_params/template_addr.carbon index 23054f5e5dac..67c41159067d 100644 --- a/toolchain/parse/testdata/generics/generic_params/template_addr.carbon +++ b/toolchain/parse/testdata/generics/generic_params/template_addr.carbon @@ -8,6 +8,7 @@ fn foo(template addr a:! i32); // CHECK:STDOUT: - filename: template_addr.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/interface/basic.carbon b/toolchain/parse/testdata/generics/interface/basic.carbon index 16b439bfd929..b467df71a7cb 100644 --- a/toolchain/parse/testdata/generics/interface/basic.carbon +++ b/toolchain/parse/testdata/generics/interface/basic.carbon @@ -11,6 +11,7 @@ interface Foo { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/declaration.carbon b/toolchain/parse/testdata/generics/interface/declaration.carbon index 6f7a8131af99..244a087d44a1 100644 --- a/toolchain/parse/testdata/generics/interface/declaration.carbon +++ b/toolchain/parse/testdata/generics/interface/declaration.carbon @@ -9,6 +9,7 @@ interface Foo { // CHECK:STDOUT: - filename: declaration.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/empty_body.carbon b/toolchain/parse/testdata/generics/interface/empty_body.carbon index f78e6f408403..2a7074ef5f62 100644 --- a/toolchain/parse/testdata/generics/interface/empty_body.carbon +++ b/toolchain/parse/testdata/generics/interface/empty_body.carbon @@ -8,6 +8,7 @@ interface Foo { // CHECK:STDOUT: - filename: empty_body.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/fail_missing_name.carbon b/toolchain/parse/testdata/generics/interface/fail_missing_name.carbon index 4dd9609d5cc8..430c527297bc 100644 --- a/toolchain/parse/testdata/generics/interface/fail_missing_name.carbon +++ b/toolchain/parse/testdata/generics/interface/fail_missing_name.carbon @@ -12,6 +12,7 @@ interface { // CHECK:STDOUT: - filename: fail_missing_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '{'}, // CHECK:STDOUT: {kind: 'InterfaceDeclaration', text: 'interface', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/fail_missing_open_curly.carbon b/toolchain/parse/testdata/generics/interface/fail_missing_open_curly.carbon index 3784744601c3..00caa8c66d14 100644 --- a/toolchain/parse/testdata/generics/interface/fail_missing_open_curly.carbon +++ b/toolchain/parse/testdata/generics/interface/fail_missing_open_curly.carbon @@ -11,11 +11,12 @@ interface Bar Baz {} interface Foo -// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+12]]:21: ERROR: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition. +// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+13]]:21: ERROR: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition. // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDOUT: - filename: fail_missing_open_curly.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Bar'}, // CHECK:STDOUT: {kind: 'InterfaceDeclaration', text: 'interface', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/fail_no_impl_allowed.carbon b/toolchain/parse/testdata/generics/interface/fail_no_impl_allowed.carbon index 5dc668124327..b75a5d2f40ce 100644 --- a/toolchain/parse/testdata/generics/interface/fail_no_impl_allowed.carbon +++ b/toolchain/parse/testdata/generics/interface/fail_no_impl_allowed.carbon @@ -15,6 +15,7 @@ interface Foo { // CHECK:STDOUT: - filename: fail_no_impl_allowed.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon b/toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon index 9fc0c1af1314..1dcf49d1b12d 100644 --- a/toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon +++ b/toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon @@ -18,6 +18,7 @@ interface Foo { // CHECK:STDOUT: - filename: fail_self_param_syntax.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/non_instance_fn.carbon b/toolchain/parse/testdata/generics/interface/non_instance_fn.carbon index 9a4e03b04631..5b965c5edd18 100644 --- a/toolchain/parse/testdata/generics/interface/non_instance_fn.carbon +++ b/toolchain/parse/testdata/generics/interface/non_instance_fn.carbon @@ -10,6 +10,7 @@ interface Foo { // CHECK:STDOUT: - filename: non_instance_fn.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/interface/self_pointer.carbon b/toolchain/parse/testdata/generics/interface/self_pointer.carbon index 072230332278..df3e0409d1d0 100644 --- a/toolchain/parse/testdata/generics/interface/self_pointer.carbon +++ b/toolchain/parse/testdata/generics/interface/self_pointer.carbon @@ -11,6 +11,7 @@ interface Foo { // CHECK:STDOUT: - filename: self_pointer.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'InterfaceIntroducer', text: 'interface'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'InterfaceDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/named_constraint/basic.carbon b/toolchain/parse/testdata/generics/named_constraint/basic.carbon index 9f2c9b937aec..adb2ef1ee930 100644 --- a/toolchain/parse/testdata/generics/named_constraint/basic.carbon +++ b/toolchain/parse/testdata/generics/named_constraint/basic.carbon @@ -10,6 +10,7 @@ constraint Foo { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamedConstraintIntroducer', text: 'constraint'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'NamedConstraintDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/named_constraint/fail_no_impl_allowed.carbon b/toolchain/parse/testdata/generics/named_constraint/fail_no_impl_allowed.carbon index e11058bced51..a4c0835a066a 100644 --- a/toolchain/parse/testdata/generics/named_constraint/fail_no_impl_allowed.carbon +++ b/toolchain/parse/testdata/generics/named_constraint/fail_no_impl_allowed.carbon @@ -13,6 +13,7 @@ constraint Foo { // CHECK:STDOUT: - filename: fail_no_impl_allowed.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamedConstraintIntroducer', text: 'constraint'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'NamedConstraintDefinitionStart', text: '{', subtree_size: 3}, diff --git a/toolchain/parse/testdata/generics/params/empty.carbon b/toolchain/parse/testdata/generics/params/empty.carbon index bc4bc10941e1..cb9eacea43ae 100644 --- a/toolchain/parse/testdata/generics/params/empty.carbon +++ b/toolchain/parse/testdata/generics/params/empty.carbon @@ -10,6 +10,7 @@ interface Bar() {} // CHECK:STDOUT: - filename: empty.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/params/one.carbon b/toolchain/parse/testdata/generics/params/one.carbon index 778711ae3ec1..63a5c0058b0d 100644 --- a/toolchain/parse/testdata/generics/params/one.carbon +++ b/toolchain/parse/testdata/generics/params/one.carbon @@ -10,6 +10,7 @@ interface Bar(a: i32) {} // CHECK:STDOUT: - filename: one.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/params/one_suffix_comma.carbon b/toolchain/parse/testdata/generics/params/one_suffix_comma.carbon index a9930e6e110d..da725912cd91 100644 --- a/toolchain/parse/testdata/generics/params/one_suffix_comma.carbon +++ b/toolchain/parse/testdata/generics/params/one_suffix_comma.carbon @@ -10,6 +10,7 @@ interface Bar(a: i32,) {} // CHECK:STDOUT: - filename: one_suffix_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/params/six.carbon b/toolchain/parse/testdata/generics/params/six.carbon index bfaac653bbfc..8b9c89611692 100644 --- a/toolchain/parse/testdata/generics/params/six.carbon +++ b/toolchain/parse/testdata/generics/params/six.carbon @@ -10,6 +10,7 @@ interface Bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {} // CHECK:STDOUT: - filename: six.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/params/two.carbon b/toolchain/parse/testdata/generics/params/two.carbon index 25143d11b93f..9b5964a4b3e4 100644 --- a/toolchain/parse/testdata/generics/params/two.carbon +++ b/toolchain/parse/testdata/generics/params/two.carbon @@ -10,6 +10,7 @@ interface Bar(a: i32, b: i32) {} // CHECK:STDOUT: - filename: two.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/generics/params/two_suffix_comma.carbon b/toolchain/parse/testdata/generics/params/two_suffix_comma.carbon index ad1475792e60..e81fcff6bdb3 100644 --- a/toolchain/parse/testdata/generics/params/two_suffix_comma.carbon +++ b/toolchain/parse/testdata/generics/params/two_suffix_comma.carbon @@ -10,6 +10,7 @@ interface Bar(a: i32, b: i32,) {} // CHECK:STDOUT: - filename: two_suffix_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'ClassIntroducer', text: 'class'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/basic.carbon b/toolchain/parse/testdata/if/basic.carbon index 552e4b9095e4..93eb81b93868 100644 --- a/toolchain/parse/testdata/if/basic.carbon +++ b/toolchain/parse/testdata/if/basic.carbon @@ -16,6 +16,7 @@ fn F() { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/else.carbon b/toolchain/parse/testdata/if/else.carbon index 9aadcc472f92..02c8c2afcae2 100644 --- a/toolchain/parse/testdata/if/else.carbon +++ b/toolchain/parse/testdata/if/else.carbon @@ -21,6 +21,7 @@ fn F() { // CHECK:STDOUT: - filename: else.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/fail_else_unbraced.carbon b/toolchain/parse/testdata/if/fail_else_unbraced.carbon index eb6d3c217aef..6e4c3fa6f4e3 100644 --- a/toolchain/parse/testdata/if/fail_else_unbraced.carbon +++ b/toolchain/parse/testdata/if/fail_else_unbraced.carbon @@ -31,6 +31,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_else_unbraced.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/fail_errors.carbon b/toolchain/parse/testdata/if/fail_errors.carbon index 00cd51beff0a..2030f1374a45 100644 --- a/toolchain/parse/testdata/if/fail_errors.carbon +++ b/toolchain/parse/testdata/if/fail_errors.carbon @@ -28,6 +28,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_errors.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/fail_missing_cond.carbon b/toolchain/parse/testdata/if/fail_missing_cond.carbon index ca66e43723a5..692ce9ba7049 100644 --- a/toolchain/parse/testdata/if/fail_missing_cond.carbon +++ b/toolchain/parse/testdata/if/fail_missing_cond.carbon @@ -14,6 +14,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_missing_cond.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/fail_square_brackets.carbon b/toolchain/parse/testdata/if/fail_square_brackets.carbon index c0705ffe4026..8c86a66d4db7 100644 --- a/toolchain/parse/testdata/if/fail_square_brackets.carbon +++ b/toolchain/parse/testdata/if/fail_square_brackets.carbon @@ -19,6 +19,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_square_brackets.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if/fail_unbraced.carbon b/toolchain/parse/testdata/if/fail_unbraced.carbon index 4e31e2ddd340..cf344b97b741 100644 --- a/toolchain/parse/testdata/if/fail_unbraced.carbon +++ b/toolchain/parse/testdata/if/fail_unbraced.carbon @@ -23,6 +23,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_unbraced.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/basic.carbon b/toolchain/parse/testdata/if_expression/basic.carbon index d02da5d26819..a7520a7ce6c8 100644 --- a/toolchain/parse/testdata/if_expression/basic.carbon +++ b/toolchain/parse/testdata/if_expression/basic.carbon @@ -10,6 +10,7 @@ fn F(b: bool, x: i32, y: i32) -> bool { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/fail_condition_missing.carbon b/toolchain/parse/testdata/if_expression/fail_condition_missing.carbon index 8a750f28090f..747bdd00c196 100644 --- a/toolchain/parse/testdata/if_expression/fail_condition_missing.carbon +++ b/toolchain/parse/testdata/if_expression/fail_condition_missing.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_condition_missing.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/fail_else_expr_missing.carbon b/toolchain/parse/testdata/if_expression/fail_else_expr_missing.carbon index 07371a3ef1c3..b84b7d556e3a 100644 --- a/toolchain/parse/testdata/if_expression/fail_else_expr_missing.carbon +++ b/toolchain/parse/testdata/if_expression/fail_else_expr_missing.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_else_expr_missing.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/fail_else_missing.carbon b/toolchain/parse/testdata/if_expression/fail_else_missing.carbon index a3489c9a0dbf..d824e039dc6c 100644 --- a/toolchain/parse/testdata/if_expression/fail_else_missing.carbon +++ b/toolchain/parse/testdata/if_expression/fail_else_missing.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_else_missing.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/fail_then_expr_missing.carbon b/toolchain/parse/testdata/if_expression/fail_then_expr_missing.carbon index d87728db295c..7f9c8b5bd9a1 100644 --- a/toolchain/parse/testdata/if_expression/fail_then_expr_missing.carbon +++ b/toolchain/parse/testdata/if_expression/fail_then_expr_missing.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_then_expr_missing.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/fail_then_missing.carbon b/toolchain/parse/testdata/if_expression/fail_then_missing.carbon index 39a662478585..4a45533f1be9 100644 --- a/toolchain/parse/testdata/if_expression/fail_then_missing.carbon +++ b/toolchain/parse/testdata/if_expression/fail_then_missing.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_then_missing.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/fail_top_level_if.carbon b/toolchain/parse/testdata/if_expression/fail_top_level_if.carbon index e286739a9d20..ba5a33c95d1a 100644 --- a/toolchain/parse/testdata/if_expression/fail_top_level_if.carbon +++ b/toolchain/parse/testdata/if_expression/fail_top_level_if.carbon @@ -19,6 +19,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_top_level_if.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/if_expression/in_type.carbon b/toolchain/parse/testdata/if_expression/in_type.carbon index 05d7e2aa128c..0e30e3343dc5 100644 --- a/toolchain/parse/testdata/if_expression/in_type.carbon +++ b/toolchain/parse/testdata/if_expression/in_type.carbon @@ -12,6 +12,7 @@ fn F() -> if true then i32 else i32* { // CHECK:STDOUT: - filename: in_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/if_expression/precedence.carbon b/toolchain/parse/testdata/if_expression/precedence.carbon index d4757ad5bb69..46e3ad852311 100644 --- a/toolchain/parse/testdata/if_expression/precedence.carbon +++ b/toolchain/parse/testdata/if_expression/precedence.carbon @@ -10,6 +10,7 @@ fn F(b: bool) -> bool { // CHECK:STDOUT: - filename: precedence.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/index/assign_to_var.carbon b/toolchain/parse/testdata/index/assign_to_var.carbon index 2d16dcbaf153..a95cb090f44c 100644 --- a/toolchain/parse/testdata/index/assign_to_var.carbon +++ b/toolchain/parse/testdata/index/assign_to_var.carbon @@ -8,6 +8,7 @@ var v: i32 = t[0]; // CHECK:STDOUT: - filename: assign_to_var.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/index/fail_empty_expr.carbon b/toolchain/parse/testdata/index/fail_empty_expr.carbon index c7d2822227d7..0d31c1654147 100644 --- a/toolchain/parse/testdata/index/fail_empty_expr.carbon +++ b/toolchain/parse/testdata/index/fail_empty_expr.carbon @@ -11,6 +11,7 @@ var v: i32 = t[]; // CHECK:STDOUT: - filename: fail_empty_expr.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/index/fail_malformed_expr.carbon b/toolchain/parse/testdata/index/fail_malformed_expr.carbon index 0e331bed180f..bfd3e7017aa6 100644 --- a/toolchain/parse/testdata/index/fail_malformed_expr.carbon +++ b/toolchain/parse/testdata/index/fail_malformed_expr.carbon @@ -11,6 +11,7 @@ var v: i32 = t[0,]; // CHECK:STDOUT: - filename: fail_malformed_expr.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/namespace/basic.carbon b/toolchain/parse/testdata/namespace/basic.carbon index 85ea006e342b..669566d07149 100644 --- a/toolchain/parse/testdata/namespace/basic.carbon +++ b/toolchain/parse/testdata/namespace/basic.carbon @@ -12,6 +12,7 @@ fn Bar() { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'Namespace', text: ';', subtree_size: 3}, diff --git a/toolchain/parse/testdata/namespace/fail_args.carbon b/toolchain/parse/testdata/namespace/fail_args.carbon index 7761cb9ac3cd..18921301aff8 100644 --- a/toolchain/parse/testdata/namespace/fail_args.carbon +++ b/toolchain/parse/testdata/namespace/fail_args.carbon @@ -11,6 +11,7 @@ namespace Foo(); // CHECK:STDOUT: - filename: fail_args.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'Namespace', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/namespace/fail_arrow.carbon b/toolchain/parse/testdata/namespace/fail_arrow.carbon index 4a975d1630ae..ac4ff0f7b494 100644 --- a/toolchain/parse/testdata/namespace/fail_arrow.carbon +++ b/toolchain/parse/testdata/namespace/fail_arrow.carbon @@ -13,6 +13,7 @@ fn Foo->Bar() {} // CHECK:STDOUT: - filename: fail_arrow.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'Namespace', text: ';', subtree_size: 3}, diff --git a/toolchain/parse/testdata/namespace/fail_incomplete_name.carbon b/toolchain/parse/testdata/namespace/fail_incomplete_name.carbon index 1402b8b824eb..0611c683b325 100644 --- a/toolchain/parse/testdata/namespace/fail_incomplete_name.carbon +++ b/toolchain/parse/testdata/namespace/fail_incomplete_name.carbon @@ -11,6 +11,7 @@ namespace Foo.; // CHECK:STDOUT: - filename: fail_incomplete_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'NameExpression', text: 'Foo'}, // CHECK:STDOUT: {kind: 'Name', text: ';', has_error: yes}, diff --git a/toolchain/parse/testdata/namespace/fail_no_name.carbon b/toolchain/parse/testdata/namespace/fail_no_name.carbon index f96aa51c3289..a0abef76b692 100644 --- a/toolchain/parse/testdata/namespace/fail_no_name.carbon +++ b/toolchain/parse/testdata/namespace/fail_no_name.carbon @@ -11,6 +11,7 @@ namespace; // CHECK:STDOUT: - filename: fail_no_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';'}, // CHECK:STDOUT: {kind: 'Namespace', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/namespace/nested.carbon b/toolchain/parse/testdata/namespace/nested.carbon index 106897cd5950..22eb30a83449 100644 --- a/toolchain/parse/testdata/namespace/nested.carbon +++ b/toolchain/parse/testdata/namespace/nested.carbon @@ -13,6 +13,7 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: - filename: nested.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'Namespace', text: ';', subtree_size: 3}, diff --git a/toolchain/parse/testdata/operators/assign.carbon b/toolchain/parse/testdata/operators/assign.carbon index 1faf82007ca3..4226aa142616 100644 --- a/toolchain/parse/testdata/operators/assign.carbon +++ b/toolchain/parse/testdata/operators/assign.carbon @@ -24,6 +24,7 @@ fn F() { // CHECK:STDOUT: - filename: assign.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/associative.carbon b/toolchain/parse/testdata/operators/associative.carbon index ca5d0320cf86..f5b7817eb4f1 100644 --- a/toolchain/parse/testdata/operators/associative.carbon +++ b/toolchain/parse/testdata/operators/associative.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: associative.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_chained_assign.carbon b/toolchain/parse/testdata/operators/fail_chained_assign.carbon index d568362a8f2b..545c99cc237f 100644 --- a/toolchain/parse/testdata/operators/fail_chained_assign.carbon +++ b/toolchain/parse/testdata/operators/fail_chained_assign.carbon @@ -17,6 +17,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_chained_assign.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon b/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon index f319a41e556c..d3efcea11e08 100644 --- a/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon +++ b/toolchain/parse/testdata/operators/fail_infix_uneven_space_after.carbon @@ -13,6 +13,7 @@ var n: i8 = n* n; // CHECK:STDOUT: - filename: fail_infix_uneven_space_after.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/fail_invalid_infix.carbon b/toolchain/parse/testdata/operators/fail_invalid_infix.carbon index 73230d21c14a..40a018ce81be 100644 --- a/toolchain/parse/testdata/operators/fail_invalid_infix.carbon +++ b/toolchain/parse/testdata/operators/fail_invalid_infix.carbon @@ -22,6 +22,7 @@ var c: i32 = == ; // CHECK:STDOUT: - filename: fail_invalid_infix.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'a'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/operators/fail_postincrement.carbon b/toolchain/parse/testdata/operators/fail_postincrement.carbon index 3dd281bf64ac..1a2ca3ccf668 100644 --- a/toolchain/parse/testdata/operators/fail_postincrement.carbon +++ b/toolchain/parse/testdata/operators/fail_postincrement.carbon @@ -19,6 +19,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_postincrement.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_precedence_and_or.carbon b/toolchain/parse/testdata/operators/fail_precedence_and_or.carbon index b15e8533a0ee..4e5e23b699a5 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_and_or.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_and_or.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_precedence_and_or.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_precedence_as.carbon b/toolchain/parse/testdata/operators/fail_precedence_as.carbon index 3bf2349e064a..925582174214 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_as.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_as.carbon @@ -24,6 +24,7 @@ fn F(n: i32) { // CHECK:STDOUT: - filename: fail_precedence_as.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_precedence_assign.carbon b/toolchain/parse/testdata/operators/fail_precedence_assign.carbon index 51a7740a0bcf..bfbb1a28133f 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_assign.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_assign.carbon @@ -31,6 +31,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_precedence_assign.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_precedence_or_and.carbon b/toolchain/parse/testdata/operators/fail_precedence_or_and.carbon index 1ba01ac99bbe..747266962b2a 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_or_and.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_or_and.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_precedence_or_and.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fail_precedence_star_minus.carbon b/toolchain/parse/testdata/operators/fail_precedence_star_minus.carbon index f270aebecc9e..fd78090fca54 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_star_minus.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_star_minus.carbon @@ -11,6 +11,7 @@ var n: i8 = n* -n; // CHECK:STDOUT: - filename: fail_precedence_star_minus.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/fail_precedence_star_star.carbon b/toolchain/parse/testdata/operators/fail_precedence_star_star.carbon index 782bb4e51195..18c33cc111c3 100644 --- a/toolchain/parse/testdata/operators/fail_precedence_star_star.carbon +++ b/toolchain/parse/testdata/operators/fail_precedence_star_star.carbon @@ -11,6 +11,7 @@ var n: i8 = n* *p; // CHECK:STDOUT: - filename: fail_precedence_star_star.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon b/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon index ab9395702ab6..dad2aba8cfc1 100644 --- a/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon +++ b/toolchain/parse/testdata/operators/fail_star_star_no_space.carbon @@ -15,6 +15,7 @@ var n: i8 = n**p; // CHECK:STDOUT: - filename: fail_star_star_no_space.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/fail_variety.carbon b/toolchain/parse/testdata/operators/fail_variety.carbon index e0fb0875dfa0..baf83e22e41f 100644 --- a/toolchain/parse/testdata/operators/fail_variety.carbon +++ b/toolchain/parse/testdata/operators/fail_variety.carbon @@ -25,6 +25,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_variety.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fixity_in_call.carbon b/toolchain/parse/testdata/operators/fixity_in_call.carbon index bd6212ac1e38..a809bb4a9c34 100644 --- a/toolchain/parse/testdata/operators/fixity_in_call.carbon +++ b/toolchain/parse/testdata/operators/fixity_in_call.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: fixity_in_call.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fixity_in_params.carbon b/toolchain/parse/testdata/operators/fixity_in_params.carbon index dd5c0a4e7e0f..b8f0ed15e486 100644 --- a/toolchain/parse/testdata/operators/fixity_in_params.carbon +++ b/toolchain/parse/testdata/operators/fixity_in_params.carbon @@ -9,6 +9,7 @@ fn F(p: i32*, n: i32) { // CHECK:STDOUT: - filename: fixity_in_params.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fixity_in_var.carbon b/toolchain/parse/testdata/operators/fixity_in_var.carbon index 8c8bdad1eec2..a19a1f75bc40 100644 --- a/toolchain/parse/testdata/operators/fixity_in_var.carbon +++ b/toolchain/parse/testdata/operators/fixity_in_var.carbon @@ -11,6 +11,7 @@ fn F() { // CHECK:STDOUT: - filename: fixity_in_var.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/fixity_with_assign.carbon b/toolchain/parse/testdata/operators/fixity_with_assign.carbon index 2ebf0b8daf91..33b331034a95 100644 --- a/toolchain/parse/testdata/operators/fixity_with_assign.carbon +++ b/toolchain/parse/testdata/operators/fixity_with_assign.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fixity_with_assign.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/infix.carbon b/toolchain/parse/testdata/operators/infix.carbon index 67c899b1ad6c..0c92e7f7bafb 100644 --- a/toolchain/parse/testdata/operators/infix.carbon +++ b/toolchain/parse/testdata/operators/infix.carbon @@ -8,6 +8,7 @@ var n: i8 = n * n; // CHECK:STDOUT: - filename: infix.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/infix_no_space.carbon b/toolchain/parse/testdata/operators/infix_no_space.carbon index 9f73187ebf9a..a938a3a0a5d2 100644 --- a/toolchain/parse/testdata/operators/infix_no_space.carbon +++ b/toolchain/parse/testdata/operators/infix_no_space.carbon @@ -8,6 +8,7 @@ var n: i8 = n*n; // CHECK:STDOUT: - filename: infix_no_space.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/infix_with_paren_after.carbon b/toolchain/parse/testdata/operators/infix_with_paren_after.carbon index d58fe256c366..8ae0533605d1 100644 --- a/toolchain/parse/testdata/operators/infix_with_paren_after.carbon +++ b/toolchain/parse/testdata/operators/infix_with_paren_after.carbon @@ -8,6 +8,7 @@ var n: i8 = 3*(n); // CHECK:STDOUT: - filename: infix_with_paren_after.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/infix_with_paren_before.carbon b/toolchain/parse/testdata/operators/infix_with_paren_before.carbon index c8b13feaf080..d2bb4153c62b 100644 --- a/toolchain/parse/testdata/operators/infix_with_paren_before.carbon +++ b/toolchain/parse/testdata/operators/infix_with_paren_before.carbon @@ -8,6 +8,7 @@ var n: i8 = (n)*3; // CHECK:STDOUT: - filename: infix_with_paren_before.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/postfix.carbon b/toolchain/parse/testdata/operators/postfix.carbon index c5b11562964e..50d0c260a2e6 100644 --- a/toolchain/parse/testdata/operators/postfix.carbon +++ b/toolchain/parse/testdata/operators/postfix.carbon @@ -8,6 +8,7 @@ var v: type = i8*; // CHECK:STDOUT: - filename: postfix.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'type'}, diff --git a/toolchain/parse/testdata/operators/postfix_repeat.carbon b/toolchain/parse/testdata/operators/postfix_repeat.carbon index c5f9399ab4fd..0f6a2ab7e02b 100644 --- a/toolchain/parse/testdata/operators/postfix_repeat.carbon +++ b/toolchain/parse/testdata/operators/postfix_repeat.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: postfix_repeat.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/postfix_space_after_op.carbon b/toolchain/parse/testdata/operators/postfix_space_after_op.carbon index 04d572e4a9f1..7ad3e1949f5c 100644 --- a/toolchain/parse/testdata/operators/postfix_space_after_op.carbon +++ b/toolchain/parse/testdata/operators/postfix_space_after_op.carbon @@ -8,6 +8,7 @@ var v: type = i8* ; // CHECK:STDOUT: - filename: postfix_space_after_op.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'type'}, diff --git a/toolchain/parse/testdata/operators/precedence_as.carbon b/toolchain/parse/testdata/operators/precedence_as.carbon index ede8e9047e41..e3a49297a746 100644 --- a/toolchain/parse/testdata/operators/precedence_as.carbon +++ b/toolchain/parse/testdata/operators/precedence_as.carbon @@ -15,6 +15,7 @@ fn F(n: i32) { // CHECK:STDOUT: - filename: precedence_as.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/precedence_assign.carbon b/toolchain/parse/testdata/operators/precedence_assign.carbon index cfc28f74edde..8d59aebacb9a 100644 --- a/toolchain/parse/testdata/operators/precedence_assign.carbon +++ b/toolchain/parse/testdata/operators/precedence_assign.carbon @@ -15,6 +15,7 @@ fn F(c: bool) { // CHECK:STDOUT: - filename: precedence_assign.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/precedence_not.carbon b/toolchain/parse/testdata/operators/precedence_not.carbon index 15fc26c6e7e1..df58931eb217 100644 --- a/toolchain/parse/testdata/operators/precedence_not.carbon +++ b/toolchain/parse/testdata/operators/precedence_not.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: precedence_not.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/precedence_unary.carbon b/toolchain/parse/testdata/operators/precedence_unary.carbon index 87b71344e39f..93905281625b 100644 --- a/toolchain/parse/testdata/operators/precedence_unary.carbon +++ b/toolchain/parse/testdata/operators/precedence_unary.carbon @@ -15,6 +15,7 @@ fn F(p: i32*) { // CHECK:STDOUT: - filename: precedence_unary.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/prefix.carbon b/toolchain/parse/testdata/operators/prefix.carbon index 87fa729c6d0c..ab881e31c133 100644 --- a/toolchain/parse/testdata/operators/prefix.carbon +++ b/toolchain/parse/testdata/operators/prefix.carbon @@ -9,6 +9,7 @@ var b: bool = not true; // CHECK:STDOUT: - filename: prefix.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/prefix_no_space.carbon b/toolchain/parse/testdata/operators/prefix_no_space.carbon index 7909b13a9f56..31cc5d5165f7 100644 --- a/toolchain/parse/testdata/operators/prefix_no_space.carbon +++ b/toolchain/parse/testdata/operators/prefix_no_space.carbon @@ -9,6 +9,7 @@ var n: i8 =-n; // CHECK:STDOUT: - filename: prefix_no_space.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/prefix_repeat.carbon b/toolchain/parse/testdata/operators/prefix_repeat.carbon index c8e1e49e544f..f1bd59c907c7 100644 --- a/toolchain/parse/testdata/operators/prefix_repeat.carbon +++ b/toolchain/parse/testdata/operators/prefix_repeat.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: prefix_repeat.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/recover_infix_uneven_space_before.carbon b/toolchain/parse/testdata/operators/recover_infix_uneven_space_before.carbon index 477c3daf0e03..869fdb5f43a8 100644 --- a/toolchain/parse/testdata/operators/recover_infix_uneven_space_before.carbon +++ b/toolchain/parse/testdata/operators/recover_infix_uneven_space_before.carbon @@ -11,6 +11,7 @@ var n: i8 = n *n; // CHECK:STDOUT: - filename: recover_infix_uneven_space_before.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/recover_postfix_space.carbon b/toolchain/parse/testdata/operators/recover_postfix_space.carbon index 76e846a1b424..55805dc61ab4 100644 --- a/toolchain/parse/testdata/operators/recover_postfix_space.carbon +++ b/toolchain/parse/testdata/operators/recover_postfix_space.carbon @@ -11,6 +11,7 @@ var v: type = i8 *; // CHECK:STDOUT: - filename: recover_postfix_space.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'type'}, diff --git a/toolchain/parse/testdata/operators/recover_postfix_space_before_comma.carbon b/toolchain/parse/testdata/operators/recover_postfix_space_before_comma.carbon index 8267a7a4db5e..1dd3b7fc6ee9 100644 --- a/toolchain/parse/testdata/operators/recover_postfix_space_before_comma.carbon +++ b/toolchain/parse/testdata/operators/recover_postfix_space_before_comma.carbon @@ -11,6 +11,7 @@ var n: i8 = F(i8 *, 0); // CHECK:STDOUT: - filename: recover_postfix_space_before_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/recover_postfix_space_in_call.carbon b/toolchain/parse/testdata/operators/recover_postfix_space_in_call.carbon index 0bcafb58b501..375af15ad3ee 100644 --- a/toolchain/parse/testdata/operators/recover_postfix_space_in_call.carbon +++ b/toolchain/parse/testdata/operators/recover_postfix_space_in_call.carbon @@ -11,6 +11,7 @@ var n: i8 = F(i8 *); // CHECK:STDOUT: - filename: recover_postfix_space_in_call.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/recover_postfix_space_surrounding.carbon b/toolchain/parse/testdata/operators/recover_postfix_space_surrounding.carbon index e5364f31cdf1..c03dc475c241 100644 --- a/toolchain/parse/testdata/operators/recover_postfix_space_surrounding.carbon +++ b/toolchain/parse/testdata/operators/recover_postfix_space_surrounding.carbon @@ -11,6 +11,7 @@ var v: type = i8 * ; // CHECK:STDOUT: - filename: recover_postfix_space_surrounding.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'type'}, diff --git a/toolchain/parse/testdata/operators/recover_prefix_repeat.carbon b/toolchain/parse/testdata/operators/recover_prefix_repeat.carbon index 347a7cb84ff0..c2a941bd4ecb 100644 --- a/toolchain/parse/testdata/operators/recover_prefix_repeat.carbon +++ b/toolchain/parse/testdata/operators/recover_prefix_repeat.carbon @@ -12,6 +12,7 @@ fn F() -> const const i32* { // CHECK:STDOUT: - filename: recover_prefix_repeat.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/operators/recover_prefix_space.carbon b/toolchain/parse/testdata/operators/recover_prefix_space.carbon index d8f38ecd8b27..77f3a1d1ff6d 100644 --- a/toolchain/parse/testdata/operators/recover_prefix_space.carbon +++ b/toolchain/parse/testdata/operators/recover_prefix_space.carbon @@ -11,6 +11,7 @@ var n: i8 = - n; // CHECK:STDOUT: - filename: recover_prefix_space.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/operators/recover_prefix_uneven_space_with_assign.carbon b/toolchain/parse/testdata/operators/recover_prefix_uneven_space_with_assign.carbon index 2943e55e9acd..27b41d5f2cfc 100644 --- a/toolchain/parse/testdata/operators/recover_prefix_uneven_space_with_assign.carbon +++ b/toolchain/parse/testdata/operators/recover_prefix_uneven_space_with_assign.carbon @@ -11,6 +11,7 @@ var n: i8 =- n; // CHECK:STDOUT: - filename: recover_prefix_uneven_space_with_assign.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'n'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i8'}, diff --git a/toolchain/parse/testdata/package/api.carbon b/toolchain/parse/testdata/package/api.carbon index 4f4a60fd6fd1..3ac51c66dbdc 100644 --- a/toolchain/parse/testdata/package/api.carbon +++ b/toolchain/parse/testdata/package/api.carbon @@ -8,6 +8,7 @@ package Geometry api; // CHECK:STDOUT: - filename: api.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'PackageApi', text: 'api'}, diff --git a/toolchain/parse/testdata/package/api_library.carbon b/toolchain/parse/testdata/package/api_library.carbon index e054e5952026..e5f746307a9e 100644 --- a/toolchain/parse/testdata/package/api_library.carbon +++ b/toolchain/parse/testdata/package/api_library.carbon @@ -8,6 +8,7 @@ package Geometry library "Shapes" api; // CHECK:STDOUT: - filename: api_library.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'Literal', text: '"Shapes"'}, diff --git a/toolchain/parse/testdata/package/fail_extra_string.carbon b/toolchain/parse/testdata/package/fail_extra_string.carbon index 4ead3e20bb8e..d3dab82d6aa6 100644 --- a/toolchain/parse/testdata/package/fail_extra_string.carbon +++ b/toolchain/parse/testdata/package/fail_extra_string.carbon @@ -11,6 +11,7 @@ package Foo library "bar" "baz"; // CHECK:STDOUT: - filename: fail_extra_string.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Foo'}, // CHECK:STDOUT: {kind: 'Literal', text: '"bar"'}, diff --git a/toolchain/parse/testdata/package/fail_library_is_identifier.carbon b/toolchain/parse/testdata/package/fail_library_is_identifier.carbon index 3e87f5ce572d..03f76bb14973 100644 --- a/toolchain/parse/testdata/package/fail_library_is_identifier.carbon +++ b/toolchain/parse/testdata/package/fail_library_is_identifier.carbon @@ -11,6 +11,7 @@ package Geometry library Shapes api; // CHECK:STDOUT: - filename: fail_library_is_identifier.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/package/fail_library_skips_name.carbon b/toolchain/parse/testdata/package/fail_library_skips_name.carbon index ef141c6d8811..f8b4f5275b4a 100644 --- a/toolchain/parse/testdata/package/fail_library_skips_name.carbon +++ b/toolchain/parse/testdata/package/fail_library_skips_name.carbon @@ -11,6 +11,7 @@ package library "Shapes" api; // CHECK:STDOUT: - filename: fail_library_skips_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 2}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, diff --git a/toolchain/parse/testdata/package/fail_name_is_keyword.carbon b/toolchain/parse/testdata/package/fail_name_is_keyword.carbon index 8d0388babc28..93730f2cf11d 100644 --- a/toolchain/parse/testdata/package/fail_name_is_keyword.carbon +++ b/toolchain/parse/testdata/package/fail_name_is_keyword.carbon @@ -11,6 +11,7 @@ package fn; // CHECK:STDOUT: - filename: fail_name_is_keyword.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 2}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, diff --git a/toolchain/parse/testdata/package/fail_no_name.carbon b/toolchain/parse/testdata/package/fail_no_name.carbon index 25100737d794..0f19b74952e4 100644 --- a/toolchain/parse/testdata/package/fail_no_name.carbon +++ b/toolchain/parse/testdata/package/fail_no_name.carbon @@ -11,6 +11,7 @@ package; // CHECK:STDOUT: - filename: fail_no_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 2}, // CHECK:STDOUT: {kind: 'FileEnd', text: ''}, diff --git a/toolchain/parse/testdata/package/fail_no_semi.carbon b/toolchain/parse/testdata/package/fail_no_semi.carbon index 0098048c070b..b9aee3f1bf26 100644 --- a/toolchain/parse/testdata/package/fail_no_semi.carbon +++ b/toolchain/parse/testdata/package/fail_no_semi.carbon @@ -6,11 +6,12 @@ package Geometry api -// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+10]]:21: ERROR: `package` declarations must end with a `;`. +// CHECK:STDERR: fail_no_semi.carbon:[[@LINE+11]]:21: ERROR: `package` declarations must end with a `;`. // CHECK:STDERR: // CHECK:STDOUT: ] // CHECK:STDERR: ^ // CHECK:STDOUT: - filename: fail_no_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'PackageApi', text: 'api'}, diff --git a/toolchain/parse/testdata/package/fail_no_type.carbon b/toolchain/parse/testdata/package/fail_no_type.carbon index de34fdcc36cc..9b549782c031 100644 --- a/toolchain/parse/testdata/package/fail_no_type.carbon +++ b/toolchain/parse/testdata/package/fail_no_type.carbon @@ -11,6 +11,7 @@ package Geometry; // CHECK:STDOUT: - filename: fail_no_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/package/fail_omit_library_keyword.carbon b/toolchain/parse/testdata/package/fail_omit_library_keyword.carbon index 794d1ce99d5f..744b5da749f8 100644 --- a/toolchain/parse/testdata/package/fail_omit_library_keyword.carbon +++ b/toolchain/parse/testdata/package/fail_omit_library_keyword.carbon @@ -11,6 +11,7 @@ package Geometry "Shapes" api; // CHECK:STDOUT: - filename: fail_omit_library_keyword.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'PackageDirective', text: ';', has_error: yes, subtree_size: 3}, diff --git a/toolchain/parse/testdata/package/impl.carbon b/toolchain/parse/testdata/package/impl.carbon index 3d91517df163..d840b5fadc05 100644 --- a/toolchain/parse/testdata/package/impl.carbon +++ b/toolchain/parse/testdata/package/impl.carbon @@ -8,6 +8,7 @@ package Geometry impl; // CHECK:STDOUT: - filename: impl.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'PackageImpl', text: 'impl'}, diff --git a/toolchain/parse/testdata/package/impl_library.carbon b/toolchain/parse/testdata/package/impl_library.carbon index 892487e045cb..25141406eaf4 100644 --- a/toolchain/parse/testdata/package/impl_library.carbon +++ b/toolchain/parse/testdata/package/impl_library.carbon @@ -8,6 +8,7 @@ package Geometry library "Shapes" impl; // CHECK:STDOUT: - filename: impl_library.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'PackageIntroducer', text: 'package'}, // CHECK:STDOUT: {kind: 'Name', text: 'Geometry'}, // CHECK:STDOUT: {kind: 'Literal', text: '"Shapes"'}, diff --git a/toolchain/parse/testdata/pointer/const_pointer.carbon b/toolchain/parse/testdata/pointer/const_pointer.carbon index e64611121cde..d1c61d308481 100644 --- a/toolchain/parse/testdata/pointer/const_pointer.carbon +++ b/toolchain/parse/testdata/pointer/const_pointer.carbon @@ -10,6 +10,7 @@ fn C() -> const (i32*) { return C(); } // CHECK:STDOUT: - filename: const_pointer.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'A'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/pointer/fail_pointer_type_in_expression.carbon b/toolchain/parse/testdata/pointer/fail_pointer_type_in_expression.carbon index 22fa1e5caf39..2ec14af476fc 100644 --- a/toolchain/parse/testdata/pointer/fail_pointer_type_in_expression.carbon +++ b/toolchain/parse/testdata/pointer/fail_pointer_type_in_expression.carbon @@ -34,6 +34,7 @@ fn H() -> i32 { // CHECK:STDOUT: - filename: fail_pointer_type_in_expression.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/pointer/pointer_type.carbon b/toolchain/parse/testdata/pointer/pointer_type.carbon index a9a11704227a..c7ac8f0ed9bb 100644 --- a/toolchain/parse/testdata/pointer/pointer_type.carbon +++ b/toolchain/parse/testdata/pointer/pointer_type.carbon @@ -12,6 +12,7 @@ var T: type = if true then i32* else f64*; // CHECK:STDOUT: - filename: pointer_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/pointer/pointer_value.carbon b/toolchain/parse/testdata/pointer/pointer_value.carbon index 3f53f8ab5dea..346564a0993b 100644 --- a/toolchain/parse/testdata/pointer/pointer_value.carbon +++ b/toolchain/parse/testdata/pointer/pointer_value.carbon @@ -13,6 +13,7 @@ fn F() -> i32 { // CHECK:STDOUT: - filename: pointer_value.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/return/basic.carbon b/toolchain/parse/testdata/return/basic.carbon index eba90c957207..8d49a95fcd9d 100644 --- a/toolchain/parse/testdata/return/basic.carbon +++ b/toolchain/parse/testdata/return/basic.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/return/expr.carbon b/toolchain/parse/testdata/return/expr.carbon index 0837f00a5195..b69759de45a4 100644 --- a/toolchain/parse/testdata/return/expr.carbon +++ b/toolchain/parse/testdata/return/expr.carbon @@ -10,6 +10,7 @@ fn F() { // CHECK:STDOUT: - filename: expr.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/return/fail_expr_no_semi.carbon b/toolchain/parse/testdata/return/fail_expr_no_semi.carbon index c0f0ab4afef6..a467bc6449ae 100644 --- a/toolchain/parse/testdata/return/fail_expr_no_semi.carbon +++ b/toolchain/parse/testdata/return/fail_expr_no_semi.carbon @@ -13,6 +13,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_expr_no_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/return/fail_no_semi.carbon b/toolchain/parse/testdata/return/fail_no_semi.carbon index 318260b798b3..a43d9e617f87 100644 --- a/toolchain/parse/testdata/return/fail_no_semi.carbon +++ b/toolchain/parse/testdata/return/fail_no_semi.carbon @@ -16,6 +16,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_no_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/struct/fail_comma_only.carbon b/toolchain/parse/testdata/struct/fail_comma_only.carbon index 69a1a7d21a1a..be0fba39135f 100644 --- a/toolchain/parse/testdata/struct/fail_comma_only.carbon +++ b/toolchain/parse/testdata/struct/fail_comma_only.carbon @@ -11,6 +11,7 @@ var x: {,} = {}; // CHECK:STDOUT: - filename: fail_comma_only.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon b/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon index 24a6a59f72ca..3088c96f69cd 100644 --- a/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon +++ b/toolchain/parse/testdata/struct/fail_comma_repeat_in_type.carbon @@ -11,6 +11,7 @@ var x: {.a: i32,,} = {}; // CHECK:STDOUT: - filename: fail_comma_repeat_in_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon b/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon index 7c75512069e4..e829f23e48be 100644 --- a/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon +++ b/toolchain/parse/testdata/struct/fail_comma_repeat_in_value.carbon @@ -11,6 +11,7 @@ var x: {.a = 0,,} = {}; // CHECK:STDOUT: - filename: fail_comma_repeat_in_value.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_dot_only.carbon b/toolchain/parse/testdata/struct/fail_dot_only.carbon index 4ce707e7c1b1..95268075ae18 100644 --- a/toolchain/parse/testdata/struct/fail_dot_only.carbon +++ b/toolchain/parse/testdata/struct/fail_dot_only.carbon @@ -11,6 +11,7 @@ var x: {.} = {}; // CHECK:STDOUT: - filename: fail_dot_only.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_dot_string_colon.carbon b/toolchain/parse/testdata/struct/fail_dot_string_colon.carbon index 4241b49b232b..ee8ec21da9a7 100644 --- a/toolchain/parse/testdata/struct/fail_dot_string_colon.carbon +++ b/toolchain/parse/testdata/struct/fail_dot_string_colon.carbon @@ -11,6 +11,7 @@ var x: {."hello": i32, .y: i32} = {}; // CHECK:STDOUT: - filename: fail_dot_string_colon.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_dot_string_equals.carbon b/toolchain/parse/testdata/struct/fail_dot_string_equals.carbon index ef9ad3fd52e3..1a406474108f 100644 --- a/toolchain/parse/testdata/struct/fail_dot_string_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_dot_string_equals.carbon @@ -11,6 +11,7 @@ var x: {."hello" = 0, .y = 4} = {}; // CHECK:STDOUT: - filename: fail_dot_string_equals.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon b/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon index 4cb9257118f0..a3f2b33fbdd8 100644 --- a/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon +++ b/toolchain/parse/testdata/struct/fail_extra_token_in_type.carbon @@ -11,6 +11,7 @@ var x: {.a: i32 banana} = {.a = 0}; // CHECK:STDOUT: - filename: fail_extra_token_in_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon b/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon index 08cdb459937f..65163b68e81d 100644 --- a/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon +++ b/toolchain/parse/testdata/struct/fail_extra_token_in_value.carbon @@ -11,6 +11,7 @@ var x: {.a: i32} = {.a = 0 banana}; // CHECK:STDOUT: - filename: fail_extra_token_in_value.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_identifier_colon.carbon b/toolchain/parse/testdata/struct/fail_identifier_colon.carbon index 0f5f1bd9d712..b9cbdc516260 100644 --- a/toolchain/parse/testdata/struct/fail_identifier_colon.carbon +++ b/toolchain/parse/testdata/struct/fail_identifier_colon.carbon @@ -11,6 +11,7 @@ var x: {a:} = {}; // CHECK:STDOUT: - filename: fail_identifier_colon.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_identifier_equals.carbon b/toolchain/parse/testdata/struct/fail_identifier_equals.carbon index 90de2522025e..4ac5ce2ea983 100644 --- a/toolchain/parse/testdata/struct/fail_identifier_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_identifier_equals.carbon @@ -11,6 +11,7 @@ var x: {a=} = {}; // CHECK:STDOUT: - filename: fail_identifier_equals.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_identifier_only.carbon b/toolchain/parse/testdata/struct/fail_identifier_only.carbon index 2f1c917e2807..92f7fe87be8a 100644 --- a/toolchain/parse/testdata/struct/fail_identifier_only.carbon +++ b/toolchain/parse/testdata/struct/fail_identifier_only.carbon @@ -11,6 +11,7 @@ var x: {a} = {}; // CHECK:STDOUT: - filename: fail_identifier_only.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_missing_type.carbon b/toolchain/parse/testdata/struct/fail_missing_type.carbon index e0de796dca11..a4d985105008 100644 --- a/toolchain/parse/testdata/struct/fail_missing_type.carbon +++ b/toolchain/parse/testdata/struct/fail_missing_type.carbon @@ -11,6 +11,7 @@ var x: {.a:} = {}; // CHECK:STDOUT: - filename: fail_missing_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_missing_value.carbon b/toolchain/parse/testdata/struct/fail_missing_value.carbon index 874a2fd433a3..8753792e9204 100644 --- a/toolchain/parse/testdata/struct/fail_missing_value.carbon +++ b/toolchain/parse/testdata/struct/fail_missing_value.carbon @@ -11,6 +11,7 @@ var x: {.a=} = {}; // CHECK:STDOUT: - filename: fail_missing_value.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon b/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon index 35d38b4f44ac..9d7f39d2964d 100644 --- a/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon +++ b/toolchain/parse/testdata/struct/fail_mix_type_and_value.carbon @@ -11,6 +11,7 @@ var x: {.a: i32, .b = 0} = {}; // CHECK:STDOUT: - filename: fail_mix_type_and_value.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon b/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon index 0d04f8d19249..8e27ee378a7f 100644 --- a/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon +++ b/toolchain/parse/testdata/struct/fail_mix_value_and_type.carbon @@ -11,6 +11,7 @@ var x: {.a = 0, b: i32} = {}; // CHECK:STDOUT: - filename: fail_mix_value_and_type.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon b/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon index c2f5566ee11f..230c6b6fc5d1 100644 --- a/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon +++ b/toolchain/parse/testdata/struct/fail_mix_with_unknown.carbon @@ -22,6 +22,7 @@ var x: i32 = {.a: i32, .b, .c = 1}; // CHECK:STDOUT: - filename: fail_mix_with_unknown.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon b/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon index 8a0705295eb2..49eed97e0d13 100644 --- a/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon +++ b/toolchain/parse/testdata/struct/fail_no_colon_or_equals.carbon @@ -11,6 +11,7 @@ var x: {.a} = {}; // CHECK:STDOUT: - filename: fail_no_colon_or_equals.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/fail_type_no_designator.carbon b/toolchain/parse/testdata/struct/fail_type_no_designator.carbon index 38ea3355411c..cb59957ce02f 100644 --- a/toolchain/parse/testdata/struct/fail_type_no_designator.carbon +++ b/toolchain/parse/testdata/struct/fail_type_no_designator.carbon @@ -11,6 +11,7 @@ var x: {i32} = {}; // CHECK:STDOUT: - filename: fail_type_no_designator.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/no_entries.carbon b/toolchain/parse/testdata/struct/no_entries.carbon index 6030e9a4a83e..1018d2ab8b16 100644 --- a/toolchain/parse/testdata/struct/no_entries.carbon +++ b/toolchain/parse/testdata/struct/no_entries.carbon @@ -8,6 +8,7 @@ var y: {} = {}; // CHECK:STDOUT: - filename: no_entries.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'y'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/one_entry_no_comma.carbon b/toolchain/parse/testdata/struct/one_entry_no_comma.carbon index f3a30433a299..1bcf208ffbdd 100644 --- a/toolchain/parse/testdata/struct/one_entry_no_comma.carbon +++ b/toolchain/parse/testdata/struct/one_entry_no_comma.carbon @@ -8,6 +8,7 @@ var z: {.n: i32} = {.n = 4}; // CHECK:STDOUT: - filename: one_entry_no_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'z'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/one_entry_with_comma.carbon b/toolchain/parse/testdata/struct/one_entry_with_comma.carbon index 217f09877112..f041451c2a35 100644 --- a/toolchain/parse/testdata/struct/one_entry_with_comma.carbon +++ b/toolchain/parse/testdata/struct/one_entry_with_comma.carbon @@ -8,6 +8,7 @@ var z: {.n: i32,} = {.n = 4,}; // CHECK:STDOUT: - filename: one_entry_with_comma.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'z'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/struct/two_entries.carbon b/toolchain/parse/testdata/struct/two_entries.carbon index d003000b9a28..79d7be8f72cb 100644 --- a/toolchain/parse/testdata/struct/two_entries.carbon +++ b/toolchain/parse/testdata/struct/two_entries.carbon @@ -8,6 +8,7 @@ var x: {.a: i32, .b: i32} = {.a = 1, .b = 2}; // CHECK:STDOUT: - filename: two_entries.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'StructLiteralOrStructTypeLiteralStart', text: '{'}, diff --git a/toolchain/parse/testdata/tuple/nested.carbon b/toolchain/parse/testdata/tuple/nested.carbon index 4898a9c7c628..6b70df63de71 100644 --- a/toolchain/parse/testdata/tuple/nested.carbon +++ b/toolchain/parse/testdata/tuple/nested.carbon @@ -8,6 +8,7 @@ var y: ((), (), ()); // CHECK:STDOUT: - filename: nested.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'y'}, // CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('}, diff --git a/toolchain/parse/testdata/tuple/two_entries.carbon b/toolchain/parse/testdata/tuple/two_entries.carbon index ed40a5eb5f2f..1e0c8a138170 100644 --- a/toolchain/parse/testdata/tuple/two_entries.carbon +++ b/toolchain/parse/testdata/tuple/two_entries.carbon @@ -8,6 +8,7 @@ var x: (i32, i32) = (1, 2); // CHECK:STDOUT: - filename: two_entries.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'x'}, // CHECK:STDOUT: {kind: 'ParenExpressionOrTupleLiteralStart', text: '('}, diff --git a/toolchain/parse/testdata/var/fail_bad_name.carbon b/toolchain/parse/testdata/var/fail_bad_name.carbon index 8202e1d22063..ec969a9c6fad 100644 --- a/toolchain/parse/testdata/var/fail_bad_name.carbon +++ b/toolchain/parse/testdata/var/fail_bad_name.carbon @@ -11,6 +11,7 @@ var *; // CHECK:STDOUT: - filename: fail_bad_name.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: '*', has_error: yes}, // CHECK:STDOUT: {kind: 'InvalidParse', text: '*', has_error: yes}, diff --git a/toolchain/parse/testdata/var/fail_empty.carbon b/toolchain/parse/testdata/var/fail_empty.carbon index 2b997cecc9be..5f84136afbdd 100644 --- a/toolchain/parse/testdata/var/fail_empty.carbon +++ b/toolchain/parse/testdata/var/fail_empty.carbon @@ -11,6 +11,7 @@ var; // CHECK:STDOUT: - filename: fail_empty.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: ';', has_error: yes}, // CHECK:STDOUT: {kind: 'InvalidParse', text: ';', has_error: yes}, diff --git a/toolchain/parse/testdata/var/var.carbon b/toolchain/parse/testdata/var/var.carbon index 641894787fb0..c0225d3cc736 100644 --- a/toolchain/parse/testdata/var/var.carbon +++ b/toolchain/parse/testdata/var/var.carbon @@ -12,6 +12,7 @@ fn F() { // CHECK:STDOUT: - filename: var.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'}, // CHECK:STDOUT: {kind: 'Name', text: 'v'}, // CHECK:STDOUT: {kind: 'Literal', text: 'i32'}, diff --git a/toolchain/parse/testdata/while/basic.carbon b/toolchain/parse/testdata/while/basic.carbon index 448982604476..c117ff52f434 100644 --- a/toolchain/parse/testdata/while/basic.carbon +++ b/toolchain/parse/testdata/while/basic.carbon @@ -17,6 +17,7 @@ fn F() { // CHECK:STDOUT: - filename: basic.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/while/fail_no_semi.carbon b/toolchain/parse/testdata/while/fail_no_semi.carbon index cd57cf018328..df76a07f8bd4 100644 --- a/toolchain/parse/testdata/while/fail_no_semi.carbon +++ b/toolchain/parse/testdata/while/fail_no_semi.carbon @@ -23,6 +23,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_no_semi.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/testdata/while/fail_unbraced.carbon b/toolchain/parse/testdata/while/fail_unbraced.carbon index 6868a95d73b9..f5ae7dca9c15 100644 --- a/toolchain/parse/testdata/while/fail_unbraced.carbon +++ b/toolchain/parse/testdata/while/fail_unbraced.carbon @@ -15,6 +15,7 @@ fn F() { // CHECK:STDOUT: - filename: fail_unbraced.carbon // CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'}, // CHECK:STDOUT: {kind: 'Name', text: 'F'}, // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('}, diff --git a/toolchain/parse/tree.cpp b/toolchain/parse/tree.cpp index 62c64cdd5cff..55471f730ab9 100644 --- a/toolchain/parse/tree.cpp +++ b/toolchain/parse/tree.cpp @@ -26,6 +26,9 @@ auto Tree::Parse(Lex::TokenizedBuffer& tokens, DiagnosticConsumer& consumer, PrettyStackTraceFunction context_dumper( [&](llvm::raw_ostream& output) { context.PrintForStackDump(output); }); + context.AddLeafNode(NodeKind::FileStart, + context.ConsumeChecked(Lex::TokenKind::StartOfFile)); + context.PushState(State::DeclarationScopeLoop); // The package should always be the first token, if it's present. Any other diff --git a/toolchain/parse/tree_test.cpp b/toolchain/parse/tree_test.cpp index 8d384797af58..8574383e8b90 100644 --- a/toolchain/parse/tree_test.cpp +++ b/toolchain/parse/tree_test.cpp @@ -60,6 +60,7 @@ TEST_F(TreeTest, PrintPostorderAsYAML) { tree.Print(print_stream); auto file = Yaml::Sequence(ElementsAre( + Yaml::Mapping(ElementsAre(Pair("kind", "FileStart"), Pair("text", ""))), Yaml::Mapping( ElementsAre(Pair("kind", "FunctionIntroducer"), Pair("text", "fn"))), Yaml::Mapping(ElementsAre(Pair("kind", "Name"), Pair("text", "F"))), @@ -86,26 +87,28 @@ TEST_F(TreeTest, PrintPreorderAsYAML) { tree.Print(print_stream, /*preorder=*/true); auto parameter_list = Yaml::Sequence(ElementsAre(Yaml::Mapping( - ElementsAre(Pair("node_index", "2"), Pair("kind", "ParameterListStart"), + ElementsAre(Pair("node_index", "3"), Pair("kind", "ParameterListStart"), Pair("text", "("))))); auto function_decl = Yaml::Sequence(ElementsAre( - Yaml::Mapping(ElementsAre(Pair("node_index", "0"), + Yaml::Mapping(ElementsAre(Pair("node_index", "1"), Pair("kind", "FunctionIntroducer"), Pair("text", "fn"))), - Yaml::Mapping(ElementsAre(Pair("node_index", "1"), Pair("kind", "Name"), + Yaml::Mapping(ElementsAre(Pair("node_index", "2"), Pair("kind", "Name"), Pair("text", "F"))), - Yaml::Mapping(ElementsAre(Pair("node_index", "3"), + Yaml::Mapping(ElementsAre(Pair("node_index", "4"), Pair("kind", "ParameterList"), Pair("text", ")"), Pair("subtree_size", "2"), Pair("children", parameter_list))))); auto file = Yaml::Sequence(ElementsAre( - Yaml::Mapping(ElementsAre(Pair("node_index", "4"), + Yaml::Mapping(ElementsAre(Pair("node_index", "0"), + Pair("kind", "FileStart"), Pair("text", ""))), + Yaml::Mapping(ElementsAre(Pair("node_index", "5"), Pair("kind", "FunctionDeclaration"), Pair("text", ";"), Pair("subtree_size", "5"), Pair("children", function_decl))), - Yaml::Mapping(ElementsAre(Pair("node_index", "5"), + Yaml::Mapping(ElementsAre(Pair("node_index", "6"), Pair("kind", "FileEnd"), Pair("text", ""))))); auto root = Yaml::Sequence(ElementsAre(Yaml::Mapping( diff --git a/toolchain/testing/file_test.cpp b/toolchain/testing/file_test.cpp index a7b58030ae7c..ade3983db8eb 100644 --- a/toolchain/testing/file_test.cpp +++ b/toolchain/testing/file_test.cpp @@ -76,10 +76,13 @@ class ToolchainFileTest : public FileTestBase { check_line = "// CHECK:STDOUT: {{.*}}"; } } else if (component_ == "lex") { - // Ignore the resulting column of EndOfFile because it's often the end of - // the CHECK comment. - static RE2 end_of_file_re(R"((EndOfFile.*column: )( *\d+))"); - RE2::Replace(&check_line, end_of_file_re, R"(\1{{ *\\d+}})"); + // Both StartOfFile and EndOfFile regularly have locations on CHECK + // comment lines that don't work correctly. The line happens to be correct + // for the EndOfFile, but we need to avoid checking the column. + // The column happens to be right for StartOfFile, but the line is wrong. + static RE2 file_token_re( + R"((EndOfFile.*column: |StartOfFile.*line: )( *\d+))"); + RE2::Replace(&check_line, file_token_re, R"(\1{{ *\\d+}})"); } else { return FileTestBase::DoExtraCheckReplacements(check_line); }