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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use std::fmt;
pub type ZiaResult<T> = Result<T, ZiaError>;
#[derive(Debug)]
pub enum ZiaError {
RedundantReduction,
RedundantDefinition,
RedundantRefactor,
RedundantDefinitionRemoval,
NotAProgram,
BadDefinition,
CyclicReduction,
ExpandingReduction,
InfiniteDefinition,
EmptyParentheses,
AmbiguousExpression,
DefinitionCollision,
SettingDefinitionOfConcrete,
ConcreteReduction,
MultipleReductionPaths,
}
impl fmt::Display for ZiaError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", match *self {
ZiaError::RedundantReduction => "That reduction rule already exists.",
ZiaError::RedundantDefinition => "That definition already exists.",
ZiaError::RedundantRefactor => "Relabelling something that doesn't yet exist has no effect.",
ZiaError::RedundantDefinitionRemoval => "Removing a definition that doesn't exist is redundant.",
ZiaError::NotAProgram => "No program exists for this syntax.",
ZiaError::BadDefinition => "Cannot define expressions.",
ZiaError::CyclicReduction => "Cannot allow a chain of reduction rules to loop.",
ZiaError::ExpandingReduction => "Cannot reduce a concept to an expression containing itself.",
ZiaError::InfiniteDefinition => "Cannot define a concept as an expression containing itself.",
ZiaError::EmptyParentheses => "Parentheses need to contain a symbol or expression.",
ZiaError::AmbiguousExpression => "Ambiguity due to lack of precedence or associativity defined for the symbols in that expression.",
ZiaError::DefinitionCollision => "Cannot define a used symbol as another used symbol or expression.",
ZiaError::SettingDefinitionOfConcrete => "Cannot set a definition of a concrete concept",
ZiaError::ConcreteReduction => "Cannot reduce a concrete concept",
ZiaError::MultipleReductionPaths => "Concept is already composed of concepts with their own reduction rules."
})
}
}