2019-08-28 21:24:54 +03:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# Slang compilers
|
|
|
|
|
2024-01-11 02:55:07 +03:00
|
|
|
from ..ast import Slots, lstripcount, SlSyntaxError, SlNodeException, SlValidationError
|
2020-03-18 07:00:12 +03:00
|
|
|
import abc, traceback
|
2019-08-28 21:24:54 +03:00
|
|
|
|
|
|
|
class Compiler(abc.ABC):
|
2024-01-11 02:55:07 +03:00
|
|
|
ext = ''
|
|
|
|
|
2019-08-28 21:24:54 +03:00
|
|
|
@abc.abstractclassmethod
|
|
|
|
def compile_ast(cls, ast):
|
|
|
|
pass
|
|
|
|
|
2024-01-11 02:55:07 +03:00
|
|
|
class SlCompilationError(SlNodeException):
|
|
|
|
desc: ...
|
2019-08-28 21:24:54 +03:00
|
|
|
|
2024-01-11 02:55:07 +03:00
|
|
|
def __init__(self, desc, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.desc = desc
|
2019-08-28 21:24:54 +03:00
|
|
|
|
2024-01-11 02:55:07 +03:00
|
|
|
def __exline__(self):
|
|
|
|
return f"Compilation error: {self.desc}"
|
2019-08-28 21:24:54 +03:00
|
|
|
|
2024-01-11 02:55:07 +03:00
|
|
|
# by Sdore, 2021
|