Implemented FunctionParser
This commit is contained in:
@@ -5,7 +5,7 @@ from core.sheerka.services.sheerka_service import BaseService
|
||||
|
||||
CONCEPTS_FILE = "_concepts_lite.txt"
|
||||
CONCEPTS_FILE_ALL_CONCEPTS = "_concepts.txt"
|
||||
CONCEPTS_FILE_TO_USE = CONCEPTS_FILE_ALL_CONCEPTS
|
||||
CONCEPTS_FILE_TO_USE = CONCEPTS_FILE
|
||||
|
||||
class SheerkaAdmin(BaseService):
|
||||
NAME = "Admin"
|
||||
@@ -47,6 +47,9 @@ class SheerkaAdmin(BaseService):
|
||||
if concept_file == "full":
|
||||
concept_file = CONCEPTS_FILE_ALL_CONCEPTS
|
||||
|
||||
elif not concept_file.startswith("_concepts"):
|
||||
concept_file = f"_concepts_{concept_file}.txt"
|
||||
|
||||
try:
|
||||
start = time.time_ns()
|
||||
nb_lines = 0
|
||||
|
||||
@@ -2,7 +2,7 @@ import core.utils
|
||||
from cache.Cache import Cache
|
||||
from core.builtin_concepts import BuiltinConcepts, ReturnValueConcept
|
||||
from core.sheerka.services.sheerka_service import BaseService
|
||||
from core.tokenizer import Tokenizer, TokenKind, Keywords, Token
|
||||
from core.tokenizer import Tokenizer, TokenKind, Token
|
||||
|
||||
NO_MATCH = "** No Match **"
|
||||
|
||||
@@ -88,6 +88,20 @@ class ParserInput:
|
||||
|
||||
return self.pos < self.end
|
||||
|
||||
def seek(self, pos):
|
||||
"""
|
||||
Move the token offset to position pos
|
||||
:param pos:
|
||||
:return: True is pos is a valid position False otherwise
|
||||
"""
|
||||
if pos < 0 or pos >= self.end:
|
||||
self.token = None
|
||||
return False
|
||||
|
||||
self.pos = pos
|
||||
self.token = self.tokens[self.pos]
|
||||
return True
|
||||
|
||||
def is_empty(self):
|
||||
if self.text.strip() == "":
|
||||
return True
|
||||
@@ -116,7 +130,6 @@ class ParserInput:
|
||||
tokens = [tokens]
|
||||
|
||||
switcher = {
|
||||
TokenKind.KEYWORD: lambda t: Keywords(t.value).value,
|
||||
TokenKind.CONCEPT: lambda t: core.utils.str_concept(t.value),
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ class SheerkaModifyConcept(BaseService):
|
||||
|
||||
if old_version == concept:
|
||||
# the concept is not modified
|
||||
# This is an important sanity check. Do no remove because you don't understand it
|
||||
return self.sheerka.ret(
|
||||
self.NAME, False,
|
||||
self.sheerka.new(
|
||||
|
||||
@@ -2,6 +2,7 @@ from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from cache.Cache import Cache
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.sheerka.services.sheerka_service import ServiceObj, BaseService
|
||||
|
||||
|
||||
@@ -48,6 +49,7 @@ class SheerkaVariableManager(BaseService):
|
||||
|
||||
variable = Variable(context.event.get_digest(), who, key, value, None)
|
||||
self.sheerka.cache_manager.put(self.VARIABLES_ENTRY, variable.get_key(), variable)
|
||||
return self.sheerka.ret(self.NAME, True, self.sheerka.new(BuiltinConcepts.SUCCESS))
|
||||
|
||||
def load(self, who, key):
|
||||
variable = self.sheerka.cache_manager.get(self.VARIABLES_ENTRY, who + "|" + key)
|
||||
|
||||
Reference in New Issue
Block a user