Skip to content

Commit

Permalink
docs: Update evy's grammar and examples
Browse files Browse the repository at this point in the history
This doc update is a result of a bodged merge to master and has already
been reviewed previously 🙀.
  • Loading branch information
juliaogris committed Sep 9, 2022
1 parent 6c7268a commit 23daba3
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 82 deletions.
46 changes: 23 additions & 23 deletions docs/syntax_by_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ specification see the [syntax grammar].

### `for``range` array

for x := range num[ 1 2 3]
for x := range num[ 1 2 3 ]
print x // 1 2 3
end

Expand All @@ -112,7 +112,7 @@ specification see the [syntax grammar].

## Function definition

func add:int a:int b:int
func add:num a:num b:num
return a + b
end

Expand Down Expand Up @@ -149,9 +149,9 @@ specification see the [syntax grammar].

### Concatenation, append, prepend

z = z + int[ 100 ] // [ 1 2 3 4 5 6 100 ]
z = append z 101 // [ 1 2 3 4 5 6 100 101]
z = prepend z 0 // [ 0 1 2 3 4 5 6 100 101]
z = z + num[ 100 ] // [ 1 2 3 4 5 6 100 ]
z = append z 101 // [ 1 2 3 4 5 6 100 101 ]
z = prepend z 0 // [ 0 1 2 3 4 5 6 100 101 ]

### Slicing

Expand Down Expand Up @@ -197,20 +197,20 @@ specification see the [syntax grammar].

## Type reflection

reflect "abc" // {type: "string"}
reflect true // {type: "bool"}
reflect num[1 2] // {type: "array",
// sub: {type: "num"}
// }
reflect num[[1 2] [3 4]] // {
// type: "array",
// sub: {
// type: "array"
// sub: {
// type: "num"
// }
// }
// }
reflect "abc" // {type: "string"}
reflect true // {type: "bool"}
reflect num[ 1 2 ] // {type: "array",
// sub: {type: "num"}
// }
reflect num[ [1 2] [3 4] ] // {
// type: "array",
// sub: {
// type: "array"
// sub: {
// type: "num"
// }
// }
// }

### Type reflection Usage Example

Expand Down Expand Up @@ -271,10 +271,10 @@ specification see the [syntax grammar].

### Strings

"Hello"[2] // "l"
"Hello world"[1:5] // "ello"
join ["one" "two"] ", " // "one, two"
split "hi there" " " // ["hi" "there"]
"Hello"[2] // "l"
"Hello world"[1:5] // "ello"
join [ "one" "two" ] ", " // "one, two"
split "hi there" " " // [ "hi" "there" ]

### Length

Expand Down
Loading

0 comments on commit 23daba3

Please sign in to comment.