瀏覽代碼

Symbol parsing works.

tags/v1.0^2
Ben Kurtovic 10 年之前
父節點
當前提交
064c448824
共有 2 個檔案被更改,包括 8 行新增8 行删除
  1. +7
    -7
      bitshift/query/__init__.py
  2. +1
    -1
      bitshift/query/nodes.py

+ 7
- 7
bitshift/query/__init__.py 查看文件

@@ -70,19 +70,19 @@ class _QueryParser(object):

def _parse_symbol(self, term):
"""Parse part of a query into a symbol node and return it."""
pass
return Symbol(Symbol.ALL, self._parse_literal(term))

def _parse_function(self, term):
"""Parse part of a query into a function node and return it."""
pass
return Symbol(Symbol.FUNCTION, self._parse_literal(term))

def _parse_class(self, term):
"""Parse part of a query into a class node and return it."""
pass
return Symbol(Symbol.CLASS, self._parse_literal(term))

def _parse_variable(self, term):
"""Parse part of a query into a variable node and return it."""
pass
return Symbol(Symbol.VARIABLE, self._parse_literal(term))

def _parse_literal(self, literal):
"""Parse part of a search query into a string or regular expression."""
@@ -103,9 +103,9 @@ class _QueryParser(object):
"""
Parse a search query.

The result is normalized with a sorting function so that ``"foo OR bar"``
and ``"bar OR foo"`` result in the same tree. This is important for caching
purposes.
The result is normalized with a sorting function so that
``"foo OR bar"`` and ``"bar OR foo"`` result in the same tree. This is
important for caching purposes.

:param query: The query be converted.
:type query: str


+ 1
- 1
bitshift/query/nodes.py 查看文件

@@ -142,7 +142,7 @@ class Symbol(_Node):
def __repr__(self):
types = {self.ALL: "ALL", self.FUNCTION: "FUNCTION",
self.CLASS: "CLASS", self.VARIABLE: "VARIABLE"}
return "Symbol({0}, {1})".format(types[self.type], name)
return "Symbol({0}, {1})".format(types[self.type], self.name)


class BinaryOp(_Node):


Loading…
取消
儲存