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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Exception {
    /// = -1, ANS Forth
    Abort = -1,
    /// = -2, ANS Forth
    AbortQuote = -2,
    /// = -3, ANS Forth
    StackOverflow = -3,
    /// = -4, ANS Forth
    StackUnderflow = -4,
    /// = -5, ANS Forth
    ReturnStackOverflow = -5,
    /// = -6, ANS Forth
    ReturnStackUnderflow = -6,
    /// = -7, ANS Forth
    DoLoopNestedTooDeeply = -7,
    /// = -8, ANS Forth
    DictionaryOverflow = -8,
    /// = -9, ANS Forth
    InvalidMemoryAddress = -9,
    /// = -10, ANS Forth
    DivisionByZero = -10,
    /// = -11, ANS Forth
    ResultOutOfRange = -11,
    /// = -12, ANS Forth
    ArgumentTypeMismatch = -12,
    /// = -13, ANS Forth
    UndefinedWord = -13,
    /// = -14, ANS Forth
    InterpretingACompileOnlyWord = -14,
    /// = -15, ANS Forth
    InvalidForget = -15,
    /// = -16, ANS Forth
    AttemptToUseZeroLengthString = -16,
    /// = -17, ANS Forth
    PicturedNumericOutputStringOverflow = -17,
    /// = -18, ANS Forth
    ParsedStringOverflow = -18,
    /// = -19, ANS Forth
    DefinitionNameTooLong = -19,
    /// = -20, ANS Forth
    WriteToAReadOnlyLocation = -20,
    /// = -21, ANS Forth
    UnsupportedOperation = -21,
    /// = -22, ANS Forth
    ControlStructureMismatch = -22,
    /// = -23, ANS Forth
    AddressAlignmentException = -23,
    /// = -24, ANS Forth
    InvalidNumericArgument = -24,
    /// = -25, ANS Forth
    ReturnStackImbalance = -25,
    /// = -26, ANS Forth
    LoopParametersUnavailable = -26,
    /// = -27, ANS Forth
    InvalidRecursion = -27,
    /// = -28, ANS Forth
    UserInterrupt = -28,
    /// = -29, ANS Forth
    CompilerNesting = -29,
    /// = -30, ANS Forth
    ObsolescentFeature = -30,
    /// = -31, ANS Forth
    ToBodyUsedOnNonCreatedDefinition = -31,
    /// = -32, ANS Forth
    InvalidNameArgument = -32,
    /// = -33, ANS Forth
    BlockReadException = -33,
    /// = -34, ANS Forth
    BlockWriteException = -34,
    /// = -35, ANS Forth
    InvalidBlockNumber = -35,
    /// = -36, ANS Forth
    InvalidFilePosition = -36,
    /// = -37, ANS Forth
    FileIOException = -37,
    /// = -38, ANS Forth
    NonExistentFile = -38,
    /// = -39, ANS Forth
    UnexpectedEndOfFile = -39,
    /// = -40, ANS Forth
    InvalidBaseForFloatingPointConversion = -40,
    /// = -41, ANS Forth
    LossOfPrecision = -41,
    /// = -42, ANS Forth
    FloatingPointDividedByZero = -42,
    /// = -43, ANS Forth
    FloatingPointResultOutOfRange = -43,
    /// = -44, ANS Forth
    FloatingPointStackOverflow = -44,
    /// = -45, ANS Forth
    FloatingPointStackUnderflow = -45,
    /// = -46, ANS Forth
    FloatingPointInvalidArgument = -46,
    /// = -47, ANS Forth
    CompilationWordListDeleted = -47,
    /// = -48, ANS Forth
    InvalidPostpone = -48,
    /// = -49, ANS Forth
    SearchOrderOverflow = -49,
    /// = -50, ANS Forth
    SearchOrderUnderflow = -50,
    /// = -51, ANS Forth
    CompilationWordListChanged = -51,
    /// = -52, ANS Forth
    ControlFlowStackOverflow = -52,
    /// = -53, ANS Forth
    ExceptionStackOverflow = -53,
    /// = -54, ANS Forth
    FloatingPointUnderflow = -54,
    /// = -55, ANS Forth
    FloatingPointUnidentifiedFault = -55,
    /// = -56, ANS Forth
    Quit = -56,
    /// = -57, ANS Forth
    ExceptionInSendingOrReceivingACharacter = -57,
    /// = -58, ANS Forth
    BracketIfElseOrThenException = -58,
}

impl Exception {
    /// Description of the exception
    pub fn description(&self) -> &'static str {
        match *self {
            Exception::Abort => "Aborted",
            Exception::AbortQuote => "Aborted",
            Exception::StackOverflow => "Stack overflow",
            Exception::StackUnderflow => "Stack underflow",
            Exception::ReturnStackOverflow => "Return stack overflow",
            Exception::ReturnStackUnderflow => "Return stack underflow",
            Exception::DoLoopNestedTooDeeply => "Do-loop nested too deeply",
            Exception::DictionaryOverflow => "Dictionary overflow",
            Exception::InvalidMemoryAddress => "Invalid memory address",
            Exception::DivisionByZero => "Division by zero",
            Exception::ResultOutOfRange => "Result out of range",
            Exception::ArgumentTypeMismatch => "Argument type mismatch",
            Exception::UndefinedWord => "Undefined word",
            Exception::InterpretingACompileOnlyWord => "Interpreting a compile only word",
            Exception::InvalidForget => "Invalid FORGET",
            Exception::AttemptToUseZeroLengthString => "Attempt to use zero length string",
            Exception::PicturedNumericOutputStringOverflow => {
                "Picture numeric output string overflow"
            }
            Exception::ParsedStringOverflow => "Parsed string overflow",
            Exception::DefinitionNameTooLong => "Definition name too long",
            Exception::WriteToAReadOnlyLocation => "Write to a read only location",
            Exception::UnsupportedOperation => "Unsupported operation",
            Exception::ControlStructureMismatch => "Control structure mismatch",
            Exception::AddressAlignmentException => "Address alignment exception",
            Exception::InvalidNumericArgument => "Invalid numeric argument",
            Exception::ReturnStackImbalance => "Return stack imbalance",
            Exception::LoopParametersUnavailable => "Loop parameters unavailable",
            Exception::InvalidRecursion => "Invalid recursion",
            Exception::UserInterrupt => "User interrupt",
            Exception::CompilerNesting => "Compiler nesting",
            Exception::ObsolescentFeature => "Obsolescent feature",
            Exception::ToBodyUsedOnNonCreatedDefinition => ">BODY used on non-CREATEd definition",
            Exception::InvalidNameArgument => "Invalid name argument",
            Exception::BlockReadException => "Block read exception",
            Exception::BlockWriteException => "Block write exception",
            Exception::InvalidBlockNumber => "Invalid block number",
            Exception::InvalidFilePosition => "Invalid file position",
            Exception::FileIOException => "File I/O exception",
            Exception::NonExistentFile => "Non-existent file",
            Exception::UnexpectedEndOfFile => "Unexpected end of file",
            Exception::InvalidBaseForFloatingPointConversion => {
                "Invalid BASE for floating point conversion"
            }
            Exception::LossOfPrecision => "Loss of precision",
            Exception::FloatingPointDividedByZero => "Floating point divided by zero",
            Exception::FloatingPointResultOutOfRange => "Floating point result out of range",
            Exception::FloatingPointStackOverflow => "Floating point stack overflow",
            Exception::FloatingPointStackUnderflow => "Floating point stack underflow",
            Exception::FloatingPointInvalidArgument => "Floating point invalid argument",
            Exception::CompilationWordListDeleted => "Compilation word list deleted",
            Exception::InvalidPostpone => "Invalid POSTPONE",
            Exception::SearchOrderOverflow => "Search order overflow",
            Exception::SearchOrderUnderflow => "Search order underflow",
            Exception::CompilationWordListChanged => "Compilation word list changed",
            Exception::ControlFlowStackOverflow => "Control flow stack overflow",
            Exception::ExceptionStackOverflow => "Exception stack overflow",
            Exception::FloatingPointUnderflow => "Floating point underflow",
            Exception::FloatingPointUnidentifiedFault => "Floating point unidentified fault",
            Exception::Quit => "QUIT",
            Exception::ExceptionInSendingOrReceivingACharacter => {
                "Exception in sending or receiving a character"
            }
            Exception::BracketIfElseOrThenException => "[IF],[ELSE],[THEN] exception",
        }
    }
}