Pantagruel v0.3.0 Pantagruel.Eval View Source

Evaluation of a Pantagruel program.

Evaluation of a Pantagruel AST consists of walking the tree, binding any symbols that are introduced in binding forms (function declarations, quantifiers, domain aliases), and checking that all symbols have been properly bound.

Link to this section Summary

Types

t()

A Pantagruel AST is a sequence of chapters, each of which consists of a header and optional body

Functions

Evaluate a Pantagruel AST for variable binding, returning the resulting environment of all bound symbols

Link to this section Types

Link to this type error() View Source
error() ::
  {:missing_import, any()}
  | {:unbound_variables, MapSet.t(), Pantagruel.Env.t()}
Link to this type t() View Source
t() :: %Pantagruel.Eval{
  env: Pantagruel.Env.t(),
  header_unbounds: MapSet.t(),
  unbounds: [MapSet.t()]
}

A Pantagruel AST is a sequence of chapters, each of which consists of a header and optional body.

The state of a running Pantagruel program as of any chapter consists of three elements:

  • The execution environment, a list of scopes, one for each chapter. The head of the environment corresponds to the current chapter. At any given chapter, any symbol introduced in that chapter will be bound into the scope at the head of the environment.

  • The header symbols to check for boundness. Any symbol used in a chapter header that is not in a declaration position is included here to be checked for boundness. Every symbol used in a header must be bound by the end of that header.

  • The body symbols to check for boundness. Any symbol used in a chapter body that is not in a declaration position is included here to be checked for boundness. Every symbol used in a body must be bound by the end of the following body. Unlike with headers, symbols may be referred to before they are defined, but they must be defined in the following chapter at the latest.

Link to this section Functions

Link to this function eval(arg, available_asts, opts \\ []) View Source
eval(Pantagruel.Parse.t(), any(), Keyword.t()) ::
  {:ok, [Pantagruel.Env.t()]} | {:error, error()}

Evaluate a Pantagruel AST for variable binding, returning the resulting environment of all bound symbols.