Pugs AST
if 42 { say "hello" }
else { say "oh no!" }
- An abstract syntax tree is a structure representing the parsed program
- Each implementation picks the types of nodes it carries
- In practice, the language drives the implementation choices
- together with the implementor's emphasis (speed, education...)
Why does `42` parse as `Val (VInt 42)`, and not just `42`? Because an
`if` can take any expression as the condition; this one just happens
to be a value. And Perl distinguishes between different types of
values, so this is an integer and not, say a sting.
If I had a more complex condition here, we'd just look at a more complex
AST for this.