Character ranges#

Constructor#

CharRange(char_ranges[, negate])

Grammar that defines a set of allowed or disallowed characters.

CharRange.from_chars(chars[, negate])

Create an instance of grammatica.grammar.CharRange from an iterable of characters.

CharRange.from_ords(ords[, negate])

Create an instance of grammatica.grammar.CharRange from an iterable of ordinals.

Attributes#

CharRange.char_ranges

Character ranges in the form of tuples (start, end).

CharRange.negate

Negate the character range.

Rendering#

CharRange.render([full, wrap])

Render the grammar as a regular expression.

CharRange.as_string([indent])

Return a string representation of the grammar.

Simplification#

CharRange.simplify()

Simplify the grammar.

Utility#

CharRange.copy()

Create a copy of the grammar.

CharRange.equals(other[, check_quantifier])

Check equality with another value.

Metadata#

Warning

CharRange.attrs_dict is considered experimental and may change without warning.

CharRange.attrs_dict()

Return instance attributes of the grammar.