riscemu.types.program_loader module

class riscemu.types.program_loader.ProgramLoader(source_name: str, source: IOBase, options: Dict[str, Any])

Bases: ABC

A program loader is always specific to a given source file. It is a place to store all state concerning the parsing and loading of that specific source file, including options.

is_binary: ClassVar[bool]
__init__(source_name: str, source: IOBase, options: Dict[str, Any])
abstract classmethod can_parse(source_name: str) float

Return confidence that the file located at source_path should be parsed and loaded by this loader :param source_name: the name of the input :return: the confidence that this file belongs to this parser in [0,1]

abstract classmethod get_options(argv: List[str]) [List[str], Dict[str, Any]]

parse command line args into an options dictionary

Parameters:

argv – the command line args list

Returns:

all remaining command line args and the parser options object

classmethod instantiate(source_name: str, source: IOBase, options: Dict[str, Any]) ProgramLoader

Instantiate a loader for the given source file with the required arguments

Parameters:
  • source_name – the path to the source file

  • source – IO Object representing the source

  • options – the parsed options (guaranteed to come from this classes get_options method).

Returns:

An instance of a ProgramLoader for the spcified source

abstract parse() Union[Program, Iterator[Program]]
Returns: