diff --git a/cc_code_preview/Preview/classes.cc b/cc_code_preview/Preview/classes.cc new file mode 100644 index 0000000..621a9e9 --- /dev/null +++ b/cc_code_preview/Preview/classes.cc @@ -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; + } + } +} \ No newline at end of file diff --git a/cc_code_preview/Preview/functions.cc b/cc_code_preview/Preview/functions.cc new file mode 100644 index 0000000..3deeddc --- /dev/null +++ b/cc_code_preview/Preview/functions.cc @@ -0,0 +1,5 @@ +public lib Preview.Functions { + public func isTrue(value: bool): bool { + return value; + } +} \ No newline at end of file diff --git a/cc_code_preview/Preview/variables.cc b/cc_code_preview/Preview/variables.cc new file mode 100644 index 0000000..2140abe --- /dev/null +++ b/cc_code_preview/Preview/variables.cc @@ -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); +} \ No newline at end of file diff --git a/cc_code_preview/Program/main.cc b/cc_code_preview/Program/main.cc new file mode 100644 index 0000000..f271c5e --- /dev/null +++ b/cc_code_preview/Program/main.cc @@ -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()); + } + } +} \ No newline at end of file diff --git a/cpl-workspace.json b/cpl-workspace.json index 5294190..c3c5d8e 100644 --- a/cpl-workspace.json +++ b/cpl-workspace.json @@ -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" } } } \ No newline at end of file diff --git a/old/src/ServiceInitializer.py b/old/src/ServiceInitializer.py index a2faea2..becc5ff 100644 --- a/old/src/ServiceInitializer.py +++ b/old/src/ServiceInitializer.py @@ -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) diff --git a/old/src/cclang.py b/old/src/cclang.py index e33045d..f31825d 100644 --- a/old/src/cclang.py +++ b/old/src/cclang.py @@ -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__': diff --git a/src/cc_lang/cc-lang.json b/src/cc_lang/cc-lang.json index bd23212..34a6b80 100644 --- a/src/cc_lang/cc-lang.json +++ b/src/cc_lang/cc-lang.json @@ -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": [ diff --git a/src/cc_lang_interpreter/__init__.py b/src/cc_lang_interpreter/__init__.py new file mode 100644 index 0000000..ad5eca3 --- /dev/null +++ b/src/cc_lang_interpreter/__init__.py @@ -0,0 +1 @@ +# imports: diff --git a/src/cc_lang/application.py b/src/cc_lang_interpreter/application.py similarity index 50% rename from src/cc_lang/application.py rename to src/cc_lang_interpreter/application.py index 0a98353..bddf84d 100644 --- a/src/cc_lang/application.py +++ b/src/cc_lang_interpreter/application.py @@ -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() diff --git a/src/cc_lang_interpreter/cc-lang-interpreter.json b/src/cc_lang_interpreter/cc-lang-interpreter.json new file mode 100644 index 0000000..3f2ea2b --- /dev/null +++ b/src/cc_lang_interpreter/cc-lang-interpreter.json @@ -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": [] + } +} \ No newline at end of file diff --git a/src/cc_lang/main.py b/src/cc_lang_interpreter/main.py similarity index 67% rename from src/cc_lang/main.py rename to src/cc_lang_interpreter/main.py index 23aedce..808d05d 100644 --- a/src/cc_lang/main.py +++ b/src/cc_lang_interpreter/main.py @@ -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(): diff --git a/src/cc_lang/startup.py b/src/cc_lang_interpreter/startup.py similarity index 62% rename from src/cc_lang/startup.py rename to src/cc_lang_interpreter/startup.py index 8988cf3..f84d94a 100644 --- a/src/cc_lang/startup.py +++ b/src/cc_lang_interpreter/startup.py @@ -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() diff --git a/src/lexer/__init__.py b/src/lexer/__init__.py index ad5eca3..425ab6c 100644 --- a/src/lexer/__init__.py +++ b/src/lexer/__init__.py @@ -1 +1 @@ -# imports: +# imports diff --git a/src/lexer/abc/__init__.py b/src/lexer/abc/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/lexer/abc/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/lexer/abc/lexer_abc.py b/src/lexer/abc/lexer_abc.py new file mode 100644 index 0000000..4c892e5 --- /dev/null +++ b/src/lexer/abc/lexer_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class LexerABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/lexer/lexer.json b/src/lexer/lexer.json index db992e1..ece0188 100644 --- a/src/lexer/lexer.json +++ b/src/lexer/lexer.json @@ -28,8 +28,8 @@ "ProjectType": "library", "SourcePath": "", "OutputPath": "../../dist", - "Main": "lexer.main", - "EntryPoint": "lexer", + "Main": "", + "EntryPoint": "", "IncludePackageData": false, "Included": [], "Excluded": [ diff --git a/src/lexer/service/__init__.py b/src/lexer/service/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/lexer/service/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/lexer/service/lexer_service.py b/src/lexer/service/lexer_service.py new file mode 100644 index 0000000..397174e --- /dev/null +++ b/src/lexer/service/lexer_service.py @@ -0,0 +1,7 @@ +from lexer.abc.lexer_abc import LexerABC + + +class LexerService(LexerABC): + + def __init__(self): + pass diff --git a/src/parser/parser.json b/src/parser/parser.json index 61f93ca..16923bd 100644 --- a/src/parser/parser.json +++ b/src/parser/parser.json @@ -28,8 +28,8 @@ "ProjectType": "library", "SourcePath": "", "OutputPath": "../../dist", - "Main": "parser.main", - "EntryPoint": "parser", + "Main": "", + "EntryPoint": "", "IncludePackageData": false, "Included": [], "Excluded": [ diff --git a/src/runtime/__init__.py b/src/runtime/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/runtime/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/runtime/abc/__init__.py b/src/runtime/abc/__init__.py new file mode 100644 index 0000000..425ab6c --- /dev/null +++ b/src/runtime/abc/__init__.py @@ -0,0 +1 @@ +# imports diff --git a/src/runtime/abc/class_stack_abc.py b/src/runtime/abc/class_stack_abc.py new file mode 100644 index 0000000..d1ef3e6 --- /dev/null +++ b/src/runtime/abc/class_stack_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class ClassStackABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/runtime/abc/function_stack_abc.py b/src/runtime/abc/function_stack_abc.py new file mode 100644 index 0000000..c2df524 --- /dev/null +++ b/src/runtime/abc/function_stack_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class FunctionStackABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/runtime/abc/library_stack_abc.py b/src/runtime/abc/library_stack_abc.py new file mode 100644 index 0000000..836e7cd --- /dev/null +++ b/src/runtime/abc/library_stack_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class LibraryStackABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/runtime/abc/variable_stack_abc.py b/src/runtime/abc/variable_stack_abc.py new file mode 100644 index 0000000..06b3a7e --- /dev/null +++ b/src/runtime/abc/variable_stack_abc.py @@ -0,0 +1,7 @@ +from abc import ABC, abstractmethod + + +class VariableStackABC(ABC): + + @abstractmethod + def __init__(self): pass diff --git a/src/runtime/runtime.json b/src/runtime/runtime.json new file mode 100644 index 0000000..436f695 --- /dev/null +++ b/src/runtime/runtime.json @@ -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": [] + } +} \ No newline at end of file