grammatica.grammar.CharRange#
- class grammatica.grammar.CharRange(char_ranges, negate=False)[source]#
Grammar that defines a set of allowed or disallowed characters.
- Parameters:
char_ranges (
Iterable[tuple[str,str]]) – Character ranges in the form of tuples (start, end). Each range is inclusive, meaning both start and end characters are included. For example, (‘a’, ‘z’) includes all lowercase letters from ‘a’ to ‘z’.negate (
bool, optional) – Negate the character range. Defaults to False.
- Raises:
ValueError – Empty character range provided.
ValueError – Start or end of a character range is not a single character.
ValueError – End character is less than start character in a character range.
Attributes
Character ranges in the form of tuples (start, end). |
|
Negate the character range. |
Methods
|
Return a string representation of the grammar. |
Return instance attributes of the grammar. |
|
|
Create a copy of the grammar. |
|
Check equality with another value. |
|
Create an instance of |
|
Create an instance of |
|
Render the grammar as a regular expression. |
|
Simplify the grammar. |