Files
carbon-lang/toolchain/parser/testdata/namespace/nested.carbon
T
Jon Ross-Perkins 446b0ce4ae Refactor declaration name context logic to its own class. (#2989)
This started with cleaning up the remaining Name/expression type punning
in the node stack, and grew. I'm factoring out a class because we've
previously expressed the desire to factor logic out of SemanticsContext
where possible, and this seemed like a reasonable cut.

NameExpression as the first node as a QualifiedExpression allows the
qualifier handling to consider Name in one less spot, an incremental
simplification. However, the additional complexity caused by this makes
me split ApplyNameQualifier/ApplyExpressionQualifier in order to avoid
repeat checks of the parse node's kind. The logic is still largely
shared, thus a couple helper functions. I think this is all fairly well
structured in the isolated class.

I can see that we may want to avoid passing SemanticsContext as an
argument in the future if it elides a step of lookup.
2023-07-17 21:55:29 +00:00

42 lines
2.1 KiB
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// CHECK:STDOUT: [
// CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'},
// CHECK:STDOUT: {kind: 'Name', text: 'Foo'},
// CHECK:STDOUT: {kind: 'Namespace', text: ';', subtree_size: 3},
// CHECK:STDOUT: {kind: 'NamespaceStart', text: 'namespace'},
// CHECK:STDOUT: {kind: 'NameExpression', text: 'Foo'},
// CHECK:STDOUT: {kind: 'Name', text: 'Bar'},
// CHECK:STDOUT: {kind: 'QualifiedDeclaration', text: '.', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Namespace', text: ';', subtree_size: 5},
// CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
// CHECK:STDOUT: {kind: 'NameExpression', text: 'Foo'},
// CHECK:STDOUT: {kind: 'Name', text: 'Bar'},
// CHECK:STDOUT: {kind: 'QualifiedDeclaration', text: '.', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Name', text: 'Baz'},
// CHECK:STDOUT: {kind: 'QualifiedDeclaration', text: '.', subtree_size: 5},
// CHECK:STDOUT: {kind: 'ParameterListStart', text: '('},
// CHECK:STDOUT: {kind: 'ParameterList', text: ')', subtree_size: 2},
// CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 9},
// CHECK:STDOUT: {kind: 'NameExpression', text: 'Foo'},
// CHECK:STDOUT: {kind: 'Name', text: 'Bar'},
// CHECK:STDOUT: {kind: 'MemberAccessExpression', text: '.', subtree_size: 3},
// CHECK:STDOUT: {kind: 'Name', text: 'Wiz'},
// CHECK:STDOUT: {kind: 'MemberAccessExpression', text: '.', subtree_size: 5},
// CHECK:STDOUT: {kind: 'CallExpressionStart', text: '(', subtree_size: 6},
// CHECK:STDOUT: {kind: 'CallExpression', text: ')', subtree_size: 7},
// CHECK:STDOUT: {kind: 'ExpressionStatement', text: ';', subtree_size: 8},
// CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 18},
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
// CHECK:STDOUT: ]
namespace Foo;
namespace Foo.Bar;
fn Foo.Bar.Baz() {
Foo.Bar.Wiz();
}