-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathdiffgram_query_exectutor.py
More file actions
47 lines (37 loc) · 1.43 KB
/
diffgram_query_exectutor.py
File metadata and controls
47 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from lark.visitors import Visitor
from shared.query_engine.diffgram_query import DiffgramQuery
from abc import ABC, abstractmethod
class BaseDiffgramQueryExecutor(Visitor, ABC):
"""
The Diffgram Query Object is a tree visitors that
can be traversed to generate relevant output for different
usecases. This object is the input for classes that implement
the DiffgramQueryExecutor.
"""
def __init__(self, diffgram_query: DiffgramQuery):
self.diffgram_query = diffgram_query
@abstractmethod
def expr(self, *args):
print('visting expr: Not Implemented yet.')
@abstractmethod
def start(self, *args):
print('visting start: Not Implemented yet.')
@abstractmethod
def factor(self, *args):
print('visting start: Not Implemented yet.')
@abstractmethod
def term(self, *args):
print('visting start: Not Implemented yet.')
@abstractmethod
def compare_expr(self, *args):
print('visting start: Not Implemented yet.')
@abstractmethod
def execute_query(self):
"""
Entrypoint for building the end query. This uses the diffgram query
object and accesses the tree so it can be visited.
The main assumption here is that the tree will have the nodes that corresponds to the
grammar defined in grammar.py
:return:
"""
return self.visit(self.diffgram_query.tree)