Fixed #68: Implement SheerkaQL

Fixed #70: SheerkaFilterManager : Pipe functions
Fixed #71: SheerkaFilterManager : filter_objects
Fixed #75: SheerkaMemory: Enhance memory() to use the filtering capabilities
Fixed #76: SheerkaEvaluateConcept: Concepts that modify the state of the system must not be evaluated during question
This commit is contained in:
2021-04-26 19:13:47 +02:00
parent bef5f3208c
commit 1059ce25c5
57 changed files with 5759 additions and 1302 deletions
+26
View File
@@ -0,0 +1,26 @@
from sheerkaql.lexer import Lexer
from sheerkaql.parser import Parser
lexer_instance = Lexer()
class SheerkaQueryLanguage:
def compile(self, query):
"""
Compiles a query string into a python function that takes one parameter, the execution namespace.
The compiled function is re-usable. For information on the grammar see X.
"""
return Parser().parse(bytes(query, 'utf-8').decode('unicode_escape'), lexer=lexer_instance)
def execute(self, query, namespace, allow_builtins=False):
""""
Compiles the query string and executes it with the supplied namespace. If you want to execute a
particular query many times, use compile to get a query function.
:param query: query to execute (from self.compile())
:param namespace: execution's namespace
:param allow_builtins: auto add builtin functions and names
"""
if allow_builtins:
namespace.update(__builtins__)
return self.compile(query)(namespace)