Skip to content

Commit

Permalink
[devdoc] update example AST (JuliaLang#43150)
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon committed Nov 29, 2021
1 parent c7b5f7d commit ddca0a8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions doc/src/devdocs/ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ call. Finally, chains of comparisons have their own special expression structure
| `a&&b` | `(&& a b)` |
| `x += 1` | `(+= x 1)` |
| `a ? 1 : 2` | `(if a 1 2)` |
| `a:b` | `(: a b)` |
| `a:b:c` | `(: a b c)` |
| `a,b` | `(tuple a b)` |
| `a==b` | `(call == a b)` |
| `1<i<=n` | `(comparison 1 < i <= n)` |
Expand All @@ -78,10 +76,10 @@ call. Finally, chains of comparisons have their own special expression structure
| `[x y]` | `(hcat x y)` |
| `[x y; z t]` | `(vcat (row x y) (row z t))` |
| `[x;y;; z;t;;;]` | `(ncat 3 (nrow 2 (nrow 1 x y) (nrow 1 z t)))` |
| `[x for y in z, a in b]` | `(comprehension x (= y z) (= a b))` |
| `T[x for y in z]` | `(typed_comprehension T x (= y z))` |
| `[x for y in z, a in b]` | `(comprehension (generator x (= y z) (= a b)))` |
| `T[x for y in z]` | `(typed_comprehension T (generator x (= y z)))` |
| `(a, b, c)` | `(tuple a b c)` |
| `(a; b; c)` | `(block a (block b c))` |
| `(a; b; c)` | `(block a b c)` |

### Macros

Expand Down Expand Up @@ -130,11 +128,11 @@ instead of `:import`.
Julia supports more number types than many scheme implementations, so not all numbers are represented
directly as scheme numbers in the AST.

| Input | AST |
|:----------------------- |:------------------------------------------------------- |
| `11111111111111111111` | `(macrocall @int128_str (null) "11111111111111111111")` |
| `0xfffffffffffffffff` | `(macrocall @uint128_str (null) "0xfffffffffffffffff")` |
| `1111...many digits...` | `(macrocall @big_str (null) "1111....")` |
| Input | AST |
|:----------------------- |:-------------------------------------------------------- |
| `11111111111111111111` | `(macrocall @int128_str nothing "11111111111111111111")` |
| `0xfffffffffffffffff` | `(macrocall @uint128_str nothing "0xfffffffffffffffff")` |
| `1111...many digits...` | `(macrocall @big_str nothing "1111....")` |

### Block forms

Expand All @@ -157,7 +155,7 @@ parses as:
```
(if a (block (line 2) b)
(elseif (block (line 3) c) (block (line 4) d)
(block (line 5 e))))
(block (line 6 e))))
```

A `while` loop parses as `(while condition body)`.
Expand Down

0 comments on commit ddca0a8

Please sign in to comment.