Improved workspace structure

This commit is contained in:
Sven Heidemann 2021-08-02 15:58:05 +02:00
parent 1577c78c51
commit a97de91fc4
27 changed files with 222 additions and 20 deletions

View File

@ -0,0 +1,13 @@
public lib Preview.Classes {
public class Test {
private var _name: string;
public constructor(name: string) {
this._name = name;
}
public getName(): string {
return this._name;
}
}
}

View File

@ -0,0 +1,5 @@
public lib Preview.Functions {
public func isTrue(value: bool): bool {
return value;
}
}

View File

@ -0,0 +1,8 @@
public lib Preview.Variables {
public var str: string = "Hello World";
public var test: bool = false;
public var test2: Test = empty;
public var test3: Test = Test(34);
}

View File

@ -0,0 +1,19 @@
use Preview.Variables;
use Preview.Functions;
use Preview.Classes;
public lib Main {
public class Program {
private var test: Test;
public constructor() {
this.test = Test(str);
}
public func Main(): void {
output(str, test, test2, test3);
output(isTrue(test));
output(this.test.getName());
}
}
}

View File

@ -4,7 +4,9 @@
"Projects": {
"cc-lang": "src/cc_lang/cc-lang.json",
"parser": "src/parser/parser.json",
"lexer": "src/lexer/lexer.json"
"lexer": "src/lexer/lexer.json",
"runtime": "src/runtime/runtime.json",
"cc-lang-interpreter": "src/cc_lang_interpreter/cc-lang-interpreter.json"
}
}
}

View File

@ -1,5 +1,5 @@
from Interpreter.Interpreter import Interpreter
from CCLang_sly.Interpreter import Interpreter as SlyCCLangInterpreter
# from CCLang_sly.Interpreter import Interpreter as SlyCCLangInterpreter
from Interpreter.Utils import Utils
from Interpreter.Repo import Repo
@ -10,4 +10,4 @@ class ServiceInitializer:
self.repo = Repo()
self.utils = Utils(self.repo)
self.interpreter = Interpreter(self.repo, self.utils)
self.sly_cclang_interpreter = SlyCCLangInterpreter(self.repo, self.utils)
# self.sly_cclang_interpreter = SlyCCLangInterpreter(self.repo, self.utils)

View File

@ -12,7 +12,7 @@ class Main:
self.__utils = self.__services.utils
self.__repo = self.__services.repo
self.__interpreter = self.__services.interpreter
self.__sly_cclang_interpreter = self.__services.sly_cclang_interpreter
# self.__sly_cclang_interpreter = self.__services.sly_cclang_interpreter
def console(self) -> None:
"""
@ -22,8 +22,8 @@ class Main:
i = 0
while self.__repo.error is None:
self.__repo.line_number = i + 1
#self.__interpreter.interpret(input('> '))
self.__sly_cclang_interpreter.interpret(input('> '))
self.__interpreter.interpret(input('> '))
# self.__sly_cclang_interpreter.interpret(input('> '))
i += 1
def files(self, file: str) -> None:
@ -43,8 +43,8 @@ class Main:
f = open(file, 'r', encoding='utf-8').readlines()
for i in range(0, len(f)):
self.__repo.line_number = i + 1
# self.__interpreter.interpret(f[i])
self.__sly_cclang_interpreter.interpret(f[i])
self.__interpreter.interpret(f[i])
# self.__sly_cclang_interpreter.interpret(f[i])
if __name__ == '__main__':

View File

@ -25,11 +25,11 @@
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "console",
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "cc_lang.main",
"EntryPoint": "cc-lang",
"Main": "",
"EntryPoint": "",
"IncludePackageData": false,
"Included": [],
"Excluded": [

View File

@ -0,0 +1 @@
# imports:

View File

@ -3,14 +3,28 @@ from cpl.configuration import ConfigurationABC
from cpl.console import Console
from cpl.dependency_injection import ServiceProviderABC
from lexer.abc.lexer_abc import LexerABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
self._lexer: LexerABC = services.get_service(LexerABC)
self._path = config.get_configuration('p')
def _console(self): pass
def _files(self): pass
def configure(self):
pass
def main(self):
Console.write_line('Hello World')
Console.write_line(self._configuration.additional_arguments, self._path)
if self._path is None:
self._console()
return
self._files()

View File

@ -0,0 +1,43 @@
{
"ProjectSettings": {
"Name": "cc-lang-interpreter",
"Version": {
"Major": "0",
"Minor": "0",
"Micro": "0"
},
"Author": "",
"AuthorEmail": "",
"Description": "",
"LongDescription": "",
"URL": "",
"CopyrightDate": "",
"CopyrightName": "",
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"sh_cpl==2021.4.0.post2"
],
"PythonVersion": ">=3.9.2",
"PythonPath": {
"linux": ""
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "console",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "cc_lang_interpreter.main",
"EntryPoint": "cc-lang-interpreter",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {},
"ProjectReferences": []
}
}

View File

@ -1,7 +1,7 @@
from cpl.application import ApplicationBuilder
from cc_lang.application import Application
from cc_lang.startup import Startup
from cc_lang_interpreter.application import Application
from cc_lang_interpreter.startup import Startup
def main():

View File

@ -1,7 +1,10 @@
from cpl.application import StartupABC
from cpl.configuration import ConfigurationABC
from cpl.configuration import ConfigurationABC, ConsoleArgument
from cpl.dependency_injection import ServiceProviderABC, ServiceCollectionABC
from lexer.abc.lexer_abc import LexerABC
from lexer.service.lexer_service import LexerService
class Startup(StartupABC):
@ -13,7 +16,12 @@ class Startup(StartupABC):
self._services = services
def configure_configuration(self) -> ConfigurationABC:
self._configuration.add_console_argument(ConsoleArgument('-', 'p', [], ' '))
self._configuration.add_console_arguments()
return self._configuration
def configure_services(self) -> ServiceProviderABC:
self._services.add_singleton(LexerABC, LexerService)
return self._services.build_service_provider()

View File

@ -1 +1 @@
# imports:
# imports

View File

@ -0,0 +1 @@
# imports

View File

@ -0,0 +1,7 @@
from abc import ABC, abstractmethod
class LexerABC(ABC):
@abstractmethod
def __init__(self): pass

View File

@ -28,8 +28,8 @@
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "lexer.main",
"EntryPoint": "lexer",
"Main": "",
"EntryPoint": "",
"IncludePackageData": false,
"Included": [],
"Excluded": [

View File

@ -0,0 +1 @@
# imports

View File

@ -0,0 +1,7 @@
from lexer.abc.lexer_abc import LexerABC
class LexerService(LexerABC):
def __init__(self):
pass

View File

@ -28,8 +28,8 @@
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "parser.main",
"EntryPoint": "parser",
"Main": "",
"EntryPoint": "",
"IncludePackageData": false,
"Included": [],
"Excluded": [

1
src/runtime/__init__.py Normal file
View File

@ -0,0 +1 @@
# imports

View File

@ -0,0 +1 @@
# imports

View File

@ -0,0 +1,7 @@
from abc import ABC, abstractmethod
class ClassStackABC(ABC):
@abstractmethod
def __init__(self): pass

View File

@ -0,0 +1,7 @@
from abc import ABC, abstractmethod
class FunctionStackABC(ABC):
@abstractmethod
def __init__(self): pass

View File

@ -0,0 +1,7 @@
from abc import ABC, abstractmethod
class LibraryStackABC(ABC):
@abstractmethod
def __init__(self): pass

View File

@ -0,0 +1,7 @@
from abc import ABC, abstractmethod
class VariableStackABC(ABC):
@abstractmethod
def __init__(self): pass

43
src/runtime/runtime.json Normal file
View File

@ -0,0 +1,43 @@
{
"ProjectSettings": {
"Name": "runtime",
"Version": {
"Major": "0",
"Minor": "0",
"Micro": "0"
},
"Author": "",
"AuthorEmail": "",
"Description": "",
"LongDescription": "",
"URL": "",
"CopyrightDate": "",
"CopyrightName": "",
"LicenseName": "",
"LicenseDescription": "",
"Dependencies": [
"sh_cpl==2021.4.0.post2"
],
"PythonVersion": ">=3.9.2",
"PythonPath": {
"linux": ""
},
"Classifiers": []
},
"BuildSettings": {
"ProjectType": "library",
"SourcePath": "",
"OutputPath": "../../dist",
"Main": "",
"EntryPoint": "",
"IncludePackageData": false,
"Included": [],
"Excluded": [
"*/__pycache__",
"*/logs",
"*/tests"
],
"PackageData": {},
"ProjectReferences": []
}
}