mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:11:12 +01:00
This turns `Cpp` into a keyword, and makes it map to `NameId::Cpp` and `PackageNameId::Cpp`. Per discussion with zygoloid, the keyword versus identifier question is deliberately kept open by #4846. This PR switches to a keyword because mapping to a specific `PackageNameId` works best with a special `NameId` not backed by an `IdentifierId`. We could in theory make it work using `IdentifierId` or a runtime-tracked `PackageNameId` for `Cpp` (e.g. stored on `SemIR::File`), but this approach is consistent with `Core` and so seemed like a good starting point. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
41 lines
1.8 KiB
Plaintext
41 lines
1.8 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
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/packages/keyword_names.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/packages/keyword_names.carbon
|
|
|
|
// --- core.carbon
|
|
|
|
var x: Core;
|
|
|
|
// --- cpp.carbon
|
|
|
|
var x: Cpp;
|
|
|
|
// CHECK:STDOUT: - filename: core.carbon
|
|
// CHECK:STDOUT: parse_tree: [
|
|
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
|
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
|
|
// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'},
|
|
// CHECK:STDOUT: {kind: 'CoreNameExpr', text: 'Core'},
|
|
// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 3},
|
|
// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4},
|
|
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6},
|
|
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
|
// CHECK:STDOUT: ]
|
|
// CHECK:STDOUT: - filename: cpp.carbon
|
|
// CHECK:STDOUT: parse_tree: [
|
|
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
|
// CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
|
|
// CHECK:STDOUT: {kind: 'IdentifierNameNotBeforeParams', text: 'x'},
|
|
// CHECK:STDOUT: {kind: 'CppNameExpr', text: 'Cpp'},
|
|
// CHECK:STDOUT: {kind: 'VarBindingPattern', text: ':', subtree_size: 3},
|
|
// CHECK:STDOUT: {kind: 'VariablePattern', text: 'var', subtree_size: 4},
|
|
// CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 6},
|
|
// CHECK:STDOUT: {kind: 'FileEnd', text: ''},
|
|
// CHECK:STDOUT: ]
|