We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 784b0fb commit c2b63f5Copy full SHA for c2b63f5
src/syntactes/parser/exception.py
@@ -0,0 +1,21 @@
1
+class ParserError(Exception): ...
2
+
3
4
+class UnexpectedTokenError(ParserError):
5
+ """
6
+ A token was received that does not map to an action. The stream of tokens
7
+ is syntactically invalid.
8
9
10
+ def __init__(self, received_token, expected_tokens):
11
+ self.received_token = received_token
12
+ self.expected_tokens = expected_tokens
13
+ msg = f"Received token: {received_token}; expected one of: {[str(e) for e in expected_tokens]}"
14
+ super().__init__(msg)
15
16
17
+class NotAcceptedError(ParserError):
18
19
+ The parser did not receive an accept action. The stream of tokens is
20
+ syntactically invalid.
21
0 commit comments