From 0b637d6870660dc4baa567aa67aa214507ac12f1 Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Sat, 27 Nov 2021 22:59:21 +0100 Subject: [PATCH 1/3] Update syntax.md --- src/doc/syntax.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/doc/syntax.md b/src/doc/syntax.md index c01cdf1..b66f171 100644 --- a/src/doc/syntax.md +++ b/src/doc/syntax.md @@ -1,15 +1,21 @@ # Syntax ``` -point(3 | 4) -> A -point(6 | 7) -> B +[point(3, 4) -> A] +point(6, 7) -> B line(A, B) -> AB -line(0 | 0, 100 | 100) +line(point(0, 0), point(100, 100)) 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 * `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`. @@ -21,4 +27,4 @@ instruction ::= identifier({parameter, }) [-> identifer] parameter ::= instruction | identifier | number identifier ::= (A-Za-z) number ::= (0-9)[.(0-9)] -``` \ No newline at end of file +``` From 253513f62b0d67e2e0ee5d2fb419984734738720 Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Sat, 27 Nov 2021 23:02:34 +0100 Subject: [PATCH 2/3] Update syntax.md --- src/doc/syntax.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/doc/syntax.md b/src/doc/syntax.md index b66f171..a8039d7 100644 --- a/src/doc/syntax.md +++ b/src/doc/syntax.md @@ -16,11 +16,6 @@ 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. -## Primitives -* `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`. -* `Circle circle(Point center, radius)` draws a circle at `center` and `radius` - ## Grammar ``` instruction ::= identifier({parameter, }) [-> identifer] From 74527f68d6c3550eb29e3f7ac48d3b891d9fb07d Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Sun, 28 Nov 2021 07:40:44 +0100 Subject: [PATCH 3/3] Update syntax.md --- src/doc/syntax.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/doc/syntax.md b/src/doc/syntax.md index a8039d7..173f3ac 100644 --- a/src/doc/syntax.md +++ b/src/doc/syntax.md @@ -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]