lapspython.translation

Implements functions for translation from lambda calculus to Python.

Classes

Translator(grammar)

Translate lambda programs to Python code.

class lapspython.translation.Translator(grammar: lapspython.types.ParsedGrammar)[source]

Translate lambda programs to Python code.

setup_logger() logging.Logger[source]

Set up a logger for exceptions caught during translation.

rtype: logging.Logger

log_exception()[source]

Write current debug stack into translation.log.

translate(program: dreamcoder.program.Program, name: str) lapspython.types.ParsedProgramBase[source]

Translate a synthesized program under the current grammar.

Parameters
  • program (subclass of dreamcoder.program.Program) – Abstraction/Invented at any depth of lambda expression

  • name (string) – Task/Function name

Returns

Translated program

Return type

ParsedProgram

translate_wrapper(program: dreamcoder.program.Program, node_type: str = 'body')[source]

Redirect node to corresponding translation procedure.

Parameters

program (Subclass of dreamcoder.program.Program) – Node of program tree.

contains_index(program: dreamcoder.program.Program) bool[source]

Test whether the subprogram contains a de Bruijin index.

get_last_variable() str[source]

Return the declared variable in the last line of code.