Course of Raku / Regexes and grammars / Grammars / Action classes / Exercises
A multiply action
Problem
Write a grammar that parses two numbers joined by a *,
as in '6*7'. Write a separate action class
with a method per token: a and b each make
their value as an integer, and TOP makes the
product by reading what a and
b made (with .made). Parse '6*7'
with the action class and print .made.
Example
The program prints:
42Solution
Course navigation
← Solution: An upper-case action | Solution: A multiply action →