Update syntax.md

This commit is contained in:
Lauchmelder 2021-11-28 07:40:44 +01:00 committed by GitHub
parent 253513f62b
commit 74527f68d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@
[point(3, 4) -> A]
point(6, 7) -> B
line(A, B) -> AB
line[color=red, weight=4](A, B) -> AB
line(point(0, 0), point(100, 100))
circle(A, len(AB))
@ -16,6 +16,12 @@ These variables are immutable. Objects do not exist in this script, in fact, var
Lines in brackets `[]` are "hidden". They are parsed, but will not be rendered.
It is possible to add an optional set of parameters in front of each parameter list, in order to specify the appearance of the element.
## Primitives vs Functions
Primitives (e.g. `point`, `line`) and Functions (e.g. `len`, `intersection`) are syntactically indistinguishable.
Both can be used as parameters or instructions and can be assigned to variables. The only difference is that Primitives generate a visual output (unless they are surrounded by square brackets)
## Grammar
```
instruction ::= identifier({parameter, }) [-> identifer]