Improved parsing
This commit is contained in:
9
src/Models/AbstractSyntaxTree/AbstractSyntaxTree.py
Normal file
9
src/Models/AbstractSyntaxTree/AbstractSyntaxTree.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import List
|
||||
|
||||
from Models.Interpreter.Token import Token
|
||||
|
||||
|
||||
class AbstractSyntaxTree:
|
||||
|
||||
def __init__(self):
|
||||
self.tokens: List[Token] = []
|
13
src/Models/AbstractSyntaxTree/Class.py
Normal file
13
src/Models/AbstractSyntaxTree/Class.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from typing import List
|
||||
|
||||
from Models.AbstractSyntaxTree.Function import Function
|
||||
from Models.AbstractSyntaxTree.Variable import Variable
|
||||
|
||||
|
||||
class Class:
|
||||
|
||||
def __init__(self):
|
||||
self.name: str = ''
|
||||
self.variables: List[Variable] = []
|
||||
self.functions: List[Function] = []
|
||||
self.is_public = False
|
14
src/Models/AbstractSyntaxTree/Function.py
Normal file
14
src/Models/AbstractSyntaxTree/Function.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import List
|
||||
|
||||
from Models.AbstractSyntaxTree.Variable import Variable
|
||||
from Models.Interpreter.Types import Types
|
||||
|
||||
|
||||
class Function:
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.name: str = ''
|
||||
self.variables: List[Variable] = []
|
||||
self.instructions: [] = []
|
||||
self.return_type: Types = Types.Any
|
||||
self.is_public = False
|
9
src/Models/AbstractSyntaxTree/Instruction.py
Normal file
9
src/Models/AbstractSyntaxTree/Instruction.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from Models.AbstractSyntaxTree.AbstractSyntaxTree import AbstractSyntaxTree
|
||||
from Models.AbstractSyntaxTree.InstructionTypes import InstructionTypes
|
||||
|
||||
|
||||
class Instruction:
|
||||
|
||||
def __init__(self):
|
||||
self.type: InstructionTypes = InstructionTypes.Unknown
|
||||
self.ast: AbstractSyntaxTree = AbstractSyntaxTree()
|
10
src/Models/AbstractSyntaxTree/InstructionTypes.py
Normal file
10
src/Models/AbstractSyntaxTree/InstructionTypes.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class InstructionTypes(Enum):
|
||||
|
||||
Unknown = 0
|
||||
Expression = 1
|
||||
Bool_Expression = 2
|
||||
Assignment = 3
|
||||
Call = 4
|
11
src/Models/AbstractSyntaxTree/Library.py
Normal file
11
src/Models/AbstractSyntaxTree/Library.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import List
|
||||
|
||||
from Models.AbstractSyntaxTree.Class import Class
|
||||
|
||||
|
||||
class Library:
|
||||
|
||||
def __init__(self):
|
||||
self.name: str = ''
|
||||
self.classes: List[Class] = []
|
||||
self.is_public = False
|
@@ -0,0 +1,9 @@
|
||||
from typing import List
|
||||
|
||||
from Models.AbstractSyntaxTree.Library import Library
|
||||
|
||||
|
||||
class RuntimeAbstractSyntaxTree:
|
||||
|
||||
def __init__(self):
|
||||
self.libs: List[Library] = []
|
12
src/Models/AbstractSyntaxTree/Variable.py
Normal file
12
src/Models/AbstractSyntaxTree/Variable.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from typing import List
|
||||
|
||||
from Models.Interpreter.Token import Token
|
||||
|
||||
|
||||
class Variable:
|
||||
|
||||
def __init__(self):
|
||||
self.name: str = ''
|
||||
self.type: str = ''
|
||||
self.value: List[Token] = []
|
||||
self.is_public = False
|
0
src/Models/AbstractSyntaxTree/__init__.py
Normal file
0
src/Models/AbstractSyntaxTree/__init__.py
Normal file
Reference in New Issue
Block a user