Liking cljdoc? Tell your friends :D

clj-zig.zig

The three-level node model for Zig source generation. Generators produce declaration, statement, and expression nodes as plain data; the single render function turns them into Zig source text. This is the ONLY namespace that knows about braces, newlines, indentation, and semicolons.

The node model is a pruned view of Zig's own AST decomposition. It covers the subset clj-zig generates: function declarations, struct and enum declarations, the common statement forms (const, assign, return, if, for, defer), and a small expression vocabulary (ref, field, deref, call, lit, as, slice). The :raw node at each level is the escape hatch for user-written Zig body text and one-off complex expressions the generators do not model.

Generators compose nodes with the constructor functions, never with str. Type strings (like "i64" or "[]const f64") are the exception: they are opaque tokens passed through from zig-type. The four-space indent appears ONLY in the renderer's indent function.

The three-level node model for Zig source generation. Generators
produce declaration, statement, and expression nodes as plain data;
the single `render` function turns them into Zig source text. This is
the ONLY namespace that knows about braces, newlines, indentation, and
semicolons.

The node model is a pruned view of Zig's own AST decomposition. It
covers the subset clj-zig generates: function declarations, struct and
enum declarations, the common statement forms (const, assign, return,
if, for, defer), and a small expression vocabulary (ref, field, deref,
call, lit, as, slice). The `:raw` node at each level is the escape
hatch for user-written Zig body text and one-off complex expressions
the generators do not model.

Generators compose nodes with the constructor functions, never with
`str`. Type strings (like `"i64"` or `"[]const f64"`) are the
exception: they are opaque tokens passed through from `zig-type`. The
four-space indent appears ONLY in the renderer's `indent` function.
raw docstring

asclj

(as type value)
source

assign-stmtclj

(assign-stmt target value)

An assignment statement: target = value;.

An assignment statement: `target = value;`.
sourceraw docstring

callclj

(call fn-name args)
source

const-declclj

(const-decl name init)

A top-level const declaration node.

A top-level `const` declaration node.
sourceraw docstring

const-stmtclj

(const-stmt name init)
(const-stmt name type init)

A local const statement: const name = init; or const name: type = init;.

A local `const` statement: `const name = init;` or
`const name: type = init;`.
sourceraw docstring

defer-stmtclj

(defer-stmt expr)

A defer statement: defer expr;.

A defer statement: `defer expr;`.
sourceraw docstring

derefclj

(deref base)
source

enum-declclj

(enum-decl name backing members)

An enum(backing) declaration node.

An `enum(backing)` declaration node.
sourceraw docstring

export-fn-declclj

(export-fn-decl name params ret body)

An exported function declaration node (C ABI entry point).

An exported function declaration node (C ABI entry point).
sourceraw docstring

expr-stmtclj

(expr-stmt value)

An expression statement: expr;.

An expression statement: `expr;`.
sourceraw docstring

extern-struct-declclj

(extern-struct-decl name fields)

An extern struct declaration node (C ABI layout).

An `extern struct` declaration node (C ABI layout).
sourceraw docstring

fieldclj

(field base field-name)
source

field-dataclj

(field-data name type)

One struct field as node data: {:name name :type type}.

One struct field as node data: `{:name name :type type}`.
sourceraw docstring

fn-declclj

(fn-decl name params ret body)

A non-exported function declaration node.

A non-exported function declaration node.
sourceraw docstring

for-stmtclj

(for-stmt header body)

A for loop: for header { body }. The header is a raw string like (__nice, 0..) |*__dst, __i| because the for-loop capture syntax is too varied to model.

A for loop: `for header { body }`. The `header` is a raw string like
`(__nice, 0..) |*__dst, __i|` because the for-loop capture syntax is
too varied to model.
sourceraw docstring

if-stmtclj

(if-stmt cond body)
(if-stmt cond body else)

An if statement: if (cond) { body } with an optional else branch.

An if statement: `if (cond) { body }` with an optional else branch.
sourceraw docstring

litclj

(lit value)

A literal expression node. value is Zig source text rendered verbatim (a number, a boolean, a string of source).

A literal expression node. `value` is Zig source text rendered verbatim
(a number, a boolean, a string of source).
sourceraw docstring

packed-struct-declclj

(packed-struct-decl name fields)

A packed struct declaration node.

A `packed struct` declaration node.
sourceraw docstring

paramclj

(param name type)

One function parameter as node data: {:name name :type type}.

One function parameter as node data: `{:name name :type type}`.
sourceraw docstring

raw-declclj

(raw-decl text)

A raw declaration node (opaque Zig source text).

A raw declaration node (opaque Zig source text).
sourceraw docstring

raw-exprclj

(raw-expr text)
source

raw-stmtclj

(raw-stmt text)

A raw statement node (opaque Zig source, indented by the renderer at the enclosing level). Used for user body text and multi-line fragments whose indentation is relative to the function body.

A raw statement node (opaque Zig source, indented by the renderer at
the enclosing level). Used for user body text and multi-line fragments
whose indentation is relative to the function body.
sourceraw docstring

refclj

(ref name)
source

renderclj

(render decls)

Render a vector of declaration nodes to Zig source text. Each declaration is separated by a blank line. The output carries no trailing newline.

Render a vector of declaration nodes to Zig source text. Each
declaration is separated by a blank line. The output carries no
trailing newline.
sourceraw docstring

render-expr-for-testclj

(render-expr-for-test e)
source

render-stmt-for-testclj

(render-stmt-for-test stmt level)
source

return-stmtclj

(return-stmt)
(return-stmt value)

A return statement. With no argument, a bare return;.

A return statement. With no argument, a bare `return;`.
sourceraw docstring

sliceclj

(slice base from to)
source

struct-declclj

(struct-decl name fields)

A regular struct declaration node.

A regular `struct` declaration node.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close