added parser logic
This commit is contained in:
33
src/Models/Interpreter/Error.py
Normal file
33
src/Models/Interpreter/Error.py
Normal file
@@ -0,0 +1,33 @@
|
||||
class Error:
|
||||
|
||||
def __init__(self, code: float, msg: str = ''):
|
||||
self.code = code
|
||||
|
||||
self.__msgs = {
|
||||
# Interpreter:
|
||||
1.0: 'Start failed',
|
||||
1.1: 'File not found',
|
||||
|
||||
# Runtime:
|
||||
2.0: 'Unknown keyword',
|
||||
2.1: 'Unknown type',
|
||||
2.2: 'Unknown variable',
|
||||
2.3: 'Unknown function',
|
||||
2.4: 'Unknown class',
|
||||
2.5: 'Unknown library',
|
||||
2.6: 'Access error: no export',
|
||||
2.7: 'Expression error',
|
||||
2.8: 'Unexpected end of line',
|
||||
2.9: 'Unexpected {}', # other types
|
||||
|
||||
# Parser:
|
||||
3.0: 'Lib in lib',
|
||||
3.1: 'Lib in class',
|
||||
3.2: 'Lib in func',
|
||||
3.3: 'Class in class',
|
||||
3.4: 'Class in func',
|
||||
3.5: 'Func in lib',
|
||||
3.6: 'Func in func',
|
||||
}
|
||||
|
||||
self.msg = self.__msgs[code].format(msg)
|
6
src/Models/Language/AST/Class.py
Normal file
6
src/Models/Language/AST/Class.py
Normal file
@@ -0,0 +1,6 @@
|
||||
class Class:
|
||||
|
||||
def __init__(self, name: str, access: str = '') -> None:
|
||||
self.name = name
|
||||
self.ast = []
|
||||
self.access = access
|
6
src/Models/Language/AST/Func.py
Normal file
6
src/Models/Language/AST/Func.py
Normal file
@@ -0,0 +1,6 @@
|
||||
class Func:
|
||||
|
||||
def __init__(self, name: str, access: str = '') -> None:
|
||||
self.name = name
|
||||
self.ast = []
|
||||
self.access = access
|
5
src/Models/Language/AST/Lib.py
Normal file
5
src/Models/Language/AST/Lib.py
Normal file
@@ -0,0 +1,5 @@
|
||||
class Lib:
|
||||
|
||||
def __init__(self, name: str) -> None:
|
||||
self.name = name
|
||||
self.ast = []
|
0
src/Models/Language/AST/__init__.py
Normal file
0
src/Models/Language/AST/__init__.py
Normal file
@@ -1,5 +0,0 @@
|
||||
class Error:
|
||||
|
||||
def __init__(self, code: float, msg: str):
|
||||
self.code = code
|
||||
self.msg = msg
|
Reference in New Issue
Block a user