package expr

  1. Overview
  2. Docs

Module Expr.EvalSource

Sourceexception Failure of string

Any problem is reported: syntax of an expression or unknown bindings

Sourcetype value =
  1. | Bool of bool
  2. | Float of float
  3. | String of string
Sourcetype expression
Sourcetype env

An env binds a names to values.

Sourceval empty : unit -> env

env with no names

Sourceval add : env -> string -> value -> unit

Add a new binding to env

Sourceval add' : env -> string list -> value -> unit

Add multiple bindings, all referring to the same value. Hence this creates aliases

Sourceval env : (string * value) list -> env

Create an env from an association list

Sourceval compile : string -> expression

Compile a string to an expression for later evaluation

Sourceval string : env -> string -> value

Evaluate a string given an expression and evaluate it. This uses compile internally and is most useful if the expression is only evaluated once

Sourceval expr : env -> expression -> value

Evaluate a (compiled) expression. This can be used to evaluate a single expression multiple times with different env environments

Sourceval simple : string -> value

This simplest case: evaluate a string expression with an empty environment to a value