aboutsummaryrefslogtreecommitdiff
path: root/lib/IRC/Client/Grammar/Actions.pm6
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-06-03 07:01:14 -0400
committerZoffix Znet <cpan@zoffix.com>2016-06-03 07:01:14 -0400
commit0daa494480f7abe37a6e593c6238811009b7b914 (patch)
tree5916cb48581e9478c8b92bb458589940f6fa814e /lib/IRC/Client/Grammar/Actions.pm6
parent495050a801901460fbd6a9c525216612b0d2f470 (diff)
Start rewrite
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;
+}