base-node (.bn) v1.0.0-rc.8

Base Node (.bn) Language Reference

Language Edition 2026 · Specification Version 1.0.0-rc.8 (release candidate of the LTS). See Versioning Specification for stability policies and release lifecycles.

This reference is the language: how a text is read, printed and formatted. It names no destination. What a kind of tree, a type, a node, a setting, a formula or a call with a body means is the host's: a host library gives a text its meaning for one destination, and holds it to its own rules. The examples call nodes by name; to the language they are names.

1. File Structure#

A .bn file is UTF-8 text containing:

  1. Optional use imports at the top of the file:
    • use curves2d imports the module into the curves2d:: namespace.
    • use curves2d as c2 imports with an alias namespace (c2::ring_2d(...)).
    • use curves2d (ring_2d) imports selected symbols into local scope (ring_2d(...)).
    • use math from "lib/math.bn" imports from a file, by a path the host resolves. A source is a file, never a URL: reading a .bn makes no network request.
    • Without from, the host finds the module, in an order of its own.
  2. One or more graph declarations.

// starts a line comment. Whitespace and newlines are not significant outside literals; a statement ends when the next token cannot continue the current expression.

use curves2d as c2
use math (bump)

geometry graph relief(curve: Geometry, height: Float = 0.4) -> Geometry {
  "Lifts the middle of a curve, then draws its contour"
  h = bump(length(Position()) / 3.0, 0.5, 0.2) * height
  return curve
    |> SetPosition(offset: CombineXYZ(z: h))
    |> c2::"parallel contour 2d"(offset: 0.05)
}

1.1 File Head#

The comment lines before the first use or graph may hold directives, // @name value, one per line. They are comments: every reader keeps them as written, and a directive a tool does not know is left for others. The core reads and checks those of the table (base_node.header(source) in Python, base_node::header in Rust). A host reads its own from the same head (read_head, in both), each written once and with a value, and says what they mean.

// @module waves
// @edition 2026
// @title Ripples and waves
// @author Base Node
// @license MIT
DirectiveValue
@moduleThe module's name, an identifier: its file is <name>.bn, found by use <name>
@versionThe version of the file, as its author numbers it
@editionThe edition of the language the file is written in (versioning, 2)
@targetThe targets the file promises to fit, separated by commas; optional. A target is written name, name@version, or either with words after it, spaces apart: which targets there are, and what a version and a word mean, are the host's
@title, @author, @licenseFree text (an SPDX identifier for the license), shown to whoever opens the file

A value written in quotes is a string (2), its escapes read as in any string, wherever a directive is read: a name, a title, a target. Free text that is not one string ("a" and "b") is read as written.

A directive written twice or without a value, a @module that is not an identifier, and a target the host refuses, with its reason, are errors at their line and column. So is an @edition the reader does not know (@edition '2028': not an edition this reader knows (2026)): the parser and the formatter refuse the text too, a later edition being another language to them.

2. Identifiers and Keywords#

3. Graph Declaration#

[kind][(options)] graph name(inputs...) -> outputs {
  body...
}

A graph with a name is declared at the top of a file. Inside a body, graph(inputs...) -> outputs { body... }, with no name and no kind, is a value: a nameless graph (6).

3.1 Types#

A type is an identifier: Float, Vector, Geometry. Which types there are, their defaults, and which literals each takes, are the host's. A type parameter of a template (3.4) stands for a type.

3.2 Parameters#

name as key: Type(subtype: DISTANCE) = default_value in min..max

3.3 Interface Panels#

Parameters and outputs can be grouped into nested panels:

geometry graph scatter(
    geometry: Geometry,
    "Size"(description: "Scale controls") {
      scale: Float = 1.0,
      "Random"(default_closed: true) {
        enable: Bool(is_panel_toggle: true),
        scale as random_scale: Float = 0.2 in 0.0..1.0
      }
    }
) -> Geometry { ... }

3.4 Templates#

Since the specification version 0.12.0. The Python and Rust parsers read and print it; what a template builds, and the type a call takes when it writes none, are the host's.

A template is a graph generic over the type of a value, written once: a host builds it for each type it is called with.

geometry graph attribute_or<T: Float | Int | Bool | Vector | Color | Rotation | Matrix>(
    name: String,
    fallback: T
) -> (value: T) {
  a = NamedAttribute[T](name: name)
  return (value: Switch[T](switch: a.exists, false_: fallback, true_: a.attribute))
}

geometry graph tint(geometry: Geometry, color: Color) -> Geometry {
  c = attribute_or("Col", color)
  return geometry |> StoreNamedAttribute[FLOAT_COLOR](name: "tint", value: c)
}

Edition and versions. The syntax is added to Edition 2026: every text valid before reads as before, as a < after a graph's name was a syntax error, and f<Vector>(x) two comparisons in a row, which the grammar refuses. Before LTS this is a minor version of the specification (0.11.0 → 0.12.0) and of the Python and Rust packages with it (versioning, 3). A text using templates is not read by a toolchain before 0.12.0: it is refused there at the <.

4. Statements#

SyntaxMeaning
x = exprBind expression output
size = 10Named constant: a literal bound to a name, which the host makes a value of its own; a tuple too. A setting takes no name: no wire feeds it, so its value is written in its brackets
return exprSingle output return
return (A: e1, B: e2)Multi-output return
no returnA graph may leave its return out: its outputs, if it has any, give nothing
"Title" #color { ... }Visual frame (#e73 or named color #teal): a frame's or a look's color, never a value, which is a tuple
"Title" .. { ... }Continuation of a previously opened frame
"Note" #color {}Standalone frame note

A field of the return may be a literal: the value of that output when nothing feeds it (return (color: (0.0, 0.0, 0.0, 0.0))).

4.1 Node Presentation (@)#

p = Position() @ hide
h = sin(p.x) @ "Height" #e07030
out = SetPosition(g, offset: o) @ #orange hide mute

Flags: "Label", #color, hide (collapsed), mute (bypassed).

5. Expressions#

A call writes up to three lists after its name, each in its own delimiters: <> the types of a template (3.4), [] the node's settings, what no wire can feed, and () what a wire can feed.

call      := name type_args? settings? '(' args ')' ('->' outputs)?
body_call := name settings? '(' args ')' '->' block          (6)
name      := IDENT ('::' (IDENT | STRING))*
settings  := '[' setting (',' setting)* ','? ']'
setting   := IDENT ':' value | value                          positional ones first
value     := NUMBER | '-' NUMBER | STRING | 'true' | 'false'
           | IDENT                                            an enum value, a template's type, `_`
           | '(' ')' | '(' value ',' ')'                      a tuple of none, of one: (LEFT,)
           | '(' value (',' value)+ ','? ')'                  a tuple
           | '(' value ')'                                    the value alone
           | IDENT '(' (value | IDENT ':' value) (',' …)* ')'  a call of values: Ramp(…), Curve(…)
NUMBER    := digits ('.' digits)? (('e' | 'E') ('+' | '-')? digits)? | 'inf' | 'nan'
x = Math[WRAP](Value: angle, Value_001: 3.141593, Value_002: -3.141593)
y = Math[ADD, use_clamp: true](Value: a, Value_001: b)
o = Object[object: "Thing"]()
c = ColorRamp[color_ramp: Ramp((0.0, (0.0, 0.0, 0.0)), (1.0, (1.0, 0.5, 0.0)))](factor: f)
r = foreach[FACE](geometry, selection: s, item: f) -> { … }
g |> StoreNamedAttribute[INT, CURVE](name: "i", value: Index())
a = NamedAttribute[T](name: name)        // T, a template's type, as a setting's value

5.1 Canonical Layout#

The formatter and the printer print one layout, set by a width of 100 characters per line, indentation included (rustfmt's default):

  transform = Cube(size: CombineXYZ(x: 2.0))
    |> TransformGeometry(translation: CombineXYZ(), scale: CombineXYZ(x: 1.0, y: 1.0, z: 1.0))
  hair = Switch[GEOMETRY](
      switch: Hairs > 0.0,
      true_: (points |> SetMaterial(material: Hair)) + (lint |> SetMaterial(material: Lint)))
    + Switch[GEOMETRY](
      switch: Cobwebs > 0.0,
      true_: cobweb
        |> InstanceOnPoints(instance: strand, rotation: align, scale: CombineXYZ(x: s, y: s, z: s))
        |> RealizeInstances())
  return hair
    |> TransformGeometry(
      translation: CombineXYZ(x: 1.0, y: 1.0, z: 1.0),
      rotation: CombineXYZ(x: 1.0, y: 1.0, z: 1.0),
      scale: CombineXYZ(x: 1.0, y: 1.0, z: 1.0))
    |> SetShadeSmooth()

The layout depends on the syntax tree alone: printing the parse of a printed text gives the same text.

6. Calls with a Body, and Nameless Graphs#

Two forms hold a body of statements. Both are written only as the value of an assignment (name = …), and their body sees the names outside it.

name = call[settings...](arguments...) -> {
  body...
}

name = graph(inputs...) -> outputs {
  body...
}

Elsewhere than as the value of an assignment, both are errors: a call with a body is the value of an assignment: r = repeat(…) -> { … }, a graph with no name is the value of an assignment: f = graph(x: Float) -> Float { … }.

7. Limits#

A .bn text may come from anyone. Reading one ends with a tree or an error, never a crash or a hang: every reader refuses, with an error at the place it happens, a text past one of these limits.

LimitValueWhat counts
Source size4 MiBThe bytes of the text, in UTF-8
Nesting32What is open at once: (…), the arguments or options of a call, a {…} block (frame, panel, the body of a call or of a nameless graph), each prefix - or not, and the branches of each ? : (a chain a ? x : b ? y : … opens one per ?)
Expression height256The nodes one inside another in an expression: a name or a literal is 1, and each operator, call, tuple or .socket is one more than the tallest of what it holds. A chain counts for its length: a + b + c is 3, and so is a pipe of two steps
Integer2⁶³ − 1The digits of an integer literal; a float literal written with digits must be finite (1e999 is refused), infinity is written inf

A host that reads the file a use names reads a regular file no larger than a source, inside the roots the modules resolve in (§1).