Course of Raku / Regexes and grammars / Grammars / Action classes / Inline actions vs action classes
Quiz — Action classes
How do you tell .parse to use an action class called
MyActions?
| 0 | Grammar.parse($str, MyActions) |
| 1 | Grammar.parse($str, actions => MyActions.new) |
| 0 | Grammar.parse($str).MyActions |
| 0 | Grammar.parse($str, action => MyActions) |
The action object is passed with the actions named
argument, and it must be an instance, created with
.new. As the grammar parses, the matching token methods on
that instance run and build the result.
Course navigation
← Inline actions vs action classes | One grammar, two actions →