Course of Raku / Regexes and grammars / Grammars / Tokens and rules / Exercises

A spaced assignment

Problem

Write a grammar whose TOP is a rule matching key = value, where the key and the value are tokens of one or more word characters, and there may be spaces around the =. Parse 'x = 5' and print whether it succeeded (a plain True or False).

Example

The program prints:

True

Solution

See the solution

Course navigation

Solution: A spaced rule   |   Solution: A spaced assignment