-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptions.py
More file actions
31 lines (27 loc) · 1018 Bytes
/
Copy pathExceptions.py
File metadata and controls
31 lines (27 loc) · 1018 Bytes
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
class ParseException(Exception):
def __init__(self, line, expected, got):
self.line = line
self.expected = expected
self.got = got
def __str__(self):
return "Error at %d: expected %s, but got %s" % (self.line, self.expected, self.got)
class LexException(Exception):
def __init__(self, line, got):
self.line = line
self.got = got
def __str__(self):
return "Error at %d: invalid symbol %c" % (self.line, self.got)
class SubException(Exception):
def __init__(self, node):
self.node = node
def __str__(self):
return "Error: sub not implemented for " + self.node
class ProofException(Exception):
def __init__(self, rule, expr, reason, proof):
self.rule = rule
self.expr = expr
self.reason = reason
self.proof = proof
def print(self):
self.proof.print_proof()
print("Error: proof rule %s can't be applies to %s, because %s" % (self.rule, str(self.expr), self.reason))