fix: open statement and ;

This commit is contained in:
felipegchi 2023-01-12 11:17:07 -03:00
parent 554f1fc5d9
commit 3304d80d66
4 changed files with 26 additions and 6 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "kind2"
version = "0.3.6"
version = "0.3.7"
edition = "2021"
description = "A pure functional functional language that uses the HVM."
repository = "https://github.com/Kindelia/Kind2"

View File

@ -617,6 +617,7 @@ impl<'a> Parser<'a> {
self.advance(); // 'open'
let type_name = self.parse_upper_id()?;
let var_name = self.parse_id()?;
self.check_and_eat(Token::Semi);
let next = self.parse_expr(false)?;
let end = next.range;

View File

@ -466,16 +466,34 @@ impl Display for Match {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "match {} {}", self.typ, self.scrutinee)?;
match &self.motive {
None => Ok(()),
Some(res) => write!(f, " : {}", res),
}?;
if let Some(res) = &self.value {
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, " {{ ")?;
for case in &self.cases {
write!(f, "{}; ", case)?
}
write!(f, "}}")
write!(f, "}}")?;
if let Some(res) = &self.motive {
write!(f, " : {}", res)?;
}
Ok(())
}
}

View File

@ -303,6 +303,7 @@ impl Display for Book {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
for entr in self.entries.values() {
match entr {
TopLevel::Entry(entr) if entr.generated_by.is_some() => (),
_ => write!(f, "{}", entr)?,
}
}