grammatica.grammar.CharRange.from_chars#

classmethod grammar.CharRange.from_chars(chars, negate=False)[source]#

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

Note

Duplicate characters in the input are ignored.

Parameters:
  • chars (Iterable[str]) – Characters to include in the character ranges.

  • negate (bool, optional) – Negate the character ranges. Defaults to False.

Returns:

CharRange – Instance created from the provided characters.

Raises:

ValueError – No characters provided.