From 064c448824b6812218e376ce58e253a4311d9dda Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Fri, 9 May 2014 13:14:22 -0400 Subject: [PATCH] Symbol parsing works. --- bitshift/query/__init__.py | 14 +++++++------- bitshift/query/nodes.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bitshift/query/__init__.py b/bitshift/query/__init__.py index e5844f1..111c35b 100644 --- a/bitshift/query/__init__.py +++ b/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 diff --git a/bitshift/query/nodes.py b/bitshift/query/nodes.py index a89a8b9..b2e4864 100644 --- a/bitshift/query/nodes.py +++ b/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):