Enum erg_parser::ast::TypeSpec
source · pub enum TypeSpec {
Show 14 variants
Infer(Token),
PreDeclTy(PreDeclTypeSpec),
Array(ArrayTypeSpec),
SetWithLen(SetWithLenTypeSpec),
Tuple(TupleTypeSpec),
Dict(Vec<(TypeSpec, TypeSpec)>),
Record(Vec<(Identifier, TypeSpec)>),
And(Box<TypeSpec>, Box<TypeSpec>),
Not(Box<TypeSpec>),
Or(Box<TypeSpec>, Box<TypeSpec>),
Enum(ConstArgs),
Interval {
op: Token,
lhs: ConstExpr,
rhs: ConstExpr,
},
Subr(SubrTypeSpec),
TypeApp {
spec: Box<TypeSpec>,
args: TypeAppArgs,
},
}
Expand description
- Array:
[Int; 3]
,[Int, Ratio, Complex]
, etc. - Dict:
[Str: Str]
, etc. - And (Intersection type): Add and Sub and Mul (== Num), etc.
- Not (Diff type): Pos == Nat not {0}, etc.
- Or (Union type): Int or None (== Option Int), etc.
- Enum:
{0, 1}
(== Binary), etc. - Range: 1..12, 0.0<..1.0, etc.
- Record: {.into_s: Self.() -> Str }, etc.
- Subr: Int -> Int, Int => None, T.(X) -> Int, etc.
- TypeApp: F|…|
Variants§
Infer(Token)
PreDeclTy(PreDeclTypeSpec)
Array(ArrayTypeSpec)
SetWithLen(SetWithLenTypeSpec)
Tuple(TupleTypeSpec)
Dict(Vec<(TypeSpec, TypeSpec)>)
Record(Vec<(Identifier, TypeSpec)>)
And(Box<TypeSpec>, Box<TypeSpec>)
Not(Box<TypeSpec>)
Or(Box<TypeSpec>, Box<TypeSpec>)
Enum(ConstArgs)
Interval
Subr(SubrTypeSpec)
TypeApp
Implementations§
source§impl TypeSpec
impl TypeSpec
pub fn and(lhs: TypeSpec, rhs: TypeSpec) -> Self
pub fn not(lhs: TypeSpec) -> Self
pub fn or(lhs: TypeSpec, rhs: TypeSpec) -> Self
pub const fn interval(op: Token, lhs: ConstExpr, rhs: ConstExpr) -> Self
pub fn type_app(spec: TypeSpec, args: TypeAppArgs) -> Self
pub fn enum_t_spec(elems: Vec<Literal>) -> Self
Trait Implementations§
source§impl Locational for TypeSpec
impl Locational for TypeSpec
source§fn loc(&self) -> Location
fn loc(&self) -> Location
NOTE:
loc
cannot be treated as a light method when self
is a large grammatical element.
If possible, delay the computation by passing &impl Locational
or other means.