Skip to content

Commit

Permalink
Fix AST w.r.t. associativity in Source Analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
guilliamxavier authored and Veykril committed Sep 6, 2023
1 parent 7716ac0 commit 99a3c3b
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/syntax-extensions/source-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,27 @@ Note that this has *no relationship* to the AST the expression would produce; in
root node, there are *seven* token trees at the root level. For reference, the AST would be:

```text
┌─────────┐
│ BinOp │
│ op: Add │
┌╴│ lhs: ◌ │
┌─────────┐ │ │ rhs: ◌ │╶┐ ┌─────────┐
│ Var │╶┘ └─────────┘ └╴│ BinOp │
│ name: a │ │ op: Add │
└─────────┘ ┌╴│ lhs: ◌ │
┌─────────┐ │ │ rhs: ◌ │╶┐ ┌─────────┐
│ Var │╶┘ └─────────┘ └╴│ BinOp │
│ name: b │ │ op: Add │
└─────────┘ ┌╴│ lhs: ◌ │
┌─────────┐
│ BinOp │
│ op: Add │
┌╴│ lhs: ◌ │
┌─────────┐ │ │ rhs: ◌ │╶┐ ┌─────────┐
│ BinOp │╶┘ └─────────┘ └╴│ Var │
│ op: Add │ │ name: e │
┌╴│ lhs: ◌ │ └─────────┘
┌─────────┐ │ │ rhs: ◌ │╶┐ ┌─────────┐
│ Var │╶┘ └─────────┘ └╴│ Index │
│ name: c │ ┌╴│ arr: ◌ │
└─────────┘ ┌─────────┐ │ │ ind: ◌ │╶┐ ┌─────────┐
│ Var │╶┘ └─────────┘ └╴│ LitInt │
│ name: d │ │ val: 0 │
└─────────┘ └─────────┘
┌─────────┐ ┌─────────┐ │ │ rhs: ◌ │╶┐ ┌─────────┐
│ Var │╶┐ │ BinOp │╶┘ └─────────┘ └╴│ BinOp │
│ name: a │ │ │ op: Add │ │ op: Add │
└─────────┘ └╴│ lhs: ◌ │ ┌╴│ lhs: ◌ │
┌─────────┐ ┌╴│ rhs: ◌ │ ┌─────────┐ │ │ rhs: ◌ │╶┐ ┌─────────┐
│ Var │╶┘ └─────────┘ │ Var │╶┘ └─────────┘ └╴│ Index │
│ name: b │ │ name: c │ ┌╴│ arr: ◌ │
└─────────┘ └─────────┘ ┌─────────┐ │ │ ind: ◌ │╶┐
│ Var │╶┘ └─────────┘ │
│ name: d │ ┌─────────┐ │
└─────────┘ │ LitInt │╶┘
│ val: 0 │
└─────────┘
```

It is important to understand the distinction between the AST and token trees. When writing macros,
Expand Down

0 comments on commit 99a3c3b

Please sign in to comment.