Course of Raku / Regexes and grammars / Grammars / The parse tree, make and made / The match tree
Quiz — The match tree
What does the following program print?
grammar Point {
token TOP { <x> ',' <y> }
token x { \d+ }
token y { \d+ }
}
say Point.parse('3,4')<y>;| 0 | 「3」 |
| 1 | 「4」 |
| 0 | 「3,4」 |
| 0 | 「y」 |
Each token becomes a named branch of the match tree.
<y> on the result reaches the y token,
which matched 4, so the program prints
「4」.
Course navigation
← The match tree | make and made →