mod expr; mod statement; use std::fmt; use expr::{ Expr, Literal, Variable, BinaryOperator, }; use statement::Stat; use statement::Block; use statement::GlobalBlock; pub trait GazType { fn get_base(&self) -> BaseType; } #[derive(Copy, Clone)] pub enum Quantifier { Const, Var, Unset, } impl Default for Quantifier { fn default() -> Self { Quantifier::Unset } } impl ToString for Quantifier { fn to_string(&self) -> String { match *self { Quantifier::Const => "const", Quantifier::Var => "var", Quantifier::Unset => panic!("Found unset quantifier"), }.to_string() } } #[derive(Copy, Clone, Eq)] pub enum BaseType { Int, Real, Never, Unset, } impl Default for BaseType { fn default() -> Self { BaseType::Unset } } impl ToString for BaseType { fn to_string(&self) -> String { // TODO: Use typedefs when possible. Might fit better on a high level node match *self { BaseType::Int => "integer", BaseType::Real => "real", BaseType::Never => panic!("Attempting to get string of never type"), BaseType::Unset => panic!("Found unset basetype"), }.to_string() } } impl fmt::Debug for BaseType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let name = match self { BaseType::Int => "integer", BaseType::Real => "real", BaseType::Never => "never", BaseType::Unset => "unset", }; write!(f, "{}", name) } } impl PartialEq for BaseType { fn eq(&self, other: &Self) -> bool { match (self, other) { (&BaseType::Int, &BaseType::Int) => true, (&BaseType::Real, &BaseType::Real) => true, (&BaseType::Never, &BaseType::Never) => true, (&BaseType::Unset, &BaseType::Unset) => false, _ => false, } } }