Explorar el Código

Some early work on varous query objects.

tags/v1.0^2
Ben Kurtovic hace 10 años
padre
commit
34e629b3cd
Se han modificado 4 ficheros con 54 adiciones y 1 borrados
  1. +17
    -1
      bitshift/query/__init__.py
  2. +29
    -0
      bitshift/query/associations.py
  3. +4
    -0
      bitshift/query/node.py
  4. +4
    -0
      bitshift/query/tree.py

+ 17
- 1
bitshift/query/__init__.py Ver fichero

@@ -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

+ 29
- 0
bitshift/query/associations.py Ver fichero

@@ -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

+ 4
- 0
bitshift/query/node.py Ver fichero

@@ -0,0 +1,4 @@
__all__ = ["Node"]

class Node(object):
pass

+ 4
- 0
bitshift/query/tree.py Ver fichero

@@ -0,0 +1,4 @@
__all__ = ["Tree"]

class Tree(object):
pass

Cargando…
Cancelar
Guardar