-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpr.py
More file actions
101 lines (63 loc) · 1.85 KB
/
expr.py
File metadata and controls
101 lines (63 loc) · 1.85 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""Expression classes for the Lox interpreter."""
class Expr:
"""Base class for expressions."""
class Literal(Expr):
"""Literal expression."""
def __init__(self, value):
self.value = value
class Binary(Expr):
"""Binary expression."""
def __init__(self, left, operator, right):
self.left = left
self.operator = operator
self.right = right
class Unary(Expr):
"""Unary expression."""
def __init__(self, operator, right):
self.operator = operator
self.right = right
class Grouping(Expr):
"""Grouping expression."""
def __init__(self, expression):
self.expression = expression
class Variable(Expr):
"""Variable expression."""
def __init__(self, name):
self.name = name
class Assign(Expr):
"""Assignment expression."""
def __init__(self, name, value):
self.name = name
self.value = value
class Logical(Expr):
"""Logical expression (and/or)."""
def __init__(self, left, operator, right):
self.left = left
self.operator = operator
self.right = right
class Call(Expr):
"""Call expression."""
def __init__(self, callee, paren, arguments):
self.callee = callee
self.paren = paren
self.arguments = arguments
class Get(Expr):
"""Property get expression."""
def __init__(self, obj, name):
self.obj = obj
self.name = name
class Set(Expr):
"""Property set expression."""
def __init__(self, obj, name, value):
self.obj = obj
self.name = name
self.value = value
class This(Expr):
"""This expression."""
def __init__(self, keyword):
self.keyword = keyword
class Super(Expr):
"""Super expression."""
def __init__(self, keyword, method):
self.keyword = keyword
self.method = method