Added CPL 2021.10.0 support
This commit is contained in:
parent
1197863296
commit
1f6d13551b
@ -32,6 +32,8 @@ class LanguageDefinition:
|
||||
Keywords.Foreach.value,
|
||||
# access
|
||||
Keywords.Public.value,
|
||||
Keywords.Private.value,
|
||||
Keywords.Static.value,
|
||||
Keywords.This.value
|
||||
]
|
||||
datatypes = [
|
||||
|
@ -33,6 +33,8 @@ class Keywords(Enum):
|
||||
|
||||
# access
|
||||
Public = 'public'
|
||||
Private = 'private'
|
||||
Static = 'static'
|
||||
This = 'this'
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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": {
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user