mirror of
https://github.com/HigherOrderCO/Kind1.git
synced 2024-09-11 08:45:32 +03:00
feat: started the mutter, getter and setter feature
This commit is contained in:
parent
668233184f
commit
43eeb5ca0d
@ -288,6 +288,20 @@ impl<'a> Visitor for Subst<'a> {
|
|||||||
self.visit_expr(motive);
|
self.visit_expr(motive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ExprKind::SeqRecord(sec) => {
|
||||||
|
use kind_tree::concrete::SeqOperation::*;
|
||||||
|
|
||||||
|
self.visit_ident(&mut sec.ident[0]);
|
||||||
|
|
||||||
|
self.visit_expr(&mut sec.typ_);
|
||||||
|
|
||||||
|
match &mut sec.operation {
|
||||||
|
Set(expr) => self.visit_expr(expr),
|
||||||
|
Mut(expr) => self.visit_expr(expr),
|
||||||
|
Get => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,15 +40,15 @@ impl<'a> DesugarState<'a> {
|
|||||||
let list_ident = QualifiedIdent::new_static("Nat", None, range);
|
let list_ident = QualifiedIdent::new_static("Nat", None, range);
|
||||||
let cons_ident = list_ident.add_segment("succ");
|
let cons_ident = list_ident.add_segment("succ");
|
||||||
let nil_ident = list_ident.add_segment("zero");
|
let nil_ident = list_ident.add_segment("zero");
|
||||||
|
|
||||||
let mut res = self.mk_desugared_ctr(range, nil_ident, Vec::new(), false);
|
let mut res = self.mk_desugared_ctr(range, nil_ident, Vec::new(), false);
|
||||||
|
|
||||||
for _ in 0..*num {
|
for _ in 0..*num {
|
||||||
res = self.mk_desugared_ctr(range, cons_ident.clone(), vec![res], false)
|
res = self.mk_desugared_ctr(range, cons_ident.clone(), vec![res], false)
|
||||||
}
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
},
|
}
|
||||||
Literal::NumU120(num) => {
|
Literal::NumU120(num) => {
|
||||||
if !self.check_implementation("U120.new", range, Sugar::U120) {
|
if !self.check_implementation("U120.new", range, Sugar::U120) {
|
||||||
return desugared::Expr::err(range);
|
return desugared::Expr::err(range);
|
||||||
@ -74,6 +74,14 @@ impl<'a> DesugarState<'a> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn desugar_seq(
|
||||||
|
&mut self,
|
||||||
|
range: Range,
|
||||||
|
sub: &expr::SeqRecord,
|
||||||
|
) -> Box<desugared::Expr> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn desugar_sttm(
|
pub(crate) fn desugar_sttm(
|
||||||
&mut self,
|
&mut self,
|
||||||
bind_ident: &QualifiedIdent,
|
bind_ident: &QualifiedIdent,
|
||||||
@ -157,7 +165,10 @@ impl<'a> DesugarState<'a> {
|
|||||||
let pure = self.old_book.names.get(pure_ident.to_str());
|
let pure = self.old_book.names.get(pure_ident.to_str());
|
||||||
|
|
||||||
if bind.is_none() || pure.is_none() {
|
if bind.is_none() || pure.is_none() {
|
||||||
self.send_err(PassDiagnostic::NeedToImplementMethods(range, Sugar::DoNotation));
|
self.send_err(PassDiagnostic::NeedToImplementMethods(
|
||||||
|
range,
|
||||||
|
Sugar::DoNotation,
|
||||||
|
));
|
||||||
return desugared::Expr::err(range);
|
return desugared::Expr::err(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +260,7 @@ impl<'a> DesugarState<'a> {
|
|||||||
type_name: &QualifiedIdent,
|
type_name: &QualifiedIdent,
|
||||||
var_name: &Ident,
|
var_name: &Ident,
|
||||||
motive: &Option<Box<expr::Expr>>,
|
motive: &Option<Box<expr::Expr>>,
|
||||||
next: &expr::Expr
|
next: &expr::Expr,
|
||||||
) -> Box<desugared::Expr> {
|
) -> Box<desugared::Expr> {
|
||||||
let rec = self.old_book.entries.get(type_name.to_str());
|
let rec = self.old_book.entries.get(type_name.to_str());
|
||||||
|
|
||||||
@ -270,16 +281,23 @@ impl<'a> DesugarState<'a> {
|
|||||||
return desugared::Expr::err(range);
|
return desugared::Expr::err(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
let field_names : Vec<_> = record.fields.iter().map(|x| var_name.add_segment(x.0.to_str())).collect();
|
let field_names: Vec<_> = record
|
||||||
|
.fields
|
||||||
|
.iter()
|
||||||
|
.map(|x| var_name.add_segment(x.0.to_str()))
|
||||||
|
.collect();
|
||||||
|
|
||||||
let irrelev = vec![false; field_names.len()];
|
let irrelev = vec![false; field_names.len()];
|
||||||
|
|
||||||
let motive = motive.as_ref().map(|x| self.desugar_expr(x)).unwrap_or_else(|| self.gen_hole_expr(range));
|
let motive = motive
|
||||||
|
.as_ref()
|
||||||
|
.map(|x| self.desugar_expr(x))
|
||||||
|
.unwrap_or_else(|| self.gen_hole_expr(range));
|
||||||
|
|
||||||
let spine = vec![
|
let spine = vec![
|
||||||
desugared::Expr::var(var_name.clone()),
|
desugared::Expr::var(var_name.clone()),
|
||||||
desugared::Expr::lambda(range, var_name.clone(), motive, false),
|
desugared::Expr::lambda(range, var_name.clone(), motive, false),
|
||||||
desugared::Expr::unfold_lambda(&irrelev, &field_names, self.desugar_expr(next))
|
desugared::Expr::unfold_lambda(&irrelev, &field_names, self.desugar_expr(next)),
|
||||||
];
|
];
|
||||||
|
|
||||||
self.mk_desugared_fun(range, open_id, spine, false)
|
self.mk_desugared_fun(range, open_id, spine, false)
|
||||||
@ -367,7 +385,13 @@ impl<'a> DesugarState<'a> {
|
|||||||
Pair { fst, snd } => self.desugar_pair(expr.range, fst, snd),
|
Pair { fst, snd } => self.desugar_pair(expr.range, fst, snd),
|
||||||
Match(matcher) => self.desugar_match(expr.range, matcher),
|
Match(matcher) => self.desugar_match(expr.range, matcher),
|
||||||
Subst(sub) => self.desugar_sub(expr.range, sub),
|
Subst(sub) => self.desugar_sub(expr.range, sub),
|
||||||
Open { type_name, var_name, motive, next } => self.desugar_open(expr.range, type_name, var_name, motive, &next)
|
Open {
|
||||||
|
type_name,
|
||||||
|
var_name,
|
||||||
|
motive,
|
||||||
|
next,
|
||||||
|
} => self.desugar_open(expr.range, type_name, var_name, motive, &next),
|
||||||
|
SeqRecord(sec) => self.desugar_seq(expr.range, sec),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -635,6 +635,20 @@ impl Visitor for UnboundCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ExprKind::SeqRecord(sec) => {
|
||||||
|
use kind_tree::concrete::SeqOperation::*;
|
||||||
|
|
||||||
|
self.visit_expr(&mut sec.typ_);
|
||||||
|
|
||||||
|
self.visit_ident(&mut sec.ident[0]);
|
||||||
|
|
||||||
|
match &mut sec.operation {
|
||||||
|
Set(expr) => self.visit_expr(expr),
|
||||||
|
Mut(expr) => self.visit_expr(expr),
|
||||||
|
Get => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ use std::fmt::{Display, Error, Formatter};
|
|||||||
|
|
||||||
/// A binding express the positional or named argument of
|
/// A binding express the positional or named argument of
|
||||||
/// a constructor or function.
|
/// a constructor or function.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Binding {
|
pub enum Binding {
|
||||||
Positional(Box<Expr>),
|
Positional(Box<Expr>),
|
||||||
Named(Range, Ident, Box<Expr>),
|
Named(Range, Ident, Box<Expr>),
|
||||||
@ -22,7 +22,7 @@ pub enum Binding {
|
|||||||
pub type Spine = Vec<Binding>;
|
pub type Spine = Vec<Binding>;
|
||||||
|
|
||||||
/// A binding that is used inside applications.
|
/// A binding that is used inside applications.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct AppBinding {
|
pub struct AppBinding {
|
||||||
pub data: Box<Expr>,
|
pub data: Box<Expr>,
|
||||||
pub erased: bool,
|
pub erased: bool,
|
||||||
@ -46,7 +46,7 @@ impl AppBinding {
|
|||||||
|
|
||||||
/// A case binding is a field or a rename of some field
|
/// A case binding is a field or a rename of some field
|
||||||
/// inside a match expression.
|
/// inside a match expression.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum CaseBinding {
|
pub enum CaseBinding {
|
||||||
Field(Ident),
|
Field(Ident),
|
||||||
Renamed(Ident, Ident),
|
Renamed(Ident, Ident),
|
||||||
@ -56,7 +56,7 @@ pub enum CaseBinding {
|
|||||||
/// strutinizer, bindings to the names of each arguments and
|
/// strutinizer, bindings to the names of each arguments and
|
||||||
/// a right-hand side value. The ignore_rest flag useful to just
|
/// a right-hand side value. The ignore_rest flag useful to just
|
||||||
/// fill all of the case bindings that are not used with a default name.
|
/// fill all of the case bindings that are not used with a default name.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Case {
|
pub struct Case {
|
||||||
pub constructor: Ident,
|
pub constructor: Ident,
|
||||||
pub bindings: Vec<CaseBinding>,
|
pub bindings: Vec<CaseBinding>,
|
||||||
@ -66,7 +66,7 @@ pub struct Case {
|
|||||||
|
|
||||||
/// A match block that will be desugared
|
/// A match block that will be desugared
|
||||||
/// into an eliminator of a datatype.
|
/// into an eliminator of a datatype.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Match {
|
pub struct Match {
|
||||||
pub typ: QualifiedIdent,
|
pub typ: QualifiedIdent,
|
||||||
pub scrutinee: Ident,
|
pub scrutinee: Ident,
|
||||||
@ -77,7 +77,7 @@ pub struct Match {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Substitution
|
/// Substitution
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Substitution {
|
pub struct Substitution {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub redx: usize,
|
pub redx: usize,
|
||||||
@ -85,7 +85,7 @@ pub struct Substitution {
|
|||||||
pub expr: Box<Expr>,
|
pub expr: Box<Expr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Literal {
|
pub enum Literal {
|
||||||
/// The universe of types (e.g. Type)
|
/// The universe of types (e.g. Type)
|
||||||
Type,
|
Type,
|
||||||
@ -111,13 +111,13 @@ pub enum Literal {
|
|||||||
|
|
||||||
/// A destruct of a single constructor. It's a flat destruct
|
/// A destruct of a single constructor. It's a flat destruct
|
||||||
/// and just translates into a eliminator for records.
|
/// and just translates into a eliminator for records.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Destruct {
|
pub enum Destruct {
|
||||||
Destruct(Range, QualifiedIdent, Vec<CaseBinding>, Option<Range>),
|
Destruct(Range, QualifiedIdent, Vec<CaseBinding>, Option<Range>),
|
||||||
Ident(Ident),
|
Ident(Ident),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum SttmKind {
|
pub enum SttmKind {
|
||||||
Expr(Box<Expr>, Box<Sttm>),
|
Expr(Box<Expr>, Box<Sttm>),
|
||||||
Ask(Destruct, Box<Expr>, Box<Sttm>),
|
Ask(Destruct, Box<Expr>, Box<Sttm>),
|
||||||
@ -130,13 +130,27 @@ pub enum SttmKind {
|
|||||||
/// describes the idea of `sequence` inside a monad
|
/// describes the idea of `sequence` inside a monad
|
||||||
/// each monadic action contains a `next` element that is
|
/// each monadic action contains a `next` element that is
|
||||||
/// desugared into a 'monadic bind'.
|
/// desugared into a 'monadic bind'.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Sttm {
|
pub struct Sttm {
|
||||||
pub data: SttmKind,
|
pub data: SttmKind,
|
||||||
pub range: Range,
|
pub range: Range,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
|
pub enum SeqOperation {
|
||||||
|
Set(Box<Expr>),
|
||||||
|
Mut(Box<Expr>),
|
||||||
|
Get
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct SeqRecord {
|
||||||
|
pub typ_: Box<Expr>,
|
||||||
|
pub ident: Vec<Ident>,
|
||||||
|
pub operation: SeqOperation
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub enum ExprKind {
|
pub enum ExprKind {
|
||||||
/// Name of a variable
|
/// Name of a variable
|
||||||
Var { name: Ident },
|
Var { name: Ident },
|
||||||
@ -210,12 +224,14 @@ pub enum ExprKind {
|
|||||||
type_name: QualifiedIdent,
|
type_name: QualifiedIdent,
|
||||||
var_name: Ident,
|
var_name: Ident,
|
||||||
motive: Option<Box<Expr>>,
|
motive: Option<Box<Expr>>,
|
||||||
next: Box<Expr>,
|
next: Box<Expr>
|
||||||
},
|
},
|
||||||
|
|
||||||
|
SeqRecord(SeqRecord)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Describes a single expression inside Kind2.
|
/// Describes a single expression inside Kind2.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Expr {
|
pub struct Expr {
|
||||||
pub data: ExprKind,
|
pub data: ExprKind,
|
||||||
pub range: Range,
|
pub range: Range,
|
||||||
@ -292,25 +308,7 @@ impl Expr {
|
|||||||
range,
|
range,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl Binding {
|
|
||||||
pub fn to_app_binding(&self) -> AppBinding {
|
|
||||||
match self {
|
|
||||||
Binding::Positional(expr) => {
|
|
||||||
AppBinding {
|
|
||||||
data: expr.clone(),
|
|
||||||
erased: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Binding::Named(_, _, expr) => {
|
|
||||||
AppBinding {
|
|
||||||
data: expr.clone(),
|
|
||||||
erased: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Locatable for Binding {
|
impl Locatable for Binding {
|
||||||
@ -485,34 +483,16 @@ impl Display for Match {
|
|||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
||||||
write!(f, "match {} {}", self.typ, self.scrutinee)?;
|
write!(f, "match {} {}", self.typ, self.scrutinee)?;
|
||||||
|
|
||||||
if let Some(res) = &self.value {
|
match &self.motive {
|
||||||
write!(f, " = {}", res)?;
|
None => Ok(()),
|
||||||
}
|
Some(res) => write!(f, " : {}", res),
|
||||||
|
}?;
|
||||||
if !self.with_vars.is_empty() {
|
|
||||||
write!(f, " with")?;
|
|
||||||
for var in &self.with_vars {
|
|
||||||
if let Some(ty) = &var.1 {
|
|
||||||
write!(f, " ({} : {})", var.0, ty)?;
|
|
||||||
} else {
|
|
||||||
write!(f, " {}", var.0)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
write!(f, " {{ ")?;
|
write!(f, " {{ ")?;
|
||||||
|
|
||||||
for case in &self.cases {
|
for case in &self.cases {
|
||||||
write!(f, "{}; ", case)?
|
write!(f, "{}; ", case)?
|
||||||
}
|
}
|
||||||
|
write!(f, "}}")
|
||||||
write!(f, "}}")?;
|
|
||||||
|
|
||||||
if let Some(res) = &self.motive {
|
|
||||||
write!(f, " : {}", res)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,18 +572,8 @@ impl Display for Expr {
|
|||||||
args.iter().map(|x| format!(" {}", x)).collect::<String>()
|
args.iter().map(|x| format!(" {}", x)).collect::<String>()
|
||||||
),
|
),
|
||||||
Let { name, val, next } => write!(f, "(let {} = {}; {})", name, val, next),
|
Let { name, val, next } => write!(f, "(let {} = {}; {})", name, val, next),
|
||||||
Open {
|
Open { type_name, var_name, motive: Some(motive), next } => write!(f, "(open {} {} : {motive}; {})", type_name, var_name, next),
|
||||||
type_name,
|
Open { type_name, var_name, motive: None, next } => write!(f, "(open {} {}; {})", type_name, var_name, next),
|
||||||
var_name,
|
|
||||||
motive: Some(motive),
|
|
||||||
next,
|
|
||||||
} => write!(f, "(open {} {} : {motive}; {})", type_name, var_name, next),
|
|
||||||
Open {
|
|
||||||
type_name,
|
|
||||||
var_name,
|
|
||||||
motive: None,
|
|
||||||
next,
|
|
||||||
} => write!(f, "(open {} {}; {})", type_name, var_name, next),
|
|
||||||
If { cond, then_, else_ } => {
|
If { cond, then_, else_ } => {
|
||||||
write!(f, "(if {} {{{}}} else {{{}}})", cond, then_, else_)
|
write!(f, "(if {} {{{}}} else {{{}}})", cond, then_, else_)
|
||||||
}
|
}
|
||||||
@ -620,6 +590,34 @@ impl Display for Expr {
|
|||||||
Match(matcher) => write!(f, "({})", matcher),
|
Match(matcher) => write!(f, "({})", matcher),
|
||||||
Subst(subst) => write!(f, "({})", subst),
|
Subst(subst) => write!(f, "({})", subst),
|
||||||
Hole => write!(f, "_"),
|
Hole => write!(f, "_"),
|
||||||
|
SeqRecord(rec) => {
|
||||||
|
use SeqOperation::*;
|
||||||
|
write!(f, "(!({}) {}", rec.typ_, rec.ident.iter().map(|x| x.to_str()).collect::<Vec<_>>().join(","))?;
|
||||||
|
match &rec.operation {
|
||||||
|
Set(expr) => write!(f, "+= {})", expr),
|
||||||
|
Mut(expr) => write!(f, "@= {})", expr),
|
||||||
|
Get => write!(f, ")")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Binding {
|
||||||
|
pub fn to_app_binding(&self) -> AppBinding {
|
||||||
|
match self {
|
||||||
|
Binding::Positional(expr) => {
|
||||||
|
AppBinding {
|
||||||
|
data: expr.clone(),
|
||||||
|
erased: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Binding::Named(_, _, expr) => {
|
||||||
|
AppBinding {
|
||||||
|
data: expr.clone(),
|
||||||
|
erased: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ pub mod visitor;
|
|||||||
pub use expr::*;
|
pub use expr::*;
|
||||||
|
|
||||||
/// A value of a attribute
|
/// A value of a attribute
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum AttributeStyle {
|
pub enum AttributeStyle {
|
||||||
Ident(Range, Ident),
|
Ident(Range, Ident),
|
||||||
String(Range, String),
|
String(Range, String),
|
||||||
@ -34,7 +34,7 @@ pub enum AttributeStyle {
|
|||||||
/// that usually is on the top of a declaration
|
/// that usually is on the top of a declaration
|
||||||
/// and can be attached to a function declaration
|
/// and can be attached to a function declaration
|
||||||
/// it express some compiler properties
|
/// it express some compiler properties
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Attribute {
|
pub struct Attribute {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub args: Vec<AttributeStyle>,
|
pub args: Vec<AttributeStyle>,
|
||||||
@ -48,7 +48,7 @@ pub struct Attribute {
|
|||||||
/// compiled.
|
/// compiled.
|
||||||
/// hide: that express a implicit argument (that will
|
/// hide: that express a implicit argument (that will
|
||||||
/// be discovered through unification).
|
/// be discovered through unification).
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Argument {
|
pub struct Argument {
|
||||||
pub hidden: bool,
|
pub hidden: bool,
|
||||||
pub erased: bool,
|
pub erased: bool,
|
||||||
@ -60,7 +60,7 @@ pub struct Argument {
|
|||||||
/// A rule is a equation that in the left-hand-side
|
/// A rule is a equation that in the left-hand-side
|
||||||
/// contains a list of patterns @pats@ and on the
|
/// contains a list of patterns @pats@ and on the
|
||||||
/// right hand side a value.
|
/// right hand side a value.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Rule {
|
pub struct Rule {
|
||||||
pub name: QualifiedIdent,
|
pub name: QualifiedIdent,
|
||||||
pub pats: Vec<Box<Pat>>,
|
pub pats: Vec<Box<Pat>>,
|
||||||
@ -72,7 +72,7 @@ pub struct Rule {
|
|||||||
/// and has rules. The type of the function
|
/// and has rules. The type of the function
|
||||||
/// consists of the arguments @args@ and the
|
/// consists of the arguments @args@ and the
|
||||||
/// return type @typ@.
|
/// return type @typ@.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Entry {
|
pub struct Entry {
|
||||||
pub name: QualifiedIdent,
|
pub name: QualifiedIdent,
|
||||||
pub docs: Vec<String>,
|
pub docs: Vec<String>,
|
||||||
@ -86,7 +86,7 @@ pub struct Entry {
|
|||||||
|
|
||||||
/// A single cosntructor inside the algebraic data
|
/// A single cosntructor inside the algebraic data
|
||||||
/// type definition.
|
/// type definition.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Constructor {
|
pub struct Constructor {
|
||||||
pub name: Ident,
|
pub name: Ident,
|
||||||
pub docs: Vec<String>,
|
pub docs: Vec<String>,
|
||||||
@ -97,7 +97,7 @@ pub struct Constructor {
|
|||||||
|
|
||||||
/// An algebraic data type definition that supports
|
/// An algebraic data type definition that supports
|
||||||
/// parametric and indexed data type definitions.
|
/// parametric and indexed data type definitions.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct SumTypeDecl {
|
pub struct SumTypeDecl {
|
||||||
pub name: QualifiedIdent,
|
pub name: QualifiedIdent,
|
||||||
pub docs: Vec<String>,
|
pub docs: Vec<String>,
|
||||||
@ -108,7 +108,7 @@ pub struct SumTypeDecl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A single constructor data type.
|
/// A single constructor data type.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RecordDecl {
|
pub struct RecordDecl {
|
||||||
pub name: QualifiedIdent,
|
pub name: QualifiedIdent,
|
||||||
pub docs: Vec<String>,
|
pub docs: Vec<String>,
|
||||||
@ -126,7 +126,7 @@ impl RecordDecl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// All of the structures
|
/// All of the structures
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum TopLevel {
|
pub enum TopLevel {
|
||||||
SumType(SumTypeDecl),
|
SumType(SumTypeDecl),
|
||||||
RecordType(RecordDecl),
|
RecordType(RecordDecl),
|
||||||
@ -166,7 +166,7 @@ impl TopLevel {
|
|||||||
/// A module is a collection of top level entries
|
/// A module is a collection of top level entries
|
||||||
/// that contains syntatic sugars. In the future
|
/// that contains syntatic sugars. In the future
|
||||||
/// it will contain a HashMap to local renames.
|
/// it will contain a HashMap to local renames.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Module {
|
pub struct Module {
|
||||||
pub entries: Vec<TopLevel>,
|
pub entries: Vec<TopLevel>,
|
||||||
pub uses: FxHashMap<String, String>,
|
pub uses: FxHashMap<String, String>,
|
||||||
|
@ -492,5 +492,6 @@ pub fn walk_expr<T: Visitor>(ctx: &mut T, expr: &mut Expr) {
|
|||||||
ExprKind::Hole => {}
|
ExprKind::Hole => {}
|
||||||
ExprKind::Subst(subst) => ctx.visit_substitution(subst),
|
ExprKind::Subst(subst) => ctx.visit_substitution(subst),
|
||||||
ExprKind::Match(matcher) => ctx.visit_match(matcher),
|
ExprKind::Match(matcher) => ctx.visit_match(matcher),
|
||||||
|
ExprKind::SeqRecord(_) => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user