| Bytes | Lang | Time | Link |
|---|---|---|---|
| 040 | Charcoal | 241005T171209Z | Neil |
Charcoal, 43 40 bytes
↶≔⁰ηFS≡ι(⊞υ⁺ηLυ)«↖⁻ⅉ⊟υ\¿υ/»«JηηFυ↙↗ι/≦⊕η
Try it online! Link is to verbose version of code. Takes input as a string of atoms and parentheses without spaces. Explanation:
↶
Change the default text output direction to upwards.
≔⁰η
Start with 0 atoms so far.
FS≡ι
Switch on each input character.
(⊞υ⁺ηLυ
For (, save the row where this expression starts.
)«
For )...
↖⁻ⅉ⊟υ
... draw a line of \s back to the last saved row, ...
\
... with an extra \ for the atom at the start of that expression, ...
¿υ/»
... and a joining / if this is not the outer expression.
«JηηFυ↙
Otherwise, jump to the position of this atom on the canvas, which is one square down and right for each atom, plus one square down and left for each level of nesting.
↗ι/
Output the atom and the joining /.
≦⊕η
Increment the atom count.