raesl.compile.machine_files.utils#

Utility functions.

Module Contents#

Functions#

make_loc_names(→ Dict[str, str])

Make a dict with 'count' names by combining the prefix, name, and a number.

_in_range(→ bool)

Is the given token offset positioned between and not at 'start_offset' and

get_one(→ raesl.compile.scanner.Token)

Filter tokens on the provided start and end offsets, and return the only token

get_optional(→ Optional[raesl.compile.scanner.Token])

Filter tokens on the provided start and end offsets, and return the only token

raesl.compile.machine_files.utils.make_loc_names(prefix: str, name: str, count: int) Dict[str, str]#

Make a dict with ‘count’ names by combining the prefix, name, and a number.

raesl.compile.machine_files.utils._in_range(tok: raesl.compile.scanner.Token, start_offset: int | None, end_offset: int | None) bool#

Is the given token offset positioned between and not at ‘start_offset’ and ‘end_offset’? If start_offset or end_offset is None, use -1 and infinity as offsets, respectively.

Returns:

Whether the provided token is between (not at) the start_offset and end_offset.

raesl.compile.machine_files.utils.get_one(tokens: List[raesl.compile.scanner.Token], start_offset: int | None, end_offset: int | None) raesl.compile.scanner.Token#

Filter tokens on the provided start and end offsets, and return the only token between the positions.

raesl.compile.machine_files.utils.get_optional(tokens: List[raesl.compile.scanner.Token], start_offset: int | None, end_offset: int | None) raesl.compile.scanner.Token | None#

Filter tokens on the provided start and end offsets, and return the only token between the positions.