-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTNode.py
More file actions
47 lines (39 loc) · 1.49 KB
/
ASTNode.py
File metadata and controls
47 lines (39 loc) · 1.49 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
# Dominic Stencel
# CSC 330 100
# Session 7
# Final Project - AstNode Class
# 4/12/2025
# Added import - WB
from ast import AST
####################################################
###### ASTNode ######
####################################################
class ASTNode(object):
pass
####################################################
###### BinOp ######
####################################################
''' Binary Operator class to represent all four binary operators (add, sub., mult., divide)
Can Combine all four since they all function the same where you have an:
expression to the left, an operator, and a expression to the right '''
class BinOp(ASTNode):
def __init__(self, leftNode, opNode, rightNode):
self.leftNode = leftNode
self.opNode = opNode
self.rightNode = rightNode
def __repr__(self):
return f'{self.token}'
####################################################
###### NumNode ######
####################################################
# Num Class to represent numbers and their value
class NumNode(ASTNode):
def __init__(self, token):
self.token= token
# Fixed spacing - WB
def __repr__(self):
return f'{self.token}'
####################################################
###### Deposit, Withdraw, CreateNew ######
####################################################
# These nodes will be included in the Parser class