Skip to content

Commit

Permalink
Update ast.md to where syntax (#22109)
Browse files Browse the repository at this point in the history
  • Loading branch information
musm authored and ararslan committed Jun 13, 2017
1 parent c6799e6 commit 49ea8df
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions doc/src/devdocs/ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ parses as:
```
(if a (block (line 2) b)
(block (line 3) (if c (block (line 4) d)
(block (line 5) e (line 6) f))))
(block (line 5) e
(line 6) f))))
```

A `while` loop parses as `(while condition body)`.
Expand All @@ -491,17 +492,18 @@ they are parsed as a block: `(for (block (= v1 iter1) (= v2 iter2)) body)`.
A basic function definition is parsed as `(function (call f x) body)`. A more complex example:

```julia
function f{T}(x::T; k = 1)
function f(x::T; k = 1) where T
return x+1
end
```

parses as:

```
(function (call (curly f T) (parameters (kw k 1))
(:: x T))
(block (line 2 file.jl) (return (call + x 1))))
(function (where (call f (parameters (kw k 1))
(:: x T))
T)
(block (line 2) (return (call + x 1))))
```

Type definition:
Expand All @@ -515,8 +517,8 @@ end
parses as:

```
(type #t (curly Foo (<: T S))
(block (line 2 none) (:: x T)))
(type true (curly Foo (<: T S))
(block (line 2) (:: x T)))
```

The first argument is a boolean telling whether the type is mutable.
Expand Down

0 comments on commit 49ea8df

Please sign in to comment.