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

Inherit a grammar

Problem

Write a base grammar Animal whose TOP matches a sound token equal to meow. Then write a grammar Dog that inherits from it and overrides sound to match woof. Parse 'woof' with the derived grammar and print whether it succeeded.

Example

The program prints:

True

Solution

See the solution

Course navigation

Quiz — Grammar inheritance   |   Solution: Inherit a grammar