WIP: feature/#35-shimatta-search-language #39

Draft
sst wants to merge 4 commits from feature/#35-shimatta-search-language into develop
2 changed files with 6 additions and 6 deletions
Showing only changes of commit 3ef9ea3a3b - Show all commits

View File

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

View File

@ -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'\)'