@@ -1,9 +1,25 @@ | |||||
from .association import Association | |||||
from .associations import BinaryOp, UnaryOp | |||||
from .node import Node | from .node import Node | ||||
from .tree import Tree | from .tree import Tree | ||||
__all__ = ["parse_query"] | __all__ = ["parse_query"] | ||||
def parse_query(query): | def parse_query(query): | ||||
""" | |||||
Parse a search query. | |||||
:param query: The query be converted. | |||||
:type query: str | |||||
:return: A tree storing the data in the query. | |||||
:rtype: :py:class:`~.query.tree.Tree` | |||||
""" | |||||
"bubble sort lang:python" | |||||
# gets a string, returns a Tree | # gets a string, returns a Tree | ||||
pass | pass |
@@ -0,0 +1,29 @@ | |||||
__all__ = ["BinaryOp", "UnaryOp"] | |||||
class _Association(object): | |||||
pass | |||||
class BinaryOp(_Association): | |||||
AND = 1 | |||||
OR = 2 | |||||
def __init__(self, left, right, op): | |||||
self.left = left | |||||
self.right = right | |||||
self.op = op | |||||
def __str__(self): | |||||
ops = {AND: "And", OR: "Or"} | |||||
return "{0}({1}, {2})".format(ops[self.op], self.left, self.right) | |||||
class UnaryOp(_Association): | |||||
NOT = 1 | |||||
def __init__(self, node, op): | |||||
self.node = node | |||||
self.op = op | |||||
def __str__(self): | |||||
pass |
@@ -0,0 +1,4 @@ | |||||
__all__ = ["Node"] | |||||
class Node(object): | |||||
pass |
@@ -0,0 +1,4 @@ | |||||
__all__ = ["Tree"] | |||||
class Tree(object): | |||||
pass |