Update syntax.md

This commit is contained in:
Lauchmelder 2021-11-27 22:59:21 +01:00 committed by GitHub
parent 79c54f3c0d
commit 0b637d6870
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,21 @@
# Syntax # Syntax
``` ```
point(3 | 4) -> A [point(3, 4) -> A]
point(6 | 7) -> B point(6, 7) -> B
line(A, B) -> AB line(A, B) -> AB
line(0 | 0, 100 | 100) line(point(0, 0), point(100, 100))
circle(A, len(AB)) circle(A, len(AB))
``` ```
## Behaviour
Every line is one instruction. It is possible to assign instructions names to re-use them later.
These variables are immutable. Objects do not exist in this script, in fact, variables are more similar to C-style macros than actual variables.
Lines in brackets `[]` are "hidden". They are parsed, but will not be rendered.
## Primitives ## Primitives
* `Point point(x, y)` is a 2D point. It returns an element of type `Point` * `Point point(x, y)` is a 2D point. It returns an element of type `Point`
* `Line line(Point from, Point to)` is a straight line. It returns an element of type `Line`. * `Line line(Point from, Point to)` is a straight line. It returns an element of type `Line`.
@ -21,4 +27,4 @@ instruction ::= identifier({parameter, }) [-> identifer]
parameter ::= instruction | identifier | number parameter ::= instruction | identifier | number
identifier ::= (A-Za-z) identifier ::= (A-Za-z)
number ::= (0-9)[.(0-9)] number ::= (0-9)[.(0-9)]
``` ```