"timestamp" expression

This commit is contained in:
Tony Garnock-Jones 2021-10-07 21:29:01 +02:00
parent 0837606ca7
commit 733037f41b
1 changed files with 7 additions and 0 deletions

View File

@ -74,6 +74,7 @@ pub enum Expr {
template: AnyValue,
},
Dataspace,
Timestamp,
}
#[derive(Debug, Clone)]
@ -426,6 +427,7 @@ impl Env {
match e {
Expr::Template { template } => self.instantiate_value(template),
Expr::Dataspace => Ok(AnyValue::domain(Cap::new(&t.create(Dataspace::new())))),
Expr::Timestamp => Ok(AnyValue::new(chrono::Utc::now().to_rfc3339())),
}
}
@ -763,6 +765,11 @@ impl<'t> Parser<'t> {
return Some(Expr::Dataspace);
}
if self.peek() == &Value::symbol("timestamp") {
self.drop();
return Some(Expr::Timestamp);
}
return Some(Expr::Template{ template: self.shift() });
}
}