forked from JessicaDouthit00/C-Compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAST.py
More file actions
40 lines (28 loc) · 1.02 KB
/
SAST.py
File metadata and controls
40 lines (28 loc) · 1.02 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
"""
Author: Ariana Meatchem, Jessica Douthit, Deanna M. Wilborne
Created: 2025-04-08
Purpose: Simple Abstract Syntax Tree Class
Course: 25SP.CSC486 - Compiler Design & Interpretation
History:
2025-04-08, DMW, created
"""
# noinspection SpellCheckingInspection
class SAST:
def __init__(self, name: str, value: {} = None, struct: {} = None, parent=None,
children: [] = None, lineno: int = None, lexpos: int = None) -> None:
self.name = name
self.parent = parent
if value is None:
self.value = {'type': None}
else:
self.value = value
if struct is None:
self.struct = {'term': False}
else:
self.struct = struct
# 2023-04-16, DWM, line and index is based on:
# https://my.eng.utah.edu/~cs3100/lectures/l14/ply-3.4/doc/ply.html#ply_nn33
self.lineno = lineno
self.lexpos = lexpos
if children is not None:
self.children = children