Course of Raku / Regexes and grammars / Grammars

What is a grammar

A single regex is good at recognising one kind of text. But real data — a date, an e-mail address, a whole configuration file — has structure made of many smaller pieces. A grammar is a way to give names to those pieces and combine them into one description.

Before the grammar itself, this section introduces the building block it is made of: the named regex. Once you can name a pattern and reuse it, a grammar is simply a tidy collection of such named patterns.

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. A named token
  2. Reuse a token
  3. Year and month

Course navigation

Grammars   |   Named regexes