INNER CODE UNIT · Python
character_flags
lean-dojo/TorchLean · scripts/generate_unicode_table.py:47
def character_flags(codepoint: int) -> int:
"""Encode the parser-relevant Boolean properties of one code point."""
character = chr(codepoint)
flags = 0
if character.isalnum():
flags |= ALPHANUMERIC
if character.isidentifier():
flags |= IDENTIFIER_START
if ("a" + character).isidentifier():
flags |= IDENTIFIER_CONTINUE
if unicodedata.decimal(character, None) is not None:
flags |= DECIMAL
return flags
def character_payload(codepoint: int) -> int:
"""Encode the flags together with the decimal zero for interval splitting.