|
|
||
|---|---|---|
| .github | CI test prior to release | |
| .META | CI test prior to release | |
| doc | CI test prior to release | |
| lib | CI test prior to release | |
| t | CI test prior to release | |
| xt | Move doc and add coverage tests | |
| .gitignore | Add preliminary coverage testing | |
| Changes | 0.0.2 | |
| dist.ini | Move doc and add coverage tests | |
| LICENSE | Initial commit | |
| META6.json | CI test prior to release | |
| README.md | CI test prior to release | |
| run-tests | CI test prior to release | |
Actions Status Actions Status Actions Status
NAME
actions - Introduce "actions" keyword
SYNOPSIS
use actions;
grammar A { token TOP {<.print>+} }
actions B { }
say A.parse("foo", :actions(B)); # 「foo」
DESCRIPTION
The actions distribution adds an actions keyword that is almost identical to the class keyword, except that it limits the execution of methods to methods that only exist within the actions itself.
This is important when a class is used to have associated methods executed whenever a regex / token / rule in the grammar matches. The above example would fail if it were a class B, because it would try to execute the Mu::print method, which doesn't accept any arguments, resulting in:
Cannot resolve caller print(B:U: A:D); none of these signatures matches:
(Mu: *%_)
Inspired by a discussion in the Raku Problem Solving repository.
AUTHOR
Elizabeth Mattijsen liz@raku.rocks
Source can be located at: https://codeberg.org/lizmat/actions . Comments and Pull Requests are welcome.
If you like this module, or what I'm doing more generally, committing to a small sponsorship would mean a great deal to me!
COPYRIGHT AND LICENSE
Copyright 2023, 2024, 2026 Elizabeth Mattijsen
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.