stage3 ai编写新语法语义 同时提供fflush
This commit is contained in:
1 parent
bb8761d392
commit
126b979f72
170 files changed
+10729
-3175
No files matched your search
@@ -0,0 +1,142 @@
|
||||
#!role(ops)
|
||||
|
||||
// 语言运算符协议。运算符解析只认本模块的 shape;
|
||||
|
||||
// 用户模块里的同名 shape 不参与语言分派。
|
||||
|
||||
type Ordering = enum {
|
||||
Less,
|
||||
Equal,
|
||||
Greater,
|
||||
};
|
||||
|
||||
#lang(add)
|
||||
type Add = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn add(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(sub)
|
||||
type Sub = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn sub(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(mul)
|
||||
type Mul = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn mul(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(div)
|
||||
type Div = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn div(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(mod)
|
||||
type Mod = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn rem(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(neg)
|
||||
type Neg = shape {
|
||||
type Output;
|
||||
fn neg(value: @self): Output;
|
||||
};
|
||||
|
||||
#lang(bit_and)
|
||||
type BitAnd = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn bit_and(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(bit_or)
|
||||
type BitOr = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn bit_or(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(bit_xor)
|
||||
type BitXor = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn bit_xor(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(shl)
|
||||
type Shl = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn shl(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(shr)
|
||||
type Shr = shape {
|
||||
type Rhs;
|
||||
type Output;
|
||||
fn shr(lhs: @self, rhs: Rhs): Output;
|
||||
};
|
||||
|
||||
#lang(bit_not)
|
||||
type BitNot = shape {
|
||||
type Output;
|
||||
fn bit_not(value: @self): Output;
|
||||
};
|
||||
|
||||
#lang(eq)
|
||||
type Eq = shape {
|
||||
type Rhs;
|
||||
fn eq(lhs: @self, rhs: Rhs): bool;
|
||||
};
|
||||
|
||||
#lang(ord)
|
||||
type Ord = shape {
|
||||
type Rhs;
|
||||
fn cmp(lhs: @self, rhs: Rhs): Ordering;
|
||||
};
|
||||
|
||||
#lang(index)
|
||||
type Index = shape {
|
||||
type Output;
|
||||
fn index(@Self self: *@self, idx: usize): *Output;
|
||||
};
|
||||
|
||||
type Len = shape {
|
||||
fn len(@Self self: @self): usize;
|
||||
};
|
||||
|
||||
comptime fn Step(T: type): type {
|
||||
ret enum {
|
||||
Item: T,
|
||||
Done,
|
||||
};
|
||||
}
|
||||
|
||||
#lang(call)
|
||||
type Call = shape {
|
||||
type Args;
|
||||
type Output;
|
||||
fn call(self: @self, args: Args): Output;
|
||||
};
|
||||
|
||||
#lang(iter)
|
||||
type Iter = shape {
|
||||
type Item;
|
||||
fn next(@Self self: *@self): @Step(Item);
|
||||
};
|
||||
|
||||
#lang(into_iter)
|
||||
type IntoIter = shape {
|
||||
type Item;
|
||||
type Iter;
|
||||
fn iter(@Self self: *@self): Iter;
|
||||
};
|
||||
Reference in new issue
Block a user