def parser(self):
        """
        This function returns a parser.
        The grammar should be like most full text search engines (Google, Tsearch, Lucene).

        Grammar:
        - a query consists of alphanumeric words, with an optional '*' wildcard
          at the end of a word
        - a sequence of words between quotes is a literal string
        - words can be used together by using operators ('and' or 'or')
        - words with operators can be grouped with parenthesis
        - a word or group of words can be preceded by a 'not' operator
        - the 'and' operator precedes an 'or' operator
        - if an operator is missing, use an 'and' operator
        """
        operatorOr = Forward()

        operatorWord = Group(Combine(Word(alphanums) + Suppress('*'))).setResultsName('wordwildcard') | \
                            Group(Word(alphanums)).setResultsName('word')

        operatorQuotesContent = Forward()
        operatorQuotesContent << (
            (operatorWord + operatorQuotesContent) | operatorWord
        )

        operatorQuotes = Group(
            Suppress('"') + operatorQuotesContent + Suppress('"')
        ).setResultsName("quotes") | operatorWord

        operatorParenthesis = Group(
            (Suppress("(") + operatorOr + Suppress(")"))
        ).setResultsName("parenthesis") | operatorQuotes

        operatorNot = Forward()
        operatorNot << (Group(
            Suppress(Keyword("not", caseless=True)) + operatorNot
        ).setResultsName("not") | operatorParenthesis)

        operatorAnd = Forward()
        operatorAnd << (Group(
            operatorNot + Suppress(Keyword("and", caseless=True)) + operatorAnd
        ).setResultsName("and") | Group(
            operatorNot + OneOrMore(~oneOf("and or") + operatorAnd)
        ).setResultsName("and") | operatorNot)

        operatorOr << (Group(
            operatorAnd + Suppress(Keyword("or", caseless=True)) + operatorOr
        ).setResultsName("or") | operatorAnd)

        return operatorOr.parseString
def parser ( self ) : operatorOr = Forward ( ) operatorWord = Group ( Combine ( Word ( alphanums ) + Suppress ( '*' ) ) ) . setResultsName ( 'wordwildcard' ) | Group ( Word ( alphanums ) ) . setResultsName ( 'word' ) operatorQuotesContent = Forward ( ) operatorQuotesContent << ( ( operatorWord + operatorQuotesContent ) | operatorWord ) operatorQuotes = Group ( Suppress ( '"' ) + operatorQuotesContent + Suppress ( '"' ) ) . setResultsName ( "quotes" ) | operatorWord operatorParenthesis = Group ( ( Suppress ( "(" ) + operatorOr + Suppress ( ")" ) ) ) . setResultsName ( "parenthesis" ) | operatorQuotes operatorNot = Forward ( ) operatorNot << ( Group ( Suppress ( Keyword ( "not" , caseless = True ) ) + operatorNot ) . setResultsName ( "not" ) | operatorParenthesis ) operatorAnd = Forward ( ) operatorAnd << ( Group ( operatorNot + Suppress ( Keyword ( "and" , caseless = True ) ) + operatorAnd ) . setResultsName ( "and" ) | Group ( operatorNot + OneOrMore ( ~ oneOf ( "and or" ) + operatorAnd ) ) . setResultsName ( "and" ) | operatorNot ) operatorOr << ( Group ( operatorAnd + Suppress ( Keyword ( "or" , caseless = True ) ) + operatorOr ) . setResultsName ( "or" ) | operatorAnd ) return operatorOr . parseString
This function returns a parser.
        The grammar should be like most full text search engines (Google, Tsearch, Lucene).

        Grammar:
        - a query consists of alphanumeric words, with an optional '*' wildcard
          at the end of a word
        - a sequence of words between quotes is a literal string
        - words can be used together by using operators ('and' or 'or')
        - words with operators can be grouped with parenthesis
        - a word or group of words can be preceded by a 'not' operator
        - the 'and' operator precedes an 'or' operator
        - if an operator is missing, use an 'and' operator