Validates and desugars RawAST into CoreAST.
The analyzer transforms the parser's output (RawAST) into a validated, desugared intermediate form (CoreAST) that the interpreter can safely evaluate.
Error Handling
Returns {:ok, CoreAST.t()} on success or {:error, error_reason()} on failure.
Summary
Functions
Validates and desugars raw_ast into CoreAST.
Returns the canonical list of all forms handled by the analyzer.
Types
@type error_reason() :: {:invalid_form, String.t()} | {:invalid_form, String.t(), %{ kind: :unknown_namespace, rejected_namespace: String.t(), available_namespaces: [String.t()] }} | {:grant_filtered_prelude_export, String.t(), atom() | nil} | {:invalid_arity, atom(), String.t()} | {:invalid_cond_form, String.t()} | {:invalid_thread_form, atom(), String.t()} | {:unsupported_pattern, term()} | {:invalid_placeholder, atom()} | {:unsupported_java_class, atom() | String.t()} | {:unsupported_java_member, atom() | String.t(), atom() | String.t()} | {:java_arity_error, atom(), %{expected: [non_neg_integer()], actual: non_neg_integer()}}
Functions
@spec analyze(term(), PtcRunner.Lisp.Prelude.t() | nil, [map()]) :: {:ok, PtcRunner.Lisp.CoreAST.t()} | {:error, error_reason()}
Validates and desugars raw_ast into CoreAST.
When a compiled prelude (%PtcRunner.Lisp.Prelude{}) is supplied, the
analyzer resolves qualified prelude calls/refs (e.g. crm/get-user) against
the prelude's PUBLIC export table and rejects writes into protected prelude
namespaces (e.g. (defn crm/get-user ...)) with a protection programmer
fault. The prelude is consulted via process-local state scoped to this single
analysis pass (set on entry, cleared on exit), so the deep mutually-recursive
do_analyze/2 clauses do not each have to thread it. Passing nil keeps the
pre-prelude behavior unchanged.
@spec supported_forms() :: [atom()]
Returns the canonical list of all forms handled by the analyzer.
These are forms dispatched via dispatch_list_form/4 — special forms,
macros, predicate builders, and control flow that the analyzer intercepts
before the interpreter sees them.
Examples
iex> :let in PtcRunner.Lisp.Analyze.supported_forms()
true
iex> :filter in PtcRunner.Lisp.Analyze.supported_forms()
false