diff --git a/bitshift/query/__init__.py b/bitshift/query/__init__.py index 7d6e0d5..bc70cde 100644 --- a/bitshift/query/__init__.py +++ b/bitshift/query/__init__.py @@ -1,9 +1,25 @@ -from .association import Association +from .associations import BinaryOp, UnaryOp from .node import Node from .tree import Tree __all__ = ["parse_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 pass diff --git a/bitshift/query/associations.py b/bitshift/query/associations.py new file mode 100644 index 0000000..17e7a1e --- /dev/null +++ b/bitshift/query/associations.py @@ -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 diff --git a/bitshift/query/node.py b/bitshift/query/node.py new file mode 100644 index 0000000..3317dac --- /dev/null +++ b/bitshift/query/node.py @@ -0,0 +1,4 @@ +__all__ = ["Node"] + +class Node(object): + pass diff --git a/bitshift/query/tree.py b/bitshift/query/tree.py new file mode 100644 index 0000000..90702dc --- /dev/null +++ b/bitshift/query/tree.py @@ -0,0 +1,4 @@ +__all__ = ["Tree"] + +class Tree(object): + pass