PtcRunner.Lisp.CoreAST (PtcRunner v0.4.1)

View Source

Core, validated AST for PTC-Lisp.

This module defines the type specifications for the intermediate representation that the analyzer produces. The interpreter evaluates CoreAST to produce results.

Pipeline

source  Parser  RawAST  Analyze  CoreAST  Eval  result

Summary

Types

binding()

@type binding() :: {:binding, pattern(), t()}

field_path()

@type field_path() :: {:field, [field_segment()]}

field_segment()

@type field_segment() :: {:keyword, atom()} | {:string, String.t()}

fn_params()

@type fn_params() :: [pattern()] | {:variadic, [pattern()], pattern()}

literal()

@type literal() ::
  nil | boolean() | number() | {:string, String.t()} | {:keyword, atom()}

pattern()

@type pattern() ::
  {:var, atom()}
  | {:destructure, {:keys, [atom()], keyword()}}
  | {:destructure, {:map, [atom()], [{atom(), atom()}], keyword()}}
  | {:destructure, {:as, atom(), pattern()}}
  | {:destructure, {:seq, [pattern()]}}
  | {:destructure, {:seq_rest, [pattern()], pattern()}}

t()

@type t() ::
  literal()
  | {:vector, [t()]}
  | {:map, [{t(), t()}]}
  | {:set, [t()]}
  | {:var, atom()}
  | {:ctx, atom()}
  | {:call, t(), [t()]}
  | {:let, [binding()], t()}
  | {:if, t(), t(), t()}
  | {:fn, fn_params(), t()}
  | {:do, [t()]}
  | {:and, [t()]}
  | {:or, [t()]}
  | {:where, field_path(), where_op(), t() | nil}
  | {:pred_combinator, :all_of | :any_of | :none_of, [t()]}
  | {:return, t()}
  | {:fail, t()}
  | {:builtin_call, String.t(), t()}
  | {:ctx_call, atom(), [t()]}
  | {:def, atom(), t()}
  | {:loop, [binding()], t()}
  | {:recur, [t()]}

where_op()

@type where_op() ::
  :eq | :not_eq | :gt | :lt | :gte | :lte | :includes | :in | :truthy