diff --git a/src/cc_lang/model/language_definition.py b/src/cc_lang/model/language_definition.py index 71f0263..c1417f1 100644 --- a/src/cc_lang/model/language_definition.py +++ b/src/cc_lang/model/language_definition.py @@ -32,6 +32,8 @@ class LanguageDefinition: Keywords.Foreach.value, # access Keywords.Public.value, + Keywords.Private.value, + Keywords.Static.value, Keywords.This.value ] datatypes = [ diff --git a/src/cc_lang/model/language_definition_classes.py b/src/cc_lang/model/language_definition_classes.py index 8713c28..6c0365b 100644 --- a/src/cc_lang/model/language_definition_classes.py +++ b/src/cc_lang/model/language_definition_classes.py @@ -33,6 +33,8 @@ class Keywords(Enum): # access Public = 'public' + Private = 'private' + Static = 'static' This = 'this' diff --git a/src/cc_lang_interpreter/application.py b/src/cc_lang_interpreter/application.py index 7fc8be5..e52b16f 100644 --- a/src/cc_lang_interpreter/application.py +++ b/src/cc_lang_interpreter/application.py @@ -1,9 +1,9 @@ import os -from cpl.application import ApplicationABC -from cpl.configuration import ConfigurationABC -from cpl.console import Console -from cpl.dependency_injection import ServiceProviderABC +from cpl_core.application import ApplicationABC +from cpl_core.configuration import ConfigurationABC +from cpl_core.console import Console +from cpl_core.dependency_injection import ServiceProviderABC from lexer.abc.lexer_abc import LexerABC from runtime.abc.runtime_service_abc import RuntimeServiceABC @@ -18,19 +18,22 @@ class Application(ApplicationABC): self._runtime: RuntimeServiceABC = services.get_service(RuntimeServiceABC) self._path = config.get_configuration('p') + Console.write_line('t', self._path) def _interpret(self, line: str): tokens = self._lexer.tokenize(line) line.replace("\n", "").replace("\t", "") - Console.write_line(f'\nLINE: {line}') - tokens.for_each(lambda t: Console.write_line(t.type, t.value)) + Console.write_line(f'<{self._runtime.line_count}> LINE: {line}') + header, values = ['Type', 'Value'], [] + tokens.for_each(lambda t: values.append([t.type, t.value])) + Console.table(header, values) def _console(self): i = 0 while True: self._runtime.line_count = i + 1 - self._interpret(input('> ')) + self._interpret(Console.read('> ')) i += 1 def _files(self): diff --git a/src/cc_lang_interpreter/cc-lang-interpreter.json b/src/cc_lang_interpreter/cc-lang-interpreter.json index 3f2ea2b..21a7165 100644 --- a/src/cc_lang_interpreter/cc-lang-interpreter.json +++ b/src/cc_lang_interpreter/cc-lang-interpreter.json @@ -16,7 +16,8 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "sh_cpl==2021.4.0.post2" + "sh_cpl-core==2021.10.0.post1", + "sh_cpl-query==2021.10.0" ], "PythonVersion": ">=3.9.2", "PythonPath": { diff --git a/src/cc_lang_interpreter/main.py b/src/cc_lang_interpreter/main.py index 808d05d..95ff50b 100644 --- a/src/cc_lang_interpreter/main.py +++ b/src/cc_lang_interpreter/main.py @@ -1,4 +1,4 @@ -from cpl.application import ApplicationBuilder +from cpl_core.application import ApplicationBuilder from cc_lang_interpreter.application import Application from cc_lang_interpreter.startup import Startup diff --git a/src/cc_lang_interpreter/startup.py b/src/cc_lang_interpreter/startup.py index 4aa8673..5e9f1d0 100644 --- a/src/cc_lang_interpreter/startup.py +++ b/src/cc_lang_interpreter/startup.py @@ -1,6 +1,7 @@ -from cpl.application import StartupABC -from cpl.configuration import ConfigurationABC, ConsoleArgument -from cpl.dependency_injection import ServiceProviderABC, ServiceCollectionABC +from cpl_core.application import StartupABC +from cpl_core.configuration import ConfigurationABC, ConsoleArgument +from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC +from cpl_core.environment import ApplicationEnvironment from lexer.abc.lexer_abc import LexerABC from lexer.service.lexer_service import LexerService @@ -10,21 +11,17 @@ from runtime.service.runtime_service import RuntimeService class Startup(StartupABC): - def __init__(self, config: ConfigurationABC, services: ServiceCollectionABC): + def __init__(self): StartupABC.__init__(self) - self._configuration = config - self._environment = self._configuration.environment - self._services = services + def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironment) -> ConfigurationABC: + config.add_console_argument(ConsoleArgument('-', 'p', [], ' ', is_value_token_optional=True)) + config.add_console_arguments() - def configure_configuration(self) -> ConfigurationABC: - self._configuration.add_console_argument(ConsoleArgument('-', 'p', [], ' ', is_value_token_optional=True)) - self._configuration.add_console_arguments() + return config - return self._configuration + def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironment) -> ServiceProviderABC: + services.add_singleton(LexerABC, LexerService) + services.add_singleton(RuntimeServiceABC, RuntimeService) - def configure_services(self) -> ServiceProviderABC: - self._services.add_singleton(LexerABC, LexerService) - self._services.add_singleton(RuntimeServiceABC, RuntimeService) - - return self._services.build_service_provider() + return services.build_service_provider()