Browse Source

Symbol parsing works.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
064c448824
2 changed files with 8 additions and 8 deletions
  1. +7
    -7
      bitshift/query/__init__.py
  2. +1
    -1
      bitshift/query/nodes.py

+ 7
- 7
bitshift/query/__init__.py View File

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


def _parse_symbol(self, term): def _parse_symbol(self, term):
"""Parse part of a query into a symbol node and return it.""" """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): def _parse_function(self, term):
"""Parse part of a query into a function node and return it.""" """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): def _parse_class(self, term):
"""Parse part of a query into a class node and return it.""" """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): def _parse_variable(self, term):
"""Parse part of a query into a variable node and return it.""" """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): def _parse_literal(self, literal):
"""Parse part of a search query into a string or regular expression.""" """Parse part of a search query into a string or regular expression."""
@@ -103,9 +103,9 @@ class _QueryParser(object):
""" """
Parse a search query. 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. :param query: The query be converted.
:type query: str :type query: str


+ 1
- 1
bitshift/query/nodes.py View File

@@ -142,7 +142,7 @@ class Symbol(_Node):
def __repr__(self): def __repr__(self):
types = {self.ALL: "ALL", self.FUNCTION: "FUNCTION", types = {self.ALL: "ALL", self.FUNCTION: "FUNCTION",
self.CLASS: "CLASS", self.VARIABLE: "VARIABLE"} 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): class BinaryOp(_Node):


Loading…
Cancel
Save