diff --git a/shimatta_kenkyusho/parts/views/component_views.py b/shimatta_kenkyusho/parts/views/component_views.py index de80bce..33ccd0f 100644 --- a/shimatta_kenkyusho/parts/views/component_views.py +++ b/shimatta_kenkyusho/parts/views/component_views.py @@ -29,7 +29,7 @@ class ComponentView(LoginRequiredMixin, BaseTemplateMixin, TemplateView): error_string = '' if not search_string: - return queryset + return queryset, error_string search_parser = ShimattaSearchLanguage() query, errors = search_parser.search_for_components(search_string) diff --git a/shimatta_kenkyusho/shimatta_modules/ShimattaSearchLanguage.py b/shimatta_kenkyusho/shimatta_modules/ShimattaSearchLanguage.py index d21c8b1..f88d7a1 100644 --- a/shimatta_kenkyusho/shimatta_modules/ShimattaSearchLanguage.py +++ b/shimatta_kenkyusho/shimatta_modules/ShimattaSearchLanguage.py @@ -13,7 +13,7 @@ class ShimattaSearchConstants(): PREFIX_DICT.update({k: v for k, v in EngineeringNumberConverter.it_prefixes if k}) PREFIX_RULE = r'(' + r'|'.join([rf'(?:{p})' for p in PREFIX_DICT.keys()]) + r')?' - TEXTUAL_REGEX = r'(?:([^"\s]+))|(?:"([^"]*)")' + TEXTUAL_REGEX = r'(?:([^"><=!&\|\(\)\s]+))|(?:"([^"]*)")' VALUE_REGEX = rf'(\-?\d+(?:\.\d+)?){PREFIX_RULE}' TEXTUAL_PATTERN = re.compile(TEXTUAL_REGEX) @@ -30,14 +30,14 @@ class ShimattaSearchLexer(Lexer): ignore = ' \t\n' # Regular expression rules for simple tokens - GT = r'>' - LT = r'<' GTE = r'>=' LTE = r'<=' + GT = r'>' + LT = r'<' EQ = r'==' NEQ = r'!=' - AND = r'&' - OR = r'\|' + AND = r'(?:&{1,2})|(?:and)|(?:AND)' + OR = r'(?:\|{1,2})|(?:or)|(?:OR)' LPAREN = r'\(' RPAREN = r'\)'