From 9c6034f7aecad2b7251590b06e659e93c3ea76a7 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 2 Aug 2021 14:55:04 +0200 Subject: [PATCH] Added CPL workspace --- .gitignore | 3 +- src/CCLang_sly/__init__.py => LICENSE | 0 src/Interpreter/__init__.py => README.md | 0 appsettings.json | 15 +++++++ cpl-workspace.json | 10 +++++ {src => old/src}/Basic.py | 0 {src => old/src}/CCLang_sly/Interpreter.py | 0 {src => old/src}/CCLang_sly/Lexer.py | 0 {src => old/src}/CCLang_sly/Parser.py | 0 {src => old/src}/First.cc | 0 {src => old/src}/Interpreter/Interpreter.py | 0 {src => old/src}/Interpreter/Lexer.py | 0 {src => old/src}/Interpreter/Parser.py | 0 {src => old/src}/Interpreter/Repo.py | 0 {src => old/src}/Interpreter/Utils.py | 0 {src => old/src}/Interpreter/Validator.py | 0 .../AbstractSyntaxTree/AbstractSyntaxTree.py | 0 .../src}/Models/CCLang/TokenDefinition.py | 0 .../src}/Models/Interpreter/Datatypes.py | 0 {src => old/src}/Models/Interpreter/Error.py | 0 {src => old/src}/Models/Token/Token.py | 0 {src => old/src}/Models/Token/TokenTypes.py | 0 .../src}/Models/Token/TokenValueTypes.py | 0 {src => old/src}/ServiceInitializer.py | 0 {src => old/src}/cclang.py | 0 old/src/test.cc | 27 ++++++++++++ {src => old/src}/test.py | 0 src/cc_lang/__init__.py | 1 + src/cc_lang/application.py | 16 +++++++ src/cc_lang/cc-lang.json | 43 +++++++++++++++++++ src/cc_lang/main.py | 14 ++++++ src/cc_lang/startup.py | 19 ++++++++ src/lexer/__init__.py | 1 + src/lexer/lexer.json | 43 +++++++++++++++++++ src/parser/__init__.py | 1 + src/parser/parser.json | 43 +++++++++++++++++++ src/tests/__init__.py | 1 + 37 files changed, 236 insertions(+), 1 deletion(-) rename src/CCLang_sly/__init__.py => LICENSE (100%) rename src/Interpreter/__init__.py => README.md (100%) create mode 100644 appsettings.json create mode 100644 cpl-workspace.json rename {src => old/src}/Basic.py (100%) rename {src => old/src}/CCLang_sly/Interpreter.py (100%) rename {src => old/src}/CCLang_sly/Lexer.py (100%) rename {src => old/src}/CCLang_sly/Parser.py (100%) rename {src => old/src}/First.cc (100%) rename {src => old/src}/Interpreter/Interpreter.py (100%) rename {src => old/src}/Interpreter/Lexer.py (100%) rename {src => old/src}/Interpreter/Parser.py (100%) rename {src => old/src}/Interpreter/Repo.py (100%) rename {src => old/src}/Interpreter/Utils.py (100%) rename {src => old/src}/Interpreter/Validator.py (100%) rename {src => old/src}/Models/AbstractSyntaxTree/AbstractSyntaxTree.py (100%) rename {src => old/src}/Models/CCLang/TokenDefinition.py (100%) rename {src => old/src}/Models/Interpreter/Datatypes.py (100%) rename {src => old/src}/Models/Interpreter/Error.py (100%) rename {src => old/src}/Models/Token/Token.py (100%) rename {src => old/src}/Models/Token/TokenTypes.py (100%) rename {src => old/src}/Models/Token/TokenValueTypes.py (100%) rename {src => old/src}/ServiceInitializer.py (100%) rename {src => old/src}/cclang.py (100%) create mode 100644 old/src/test.cc rename {src => old/src}/test.py (100%) create mode 100644 src/cc_lang/__init__.py create mode 100644 src/cc_lang/application.py create mode 100644 src/cc_lang/cc-lang.json create mode 100644 src/cc_lang/main.py create mode 100644 src/cc_lang/startup.py create mode 100644 src/lexer/__init__.py create mode 100644 src/lexer/lexer.json create mode 100644 src/parser/__init__.py create mode 100644 src/parser/parser.json create mode 100644 src/tests/__init__.py diff --git a/.gitignore b/.gitignore index 274bcbb..ccae4b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyc -/.idea/ \ No newline at end of file +/.idea/ +venv \ No newline at end of file diff --git a/src/CCLang_sly/__init__.py b/LICENSE similarity index 100% rename from src/CCLang_sly/__init__.py rename to LICENSE diff --git a/src/Interpreter/__init__.py b/README.md similarity index 100% rename from src/Interpreter/__init__.py rename to README.md diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..629e6eb --- /dev/null +++ b/appsettings.json @@ -0,0 +1,15 @@ +{ + "TimeFormatSettings": { + "DateFormat": "%Y-%m-%d", + "TimeFormat": "%H:%M:%S", + "DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f", + "DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S" + }, + + "LoggingSettings": { + "Path": "logs/", + "Filename": "log_$start_time.log", + "ConsoleLogLevel": "ERROR", + "FileLogLevel": "WARN" + } +} diff --git a/cpl-workspace.json b/cpl-workspace.json new file mode 100644 index 0000000..5294190 --- /dev/null +++ b/cpl-workspace.json @@ -0,0 +1,10 @@ +{ + "WorkspaceSettings": { + "DefaultProject": "cc-lang", + "Projects": { + "cc-lang": "src/cc_lang/cc-lang.json", + "parser": "src/parser/parser.json", + "lexer": "src/lexer/lexer.json" + } + } +} \ No newline at end of file diff --git a/src/Basic.py b/old/src/Basic.py similarity index 100% rename from src/Basic.py rename to old/src/Basic.py diff --git a/src/CCLang_sly/Interpreter.py b/old/src/CCLang_sly/Interpreter.py similarity index 100% rename from src/CCLang_sly/Interpreter.py rename to old/src/CCLang_sly/Interpreter.py diff --git a/src/CCLang_sly/Lexer.py b/old/src/CCLang_sly/Lexer.py similarity index 100% rename from src/CCLang_sly/Lexer.py rename to old/src/CCLang_sly/Lexer.py diff --git a/src/CCLang_sly/Parser.py b/old/src/CCLang_sly/Parser.py similarity index 100% rename from src/CCLang_sly/Parser.py rename to old/src/CCLang_sly/Parser.py diff --git a/src/First.cc b/old/src/First.cc similarity index 100% rename from src/First.cc rename to old/src/First.cc diff --git a/src/Interpreter/Interpreter.py b/old/src/Interpreter/Interpreter.py similarity index 100% rename from src/Interpreter/Interpreter.py rename to old/src/Interpreter/Interpreter.py diff --git a/src/Interpreter/Lexer.py b/old/src/Interpreter/Lexer.py similarity index 100% rename from src/Interpreter/Lexer.py rename to old/src/Interpreter/Lexer.py diff --git a/src/Interpreter/Parser.py b/old/src/Interpreter/Parser.py similarity index 100% rename from src/Interpreter/Parser.py rename to old/src/Interpreter/Parser.py diff --git a/src/Interpreter/Repo.py b/old/src/Interpreter/Repo.py similarity index 100% rename from src/Interpreter/Repo.py rename to old/src/Interpreter/Repo.py diff --git a/src/Interpreter/Utils.py b/old/src/Interpreter/Utils.py similarity index 100% rename from src/Interpreter/Utils.py rename to old/src/Interpreter/Utils.py diff --git a/src/Interpreter/Validator.py b/old/src/Interpreter/Validator.py similarity index 100% rename from src/Interpreter/Validator.py rename to old/src/Interpreter/Validator.py diff --git a/src/Models/AbstractSyntaxTree/AbstractSyntaxTree.py b/old/src/Models/AbstractSyntaxTree/AbstractSyntaxTree.py similarity index 100% rename from src/Models/AbstractSyntaxTree/AbstractSyntaxTree.py rename to old/src/Models/AbstractSyntaxTree/AbstractSyntaxTree.py diff --git a/src/Models/CCLang/TokenDefinition.py b/old/src/Models/CCLang/TokenDefinition.py similarity index 100% rename from src/Models/CCLang/TokenDefinition.py rename to old/src/Models/CCLang/TokenDefinition.py diff --git a/src/Models/Interpreter/Datatypes.py b/old/src/Models/Interpreter/Datatypes.py similarity index 100% rename from src/Models/Interpreter/Datatypes.py rename to old/src/Models/Interpreter/Datatypes.py diff --git a/src/Models/Interpreter/Error.py b/old/src/Models/Interpreter/Error.py similarity index 100% rename from src/Models/Interpreter/Error.py rename to old/src/Models/Interpreter/Error.py diff --git a/src/Models/Token/Token.py b/old/src/Models/Token/Token.py similarity index 100% rename from src/Models/Token/Token.py rename to old/src/Models/Token/Token.py diff --git a/src/Models/Token/TokenTypes.py b/old/src/Models/Token/TokenTypes.py similarity index 100% rename from src/Models/Token/TokenTypes.py rename to old/src/Models/Token/TokenTypes.py diff --git a/src/Models/Token/TokenValueTypes.py b/old/src/Models/Token/TokenValueTypes.py similarity index 100% rename from src/Models/Token/TokenValueTypes.py rename to old/src/Models/Token/TokenValueTypes.py diff --git a/src/ServiceInitializer.py b/old/src/ServiceInitializer.py similarity index 100% rename from src/ServiceInitializer.py rename to old/src/ServiceInitializer.py diff --git a/src/cclang.py b/old/src/cclang.py similarity index 100% rename from src/cclang.py rename to old/src/cclang.py diff --git a/old/src/test.cc b/old/src/test.cc new file mode 100644 index 0000000..e478a04 --- /dev/null +++ b/old/src/test.cc @@ -0,0 +1,27 @@ +# olc test 1 +// olc test 2 +/* mlc Test 1 */ +/* + mlc Test 2 +*/ + + +public lib Main { + class Program { + var test: bool = false; + var test2: Program2 = empty; + var test3: Program2 = Test(34); + + func Main(): void { + #func Main { + var hallo: any; + #output('Hello'); + #output(this.isTrue(false)); + } + + func isTrue(value: bool): bool { + #func isTrue { + #return value; + } + } +} \ No newline at end of file diff --git a/src/test.py b/old/src/test.py similarity index 100% rename from src/test.py rename to old/src/test.py diff --git a/src/cc_lang/__init__.py b/src/cc_lang/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/cc_lang/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/cc_lang/application.py b/src/cc_lang/application.py new file mode 100644 index 0000000..0a98353 --- /dev/null +++ b/src/cc_lang/application.py @@ -0,0 +1,16 @@ +from cpl.application import ApplicationABC +from cpl.configuration import ConfigurationABC +from cpl.console import Console +from cpl.dependency_injection import ServiceProviderABC + + +class Application(ApplicationABC): + + def __init__(self, config: ConfigurationABC, services: ServiceProviderABC): + ApplicationABC.__init__(self, config, services) + + def configure(self): + pass + + def main(self): + Console.write_line('Hello World') diff --git a/src/cc_lang/cc-lang.json b/src/cc_lang/cc-lang.json new file mode 100644 index 0000000..bd23212 --- /dev/null +++ b/src/cc_lang/cc-lang.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "cc-lang", + "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.main", + "EntryPoint": "cc-lang", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/cc_lang/main.py b/src/cc_lang/main.py new file mode 100644 index 0000000..23aedce --- /dev/null +++ b/src/cc_lang/main.py @@ -0,0 +1,14 @@ +from cpl.application import ApplicationBuilder + +from cc_lang.application import Application +from cc_lang.startup import Startup + + +def main(): + app_builder = ApplicationBuilder(Application) + app_builder.use_startup(Startup) + app_builder.build().run() + + +if __name__ == '__main__': + main() diff --git a/src/cc_lang/startup.py b/src/cc_lang/startup.py new file mode 100644 index 0000000..8988cf3 --- /dev/null +++ b/src/cc_lang/startup.py @@ -0,0 +1,19 @@ +from cpl.application import StartupABC +from cpl.configuration import ConfigurationABC +from cpl.dependency_injection import ServiceProviderABC, ServiceCollectionABC + + +class Startup(StartupABC): + + def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC): + StartupABC.__init__(self) + + self._configuration = config + self._environment = self._configuration.environment + self._services = services + + def configure_configuration(self) -> ConfigurationABC: + return self._configuration + + def configure_services(self) -> ServiceProviderABC: + return self._services.build_service_provider() diff --git a/src/lexer/__init__.py b/src/lexer/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/lexer/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/lexer/lexer.json b/src/lexer/lexer.json new file mode 100644 index 0000000..db992e1 --- /dev/null +++ b/src/lexer/lexer.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "lexer", + "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": "lexer.main", + "EntryPoint": "lexer", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/parser/__init__.py b/src/parser/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/parser/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/parser/parser.json b/src/parser/parser.json new file mode 100644 index 0000000..61f93ca --- /dev/null +++ b/src/parser/parser.json @@ -0,0 +1,43 @@ +{ + "ProjectSettings": { + "Name": "parser", + "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": "parser.main", + "EntryPoint": "parser", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/tests/__init__.py @@ -0,0 +1 @@ +# imports: