Course of Raku / Regexes and grammars / Grammars / Grammars, classes, and inheritance / Grammars are classes

Quiz — Inheriting grammars

Which keyword makes one grammar inherit from another?

1is
0does
0extends
0inherits

A grammar is a kind of class, so it uses the same inheritance keyword: grammar Loud is Base { … }. The derived grammar then inherits the base’s tokens and may override individual ones.

Course navigation

Grammars are classes   |   Proto tokens and alternation