module documentation

An algorithm that generates optimized regexes for matching long lists of literal strings.

Unknown Field: copyright
Copyright 2006-2021 by the Pygments team, see AUTHORS.
Unknown Field: license
BSD, see LICENSE for details.
Constant CS​_ESCAPE Undocumented
Constant FIRST​_ELEMENT Undocumented
Function make​_charset Undocumented
Function regex​_opt Return a compiled regex that matches any string in the given list.
Function regex​_opt​_inner Return a regex that matches any string in the sorted list of strings.
CS_ESCAPE =

Undocumented

Value
re.compile(r'[\[\^\\-\]]')
FIRST_ELEMENT =

Undocumented

Value
itemgetter(0)
def make_charset(letters):

Undocumented

def regex_opt(strings, prefix='', suffix=''):

Return a compiled regex that matches any string in the given list.

The strings to match must be literal strings, not regexes. They will be regex-escaped.

prefix and suffix are pre- and appended to the final regex.

def regex_opt_inner(strings, open_paren):
Return a regex that matches any string in the sorted list of strings.