Skip to content

Commit ebda082

Browse files
authored
Fixes for AST reference documentation (#479)
1 parent 21c6774 commit ebda082

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/src/reference.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class of tokenization errors and lets the parser deal with them.
7676
* Using `try catch else finally end` is parsed with `K"catch"` `K"else"` and `K"finally"` children to avoid the awkwardness of the optional child nodes in the `Expr` representation (#234)
7777
* The dotted import path syntax as in `import A.b.c` is parsed with a `K"importpath"` kind rather than `K"."`, because a bare `A.b.c` has a very different nested/quoted expression representation (#244)
7878
* We use flags rather than child nodes to represent the difference between `struct` and `mutable struct`, `module` and `baremodule` (#220)
79-
* Iterations are represented with the `iteration` head rather than `=` within the header of a `for`. Thus `for i=is ; body end` parses to `(for (iteration i is) (block body))`. Cartesian iteration as in `for a=as, b=bs body end` are represented with a longer `iteration` block rather than a `block` containing `=` because these lists of iterators are neither semantically nor syntactically a sequence of statements, unlike other uses of `block`. Generators also use the `iteration` head - see information on that below.
79+
* Iterations are represented with the `iteration` and `in` heads rather than `=` within the header of a `for`. Thus `for i=is ; body end` parses to `(for (iteration (in i is)) (block body))`. Cartesian iteration as in `for a=as, b=bs body end` are represented with a nested `(iteration (in a as) (in b bs))` rather than a `block` containing `=` because these lists of iterators are neither semantically nor syntactically a sequence of statements, unlike other uses of `block`. Generators also use the `iteration` head - see information on that below.
80+
* Short form functions like `f(x) = x + 1` are represented with the `function` head rather than the `=` head. In this case the `SHORT_FORM_FUNCTION_FLAG` flag is set to allow the surface syntactic form to be easily distinguished from long form functions.
8081

8182
## More detail on tree differences
8283

@@ -123,16 +124,16 @@ source much more closely. For example, `(xy for x in xs for y in ys)` is parsed
123124
```
124125
(generator
125126
xy
126-
(iteration x xs)
127-
(iteration y ys))
127+
(iteration (in x xs))
128+
(iteration (in y ys)))
128129
```
129130

130131
And the cartesian iteration `(xy for x in xs, y in ys)` is parsed as
131132

132133
```
133134
(generator
134135
xy
135-
(iteration x xs y ys))
136+
(iteration (in x xs) (in y ys)))
136137
```
137138

138139
### Whitespace trivia inside strings

0 commit comments

Comments
 (0)