1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![feature(box_syntax)]
extern crate asexp;
pub mod cond;
use std::fmt::Debug;
use std::cmp::{PartialEq, PartialOrd};
#[derive(Debug, Eq, PartialEq)]
pub enum ExpressionError {
DivByZero,
InvalidVariable,
InvalidOperation,
}
pub trait Expression: Debug + Clone + PartialEq
{
type Element: Debug + Copy + Clone + PartialEq + PartialOrd;
fn evaluate(&self, variables: &[Self::Element]) -> Result<Self::Element, ExpressionError>;
}
pub trait Condition: Debug + Clone + PartialEq
{
type Expr: Expression;
fn evaluate(&self,
variables: &[<Self::Expr as Expression>::Element])
-> Result<bool, ExpressionError>;
}