Literals
This commit is contained in:
parent
93309c025e
commit
217ee73fc9
@ -170,7 +170,7 @@ impl<'a> Infer<'a> {
|
|||||||
let mut ret = MonoType::Const(TypeConst::Unit);
|
let mut ret = MonoType::Const(TypeConst::Unit);
|
||||||
for s in block {
|
for s in block {
|
||||||
ret = match s {
|
ret = match s {
|
||||||
parsing::Statement::ExpressionStatement(expr) => self.expression(expr)?,
|
parsing::Statement::ExpressionStatement(expr) => self.anno_expression(expr)?,
|
||||||
parsing::Statement::Declaration(decl) => {
|
parsing::Statement::Declaration(decl) => {
|
||||||
self.declaration(decl)?;
|
self.declaration(decl)?;
|
||||||
MonoType::Const(TypeConst::Unit)
|
MonoType::Const(TypeConst::Unit)
|
||||||
@ -184,8 +184,32 @@ impl<'a> Infer<'a> {
|
|||||||
Ok(MonoType::Const(TypeConst::Unit))
|
Ok(MonoType::Const(TypeConst::Unit))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expression(&mut self, expr: &parsing::Expression) -> InferResult<MonoType> {
|
fn anno_expression(&mut self, expr: &parsing::Expression) -> InferResult<MonoType> {
|
||||||
Ok(MonoType::Const(TypeConst::Unit))
|
match expr {
|
||||||
|
parsing::Expression(e, Some(anno)) => {
|
||||||
|
return Err(InferError::Custom(format!("Annotations not done yet")))
|
||||||
|
/*
|
||||||
|
let anno_ty = anno.to_type()?;
|
||||||
|
let ty = self.infer_exprtype(&e)?;
|
||||||
|
self.unify(ty, anno_ty)
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
parsing::Expression(e, None) => self.expression(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expression(&mut self, expr: &parsing::ExpressionType) -> InferResult<MonoType> {
|
||||||
|
use self::parsing::ExpressionType::*;
|
||||||
|
Ok(match expr {
|
||||||
|
NatLiteral(_) => MonoType::Const(TypeConst::Nat),
|
||||||
|
FloatLiteral(_) => MonoType::Const(TypeConst::Float),
|
||||||
|
StringLiteral(_) => MonoType::Const(TypeConst::StringT),
|
||||||
|
BoolLiteral(_) => MonoType::Const(TypeConst::Bool),
|
||||||
|
Value(v) => {
|
||||||
|
unimplemented!()
|
||||||
|
},
|
||||||
|
_ => return Err(InferError::Custom(format!("this expression type not done yet")))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user