pyk.krepl.repl module

class BaseRepl[source]

Bases: Cmd, Generic[T], ABC

CAT_BUILTIN: Final = 'Built-in Commands'
CAT_DEBUG: Final = 'Debugger Commands'
abstract do_load(args: Any) bool | None[source]

Set up the interpreter.

Subclasses are expected to

  • Decorate the method with with_argparser to ensure the right set of arguments is parsed.

  • Instantiate an Interpreter[T] based on args, then set self.interpreter.

  • Set self.state to self.interpreter.init_state().

do_show(args: Namespace) None[source]
do_step(args: Namespace) None[source]
interpreter: Interpreter[T] | None
prompt = '> '
state: T | None
class Interpreter[source]

Bases: Generic[T], ABC

abstract init_state() T[source]
abstract next_state(state: T, steps: int | None = None) T[source]
class KInterpreter(definition_dir: Path, program_file: Path)[source]

Bases: Interpreter[KState]

definition_dir: Path
init_state() KState[source]
next_state(state: KState, steps: int | None = None) KState[source]
program_file: Path
class KRepl(definition_dir: Path)[source]

Bases: BaseRepl[KState]

do_load(args: Namespace) None[source]
intro = 'K-REPL Shell\nType "help" or "?" for more information.'
final class KState(definition_dir: 'Path', pattern: 'Pattern')[source]

Bases: object

definition_dir: Path
pattern: Pattern
property pretty: str
exception ReplError[source]

Bases: Exception