Reference
The grammar and every keyword of version ebg 0, the view block’s keys, the limits, and the errors and
warnings a reader reports. Writing a model and Domains and couplings explain what the
statements are for.
Text
UTF-8 (a byte-order mark at the start is skipped); names and symbols are ASCII, and other characters appear only in strings and comments.
#starts a comment to the end of the line.A line end ends a statement, except inside parentheses, after an operator (
=and a leading-included) or a comma, and before a line that starts with.(a method continued on the next line).Names are
[A-Za-z_][A-Za-z0-9_]*, case-sensitive. Reserved:ebg,param,object,overlay,region,material,domain,subdomain,group,couple,include,view,outside,true,false,pi.Numbers are decimal or scientific (
1.8e-5), read and computed asdouble; a number or a result too large for adoubleis an error, and so is a shape’s argument too large for the precision the model is read in (properties are kept asdouble). Strings are double-quoted, with\"and\\.A column counts bytes, so a character outside ASCII earlier on the line counts as more than one column.
Statements
file := "ebg" INTEGER NEWLINE { statement NEWLINE }
statement := [ "param" ] name "=" expr # a value; a param may be overridden
| name "." "label" "(" args ")" # labels for the shape a name holds, wherever used
| "object" [ name "=" ] expr # the model, once; named, also a value
| "material" name [ properties ]
| "domain" name "{" { domain_item NEWLINE } "}"
| "couple" name "=" ( "volume" | "surface" ) "(" name "." name "," name "." name ")" [ properties ]
| "include" "(" STRING ")"
| "view" properties # for viewers; programs ignore it
domain_item := "subdomain" name "=" name { "," name } [ properties ]
| "group" name "=" selector { "," selector } [ properties ]
properties := "{" [ key "=" expr { ( "," | NEWLINE ) key "=" expr } ] "}" key := name { "." name }
What may be used before its definition:
A name of |
Is used |
|---|---|
a value or a param, a shape |
after its definition only |
a shape, in a label statement |
anywhere in the model; the statement’s arguments are read where the shape is defined |
a region, a material, a label |
anywhere in the model, by the materials, domains and couplings, which are resolved after the whole model is read |
a domain’s subdomain or group, in a coupling |
anywhere in the model |
Expressions
expr := term { ("+" | "-") term }
term := unary { ("*" | "/") unary }
unary := [ "-" ] postfix
postfix := primary { "." name "(" [ args ] ")" } # a.op(args) means op(a, args)
primary := NUMBER | STRING | "true" | "false" | "pi" | name
| "(" expr ")" | "(" expr "," expr "," expr ")" # grouping, a vector
| "(" expr "," expr ")" # a pair: only a selector's between = (a, b)
| name "(" [ args ] ")"
| "overlay" "{" { "region" name "=" expr [ "material" name ] NEWLINE } "}"
args := arg { "," arg } arg := expr | name "=" expr
Values are numbers, vectors, strings, bools and shapes. + and - take two numbers or two vectors, * a number
and a number or a vector, / a number or a vector by a number.
Shapes, operations and selectors
Every built-in shape, with its parameters and parts, is in Shapes, every operation in
Operations, and every selector in Domains and couplings. An axis is "x", "y"
or "z". A region named in a selector or a subdomain may be a region group (an overlay that is a region of
another), standing for its regions; outside is the region beyond the object.
Properties
A property’s value is a number, a vector, a string or a bool (true, false), written as any
expression is, params included. Its key is a name, or names joined by dots (color.copper,
inlet.profile). Properties are carried as written; the program reading the model gives them their
meaning, and reports a missing key or a value of the wrong type at the line where it is written.
The view block
view { ... }, once per model, says how a viewer opens it; programs reading the model ignore it. Its keys:
Key |
Sets |
|---|---|
|
where the eye is. Without a camera, the viewer fits one to the object. |
|
what the camera looks at (by default the center of the object’s box) |
|
the direction that is up on screen (by default |
|
the camera as a viewer prints it: its angles about the target, in degrees, and its distance, each over
the fitted camera’s when left out. Not together with |
|
the vertical field of view in degrees; |
|
the look of the backdrop and the floor: |
|
a plain background of that color, each component from 0 to 1, instead of the look’s backdrop (its floor kept) |
|
no floor under the object |
|
the color of a name, each component from 0 to 1: a material’s, a region’s, a surface label’s or a surface group’s, used when the viewer colors by that kind of name; colored by region, a region without one takes its material’s (given, or the palette’s), and a name without one otherwise takes the built-in palette’s |
Limits
An expression nests at most 256 deep, counting parentheses, calls, operators in a chain (a sum of 300 terms is too deep) and methods in a chain.
blur,mollify,repeatand the BVH operations (bvh_union,bvh_difference,smooth_union(..., bvh = true)) each start a sub-program of the tape; they nest at mostTape::MaxCallDepth(4) deep, through names too.A shape is built at most 4096 operations deep.
A
polygon_prismhas 3 to 4096 sides, andmollifytakes 1 to 64 samples per axis.
Errors and warnings
A reader reports every error and warning in a model, each with its file, line and column:
model.ebg:2:9: error: no shape or operation 'boks' (did you mean 'box'?)
model.ebg:5:33: warning: material 'steel' is not declared: it has no properties (write 'material steel { ... }')
After an error inside braces (a domain, or a material’s properties), the rest of the braces is skipped,
so a second error there shows once the first is fixed; a value with an error causes no further errors where it
is used. A model with an error is not read; a model with warnings is.
The warnings:
a material named by a region but not declared (it has no properties);
a material declared but used by no region;
a selector that can hold nothing, such as
interface(a, a)(a region has no interface with itself);surfaces(name)of a value the object does not use (it selects nothing);a key in the view block that a viewer does not read, pointing to the key meant (
red.colortocolor.red);a color in the view block for a name nothing in the model has (
color.bluewith only ablu).
Common errors, as a reader words them:
Message |
Cause |
|---|---|
|
a misspelled call |
|
a missing argument; the message lists the parameters |
|
a value the shape refuses |
|
a name defined twice, in one file or two |
|
a name used before its definition, or never defined |
|
a part labeled twice |
|
|
|
an overlay where the region of a point would not be clear |
|
a cycle of includes |
|
a file of another version of the language |
|
an override of a name that is not a param |
And when a domain is checked (see Domains and couplings):
Message |
Cause |
|---|---|
|
a surface the domain touches that no selector holds |
|
a subdomain with nothing a program could read |
|
a subdomain whose regions’ materials disagree on a key |
|
a region that does not exist; a plain object (not an overlay) has no named region |
The canonical form
A model has a canonical form, one statement per line with its comments kept, in which ebgstudio’s window
writes the files it edits (see The window); print() (see Reading models in C++) and
ebgstudio print write a model in it, keeping its includes or resolving them into one text.