mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Change syntax for package declaration to put the `impl` keyword at the start and remove the `api` keyword. To support this, rearrange processing of package, library, and import declarations to use the general modifier handling support in declaration parsing rather than special-case logic. There is an ambiguity in `impl package.Foo as Bar`, which we resolve by treating `package` as an introducer after a modifier only if it's not followed by `.`.
59 lines
1.8 KiB
Plaintext
59 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
|
|
|
|
// --- a.carbon
|
|
|
|
library "a";
|
|
|
|
class ForwardDecl;
|
|
|
|
// --- a.impl.carbon
|
|
|
|
impl library "a";
|
|
|
|
class ForwardDecl {
|
|
}
|
|
|
|
// CHECK:STDOUT: --- a.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %ForwardDecl: type = class_type @ForwardDecl [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .ForwardDecl = %ForwardDecl.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %ForwardDecl.decl: type = class_decl @ForwardDecl [template = constants.%ForwardDecl] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @ForwardDecl;
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: --- a.impl.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %ForwardDecl: type = class_type @ForwardDecl [template]
|
|
// CHECK:STDOUT: %.1: type = struct_type {} [template]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
|
// CHECK:STDOUT: .Core = %Core
|
|
// CHECK:STDOUT: .ForwardDecl = %ForwardDecl.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %import_ref: type = import_ref ir0, inst+2, loaded [template = constants.%ForwardDecl]
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
|
// CHECK:STDOUT: %ForwardDecl.decl: type = class_decl @ForwardDecl [template = constants.%ForwardDecl] {}
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @ForwardDecl {
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%ForwardDecl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|