-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclisp_execption.cpp
More file actions
78 lines (54 loc) · 2.37 KB
/
clisp_execption.cpp
File metadata and controls
78 lines (54 loc) · 2.37 KB
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
#include <utility>
//
// Created by cre-chan on 19-12-16.
//
#include "stdafx.h"
#include "clisp_execption.h"
UnrecognizedCharacter::UnrecognizedCharacter(char c, istream &in) :
LexingError(in), invalid_char(c) {
}
const string UnrecognizedCharacter::info() const noexcept {
return string("Unrecognizable character ") + invalid_char + " encountered.";
}
ClispError::ClispError(istream &in) :
exception() {
in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
InvalidToken::InvalidToken(istream &istream, string tok) : LexingError(istream), tok_name(std::move(tok)) {}
const string InvalidToken::info() const noexcept {
return "Invalid token found. Did you mean "+tok_name+"?";
}
UnmatchingBracket::UnmatchingBracket(istream &istream) : ClispError(istream) {}
const string UnmatchingBracket::info() const noexcept {
return "More enclosing brackets than opening brackets.";
}
PrimaryIsNotCallable::PrimaryIsNotCallable(istream &istream, unique_ptr<Expr> expr) : ClispError(istream),
expr(std::move(expr)) {}
const string PrimaryIsNotCallable::info() const noexcept {
return "Primary expression cannot be applied to arguments.";
}
ExpectingExpr::ExpectingExpr(istream &istream) : ClispError(istream) {}
const string ExpectingExpr::info() const noexcept {
return "Expecting expression while a token is found.";
}
EmptyExpr::EmptyExpr(istream &istream) : ClispError(istream) {}
const string EmptyExpr::info() const noexcept {
return "Empty expression enclosed by brackets.";
}
ExpectingOperands::ExpectingOperands(istream &istream, uint argNum) : ClispError(istream), arg_num(argNum) {}
const string ExpectingOperands::info() const noexcept {
return "Not enough operands or too many operands found.";
}
ExpectingIdOrArglist::ExpectingIdOrArglist(istream &istream) : ClispError(istream) {}
const string ExpectingIdOrArglist::info() const noexcept {
return "Expecting identifier or argument list.";
}
NormalExit::NormalExit() {}
const char *NormalExit::what() const noexcept {
return "Thank you for using CLisp";
}
UnexpectedEOF::UnexpectedEOF(istream &istream) : ClispError(istream) {}
const string UnexpectedEOF::info() const noexcept {
return "Unexpected end of file.";
}
LexingError::LexingError(istream &istream) : ClispError(istream) {}