# Formal GBNF (llama.cpp / XGrammar / vLLM) Constrained-Decoding Grammar for Forma-Pipe # Guarantees 0% syntax errors under grammar-constrained LLM generation. root ::= ws (stmt (nl stmt)*)? ws stmt ::= ident ws "=" ws expr | expr expr ::= add-expr (ws "|" ws pipe-call)* pipe-call ::= pipe-op "(" ws arg-list? ws ")" add-expr ::= mul-expr (ws ("+" | "-") ws mul-expr)* mul-expr ::= unary-expr (ws ("*" | "/") ws unary-expr)* unary-expr ::= ("+" | "-") ws unary-expr | atom atom ::= call | tuple-or-paren | list-lit | number | string | selector-kw | bool-lit | ident call ::= func-name "(" ws arg-list? ws ")" arg-list ::= arg (ws "," ws arg)* (ws ",")? arg ::= (kw-name ws "=" ws)? expr tuple-or-paren ::= "(" ws (expr (ws "," ws expr)* (ws ",")?)? ws ")" list-lit ::= "[" ws (expr (ws "," ws expr)* (ws ",")?)? ws "]" func-name ::= "box" | "cyl" | "cylinder" | "prism" | "pipe" | "hollow_cyl" | "cone" | "frustum" | "sphere" | "torus" | "revolve" | "arc_tube" | "tube" | "extrude2d" | "loft" | "thread" | "helix" | "sweep" | "text3d" | "text" | "bezier" | "nurbs" | "bspline" | "load" | "import" | "clearance" | "section" | "checkpoint" | "rollback" | "undo" | "units" | "del" | "remove" | "sqrt" | "sin" | "cos" | "asin" | "acos" | "abs" | "deg" | "rad" | pipe-op pipe-op ::= "add" | "union" | "cut" | "sub" | "diff" | "intersect" | "bevel" | "shell" | "extrude" | "inset" | "subsurf" | "subdiv" | "move" | "translate" | "rot" | "rotate" | "scale" | "align_z0" | "align" | "on" | "place_on" | "mirror" | "pattern_linear" | "pattern_radial" | "array" | "radial" | "mat" | "material" | "color" | "decimate" | "lod" | "smooth" | "flat" | "solidify" | "deform" | "unwrap" | "uv" | "remesh" | "bisect" selector-kw ::= "vertical" | "horizontal" | "top_rim" | "bottom_rim" | "outer_rim" | "rim" | "sharp" | "boundary" | "all" | "top" | "bottom" | "front" | "back" | "left" | "right" | "sides" | "side" | "min" | "center" | "mid" | "max" | "x" | "y" | "z" | "pi" kw-name ::= "sx" | "sy" | "sz" | "r" | "h" | "r0" | "r1" | "R" | "segs" | "segments" | "axis" | "at" | "center" | "z0" | "z1" | "rot" | "rotate" | "rx" | "rz" | "start" | "end" | "start_deg" | "end_deg" | "profile" | "points" | "pts" | "closed" | "edges" | "faces" | "w" | "width" | "t" | "thickness" | "wall" | "open_top" | "dist" | "d" | "amt" | "amount" | "depth" | "levels" | "level" | "n" | "count" | "crease" | "union" | "mode" | "val" | "to" | "gap" | "step" | "name" | "color" | "metallic" | "m" | "roughness" | "tag" | "other" | "base" | "holes" | "scale_end" | "taper" | "twist" | "twist_deg" | "path" | "corners" | "angle" | "factor" | "subdivs" | "weighted" | "margin" | "voxel_size" | "size" | "normal" | "offset" | "clear_inner" | "ratio" | "target_faces" | "degree" | "deg" | "weights" | "sections" | "profiles" | "r_out" | "ro" | "outer" | "r_in" | "ri" | "inner" | "r_minor" | "r_min" | "r_major" | "r_maj" | "pitch" | "p" | "turns" | "file" | "yup" | "text" | "height" | "radius" | "major" | "minor" | "unit" bool-lit ::= "true" | "false" ident ::= [a-zA-Z_] [a-zA-Z0-9_]* number ::= "-"? ([0-9]+ ("." [0-9]+)? | "." [0-9]+) ([eE] [+-]? [0-9]+)? string ::= "\"" [^"\\\n]* "\"" | "'" [^'\\\n]* "'" nl ::= ([ \t]* ("#" [^\n]*)? ("\r"? "\n" | ";"))+ [ \t]* ws ::= [ \t]*