Course of Raku / Regexes and grammars / Grammars

The parse tree, make and made

Parsing tells you that a string matches a grammar, and it builds a parse tree — a match object with a named capture for every token. But usually you do not want the raw text; you want a result: the integer 42, not the characters 4 and 2.

This section shows how to walk the parse tree, and how to attach a computed value to a match with make, then read it back with made.

Topics in this section

Practice

Complete the quizzes that cover the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. Extract the number
  2. Multiply a pair
  3. Reverse a word

Course navigation

Solution: A boolean with proto   |   The match tree