aboutsummaryrefslogtreecommitdiff
path: root/lib/IRC/Client/Grammar/Actions.pm6
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IRC/Client/Grammar/Actions.pm6')
-rw-r--r--lib/IRC/Client/Grammar/Actions.pm631
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/IRC/Client/Grammar/Actions.pm6 b/lib/IRC/Client/Grammar/Actions.pm6
new file mode 100644
index 0000000..74ae4e8
--- /dev/null
+++ b/lib/IRC/Client/Grammar/Actions.pm6
@@ -0,0 +1,31 @@
+unit class IRC::Client::Grammar::Actions;
+
+method TOP ($/) { $/.make: ($<message>ยป.made, $<left-overs>) }
+method left-overs ($/) {
+ $/.made: $/.defined ?? !$/ !! '';
+}
+
+method message ($/) {
+ my $pref = $/<prefix>;
+ my %args = command => ~$/<command>;
+ for qw/nick user host/ {
+ $pref{$_}.defined or next;
+ %args<who>{$_} = $pref{$_}.Str;
+ }
+ %args<who><host> = ~$pref<servername> if $pref<servername>.defined;
+
+ my $p = $/<params>;
+
+ for ^100 { # bail out after 100 iterations; we're stuck
+ if ( $p<middle>.defined ) {
+ %args<params>.append: ~$p<middle>;
+ }
+ if ( $p<trailing>.defined ) {
+ %args<params>.append: ~$p<trailing>;
+ last;
+ }
+ $p = $p<params>;
+ }
+
+ $/.make: %args;
+}