-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshared.py
More file actions
34 lines (29 loc) · 784 Bytes
/
shared.py
File metadata and controls
34 lines (29 loc) · 784 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
32
33
34
from enum import Enum
# The program node.
program = None
# A list of lines of the Arrow code currently being processed.
code = None
#
class ReturnException(Exception):
"""
Used by Arrow functions to return.
"""
def __init__(self):
pass
class ArrowException(Exception):
"""
A base class for exceptions thrown by the interpreter.
Takes
-- the stage in which the error occurred.
-- the error message.
-- the token it occurred on (containing line number information).
"""
def __init__(self, stage, message, token):
self.stage = stage
self.message = message
self.token = token
# The possible states the interpreter can be in.
class Stages(Enum):
scanning = 1
parsing = 2
evaluation = 3