mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 22:00:29 +00: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 `.`.
71 lines
1.4 KiB
Plaintext
71 lines
1.4 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
|
|
|
|
package Core library "prelude/operators/arithmetic";
|
|
|
|
// Addition: `a + b`.
|
|
interface Add {
|
|
fn Op[self: Self](other: Self) -> Self;
|
|
}
|
|
|
|
// Addition with assignment: `a += b`.
|
|
interface AddAssign {
|
|
fn Op[addr self: Self*](other: Self);
|
|
}
|
|
|
|
// Increment: `++a`.
|
|
interface Inc {
|
|
fn Op[addr self: Self*]();
|
|
}
|
|
|
|
// Negation: `-a`.
|
|
interface Negate {
|
|
fn Op[self: Self]() -> Self;
|
|
}
|
|
|
|
// Subtraction: `a - b`.
|
|
interface Sub {
|
|
fn Op[self: Self](other: Self) -> Self;
|
|
}
|
|
|
|
// Subtraction with assignment: `a -= b`.
|
|
interface SubAssign {
|
|
fn Op[addr self: Self*](other: Self);
|
|
}
|
|
|
|
// Decrement: `--a`.
|
|
interface Dec {
|
|
fn Op[addr self: Self*]();
|
|
}
|
|
|
|
// Multiplication: `a * b`.
|
|
interface Mul {
|
|
fn Op[self: Self](other: Self) -> Self;
|
|
}
|
|
|
|
// Multiplication with assignment: `a *= b`.
|
|
interface MulAssign {
|
|
fn Op[addr self: Self*](other: Self);
|
|
}
|
|
|
|
// Division: `a / b`.
|
|
interface Div {
|
|
fn Op[self: Self](other: Self) -> Self;
|
|
}
|
|
|
|
// Division with assignment: `a /= b`.
|
|
interface DivAssign {
|
|
fn Op[addr self: Self*](other: Self);
|
|
}
|
|
|
|
// Modulo: `a % b`.
|
|
interface Mod {
|
|
fn Op[self: Self](other: Self) -> Self;
|
|
}
|
|
|
|
// Modulo with assignment: `a %= b`.
|
|
interface ModAssign {
|
|
fn Op[addr self: Self*](other: Self);
|
|
}
|