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

A boolean with proto

Problem

Write a grammar that parses a bool, which is either the word true or the word false. Use a proto token with two :sym<…> variants. Parse 'true' and then 'false', printing whether each succeeded.

Example

The program prints:

True
True

Solution

See the solution

Course navigation

Solution: A number with proto   |   Solution: A boolean with proto