Comprehensive reference

Grammar operators, structures, and workflow controls

This page summarises the grammar constructs that are visibly supported in the current ProGen3D live-site build and the wrapped modular editor.

How to read this page

This page reflects the current live parser and runtime rather than an idealised older syntax sketch. Use the quick-reference cards below for operator behavior, then use the compact grammar summary here to understand the structural surface the parser accepts.

Current grammar summary

The parser supports the structural forms below. Expressions may contain spaces, tabs, newlines, and carriage returns, and conditional branches may contain inline statement lists when a top-level : is present.

<grammar>
The complete grammar document, consisting of one or more rules.
<rule>
A named production that expands into a rule body.
<sequence>
An ordered list of statements executed procedurally.
<statement>
A grouped block, transform, deformation, instance, conditional, rule call, or variable form.
<expression>
An arithmetic expression used in transforms, conditions, variables, and rule arguments.
<grammar> ::= <rule>+

<rule> ::= <rule_header> "->" <rule_body>
<rule_header> ::= <identifier>
                | <identifier> "(" <var_list> ")"
                | <identifier> "(" <var_list> ")" <repeat_expr>

<rule_body> ::= <sequence> ("|" <sequence>){0,2}
<sequence> ::= <statement>+

<statement> ::= "[" <sequence> "]"
              | <transform>
              | <deformation>
              | <instance>
              | <conditional>
              | <rule_call>
              | <variable_stmt>

<conditional> ::= "?(" <expression> ")" <rule_call>
                | "?(" <expression> ")" <sequence> ":" <sequence>

<transform> ::= "T" "(" <expr> <expr> <expr> ")"
              | "S" "(" <expr> <expr> <expr> ")"
              | ("A" | "R") "(" <expr> <axis> ")"

<deformation> ::= ("DSX" | "DSY" | "DSZ" | "DTX" | "DTY" | "DTZ")
                   "(" <expr> <expr> <expr> ")"
                | ("GDSX" | "GDSY" | "GDSZ" | "GDTX" | "GDTY" | "GDTZ")
                   "(" <expr> <expr> <expr> ")"

<instance> ::= "I" "(" ("Cube" | "CubeX" | "CubeY" | "CubeZ") <texture_name> <expr> ")"
<texture_name> ::= <preset_name> | <joined_texture_name>

<rule_call> ::= <identifier> | <identifier> "(" <arg_list> ")"
<variable_stmt> ::= <identifier> "(" <arg_list> ")"

<arg_list> ::= <expr> ((","? | whitespace)+ <expr>)*
<var_list> ::= <identifier> ((","? | whitespace)+ <identifier>)*

<expr> ::= arithmetic expression with identifiers, numbers, unary "-", parentheses,
           +, -, *, /, ^, comparisons, and functions such as sin, cos, sqrt, rand, float, int

whitespace inside expressions may include spaces, tabs, newlines, and carriage returns

For the full current text forms, see BNF.txt and grammar-reference.txt in the project root.

BNF-oriented syntax explanations

These notes explain the operator surface using the same formal language categories described in the BNF, so the documentation matches the parser model more closely.

<rule> ::= <rule_header> "->" <rule_body>
A rule is the primary production unit. It maps a named header to a sequence or set of alternative sequences.
<statement> ::= ...
Every executable grammar element occupies statement position, including transforms, grouped branches, conditionals, and instances.
<group_block> ::= "[" <sequence> "]"
A grouped block isolates a local branch of procedural structure and is commonly used to contain transform accumulation and scoped global subset deformation.
<conditional> ::= "?(" <expression> ")" ...
Conditionals support both the legacy single-rule form and inline true/false statement lists split by a top-level colon.
<instance> ::= "I" "(" <primitive> <texture> <number> ")"
An instance binds geometry type, texture preset, and scalar value into a compact renderable statement. CubeX, CubeY, and CubeZ also advance the local transform by one unit along their own axis after each instance.
<expression> ::= <add_expr>
Expressions define arithmetic structure for dimensions, recurrence, radial offsets, tapering, and conditional tests, and may span multiple lines.

Rule structure

Every grammar starts with one or more rules. The live parser supports rule headers, sequences, alternates, grouped blocks, conditional branches, calls, transforms, local and global deformations, instances, and expression-based arguments.

Start -> body
Defines a basic entry rule and sends execution into its body. Use this when you do not need resolved variables or an explicit repeat expression.
RuleName(var1 var2) -> rule_body
Defines a parameterized rule using the BNF rule-header form. Parameter and argument lists can be whitespace-separated, with commas still accepted for compatibility.
RuleName(vars) repeat_expr -> rule_body
Defines a parameterized rule followed by a repeat expression, matching the supplied BNF.
sequence | sequence | sequence
A rule body can contain one, two, or three alternative sequences separated by pipes.
?(cond_expr) Rule
Single-branch conditional rule call. If cond_expr evaluates truthy, the named rule is executed; otherwise nothing is emitted from that conditional. This is useful for optional branches, bounded recursion, or one-sided feature toggles.
?(cond_expr) stmt_list_true : stmt_list_false
Two-branch inline conditional. When a top-level colon is present, each side can be a statement list, not just a single rule call. Use this for in-place recursion, termination branches, or compact structural switches.
[ ... ]
Creates a grouped structural block that can contain transforms, variables, conditionals, and instances as one composable unit inside a rule body. Groups clone parser state, so local and global deformation settings push on entry and pop on exit, and GDS*/GDT* affect only cubes emitted while that grouped state is active.

Transforms

These operators change placement, scale, and orientation before an instance is emitted. For CubeX, CubeY, and CubeZ, the runtime also advances the local transform by one unit along that primitive axis after each instance.

T ( x y z )
Translate in 3D space.
S ( sx sy sz )
Scale on each axis.
A ( angle axis ) / R ( angle axis )
Rotate by degrees where axis 0 = X, 1 = Y, 2 = Z. `R` is accepted as the same operator surface as `A`.

Axis deformation controls

The runtime supports both per-instance axis deformation and subset-scoped global axis deformation.

DSX / DSY / DSZ ( x y z )
Local axis deformation scale. These act on each emitted cube individually in primitive-local space.
DTX / DTY / DTZ ( x y z )
Local axis deformation translation. These also act per emitted cube and compose with the matching local DS* state.
GDSX / GDSY / GDSZ ( x y z )
Global subset deformation scale. The runtime deforms together only the cubes emitted under the same active scoped GDS*/GDT* state, using one shared bounding box for that subset.
GDTX / GDTY / GDTZ ( x y z )
Global subset deformation translation. Use bracket groups to scope these operators so they affect only cubes emitted inside that active subset.

Instances and materials

Geometry is produced through the instance operator. The current runtime supports four primitive identifiers, each followed by a texture name and scale value. CubeX, CubeY, and CubeZ also move the active transform forward by one local unit on X, Y, or Z after each instance.

I ( Cube texture scale )
Instantiate a cube primitive with a texture preset and scalar value.
I ( CubeX texture scale )
Instantiate an X-oriented beam-like cube, then advance the local transform by one unit along local X.
I ( CubeY texture scale )
Instantiate a Y-oriented cube variant, then advance the local transform by one unit along local Y.
I ( CubeZ texture scale )
Instantiate a Z-oriented beam-like cube, then advance the local transform by one unit along local Z.
I ( Cube brushedAluminum 0.35 )
Use a named renderer texture preset directly in the instance call.
I ( Cube roughblueshinysemitransparentmetal 0.35 )
Joined texture descriptors are also supported. Segments are read in fixed order: surface, color, reflectance, opacity, type, with any segment optional.

Textures

The active renderer supports both named procedural presets and joined texture descriptors.

roughConcrete / smoothConcrete / crackedAsphalt / redBrickWall / whiteTiles / blueCeramicTile
Structural and architectural surface presets.
shinySteel / brushedAluminum / oxidizedCopper / agedBronze / shinyGold / tarnishedSilver / rawIron / polishedTitanium / rustyMetal
Metallic and industrial finishes.
clearGlass / frostedGlass / tintedGreenGlass / stainedBlueGlass
Transparent and translucent clearGlass presets.
freshGrass / dryGrass / desertSand / muddySoil / grayStone / darkBasalt / whiteMarble / greenMarble
Ground, stone, and landscape-style textures.
oakPlanks / darkWalnut / pineWood / mahoganyWood / cherryWood / mapleWood
Wood and timber finishes.
iceBlock / moltenLava / deepWater / snowPowder / fluffyCloud / mossPatch / claySoil
Elemental and atmospheric presets.
carbonFiber / circuitBoard / glowingPanel / hazardStripe / steelGrid / chromeSurface
Sci-fi, technical, and industrial panel presets.
rough + blue + shiny + semitransparent + metal
Joined descriptors are parsed in that fixed order and compressed into one token such as `roughblueshinysemitransparentmetal`. Any segment may be omitted.
Example: Start -> I ( Cube frostedGlass 0.22 )
A compact example of applying a named texture preset in a grammar.

Expressions, calls, and variables

Expressions drive variables, transforms, calls, and conditionals. The parser accepts identifiers, numbers, arithmetic, unary negation, grouping, and the supported functions directly inside argument lists.

RuleName( expr1 expr2 )
Call a named rule with one or more expression arguments. Whitespace-separated lists are supported, and commas remain valid.
identifier( expr1 expr2 )
A variable-style statement occupies statement position in the current BNF surface and may use the same multi-argument form.
x + y * z
Inline arithmetic is supported inside transform arguments, calls, conditionals, and variable expression lists.
sin ( expr ) / cos ( expr ) / rand ( min max ) / rand ( var ) / float ( expr ) / int ( expr )
The evaluator currently recognises trigonometric helpers, a runtime random range function, rerolls from declared R-variable ranges, plus numeric casts to float and truncated int values.
multiline expression
Spaces, tabs, newlines, and carriage returns are all accepted inside expressions. Transform arguments and conditional expressions may span multiple lines.
spacing rule
Spaces around brackets and parentheses are optional. `T(0 1 0)`, `T ( 0 1 0 )`, and `[Rule]` are all valid as long as tokens remain unambiguous.

Viewer and workflow

The PHP site wraps the modular editor with account, file, and publishing workflow around the live WebGL scene.

Run Grammar
Executes the current grammar and refreshes the scene.
Save
Stores the current grammar in JSON-backed project storage under your account.
Publish to gallery
Marks a file public so it appears in the gallery live viewer.
Fit View / Reset View
Viewer controls adjust the camera around current scene bounds.
STL export
The embedded editor still exposes STL export from the underlying WebGL toolchain.
Practical note

The public site pages document the active workflow and operator surface that are visible in this packaged build. For deeper internals, the embedded editor still includes the original class reference and structure archetype documents inside assets/editor/docs/.