aboutsummaryrefslogtreecommitdiff
path: root/lib/old-IRC/Grammar/Actions.pm6
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-05-19 19:49:39 -0400
committerZoffix Znet <cpan@zoffix.com>2016-05-19 19:49:39 -0400
commit3f65d48264430428a2165f6a9f5a4e16f823f6b8 (patch)
tree6da1f46181c3070b3eeb4ede56c3cba3623d0258 /lib/old-IRC/Grammar/Actions.pm6
parente997c1b0b5ad796425abfc9f81b91947357172ce (diff)
Start new design docs
Diffstat (limited to 'lib/old-IRC/Grammar/Actions.pm6')
-rw-r--r--lib/old-IRC/Grammar/Actions.pm626
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/old-IRC/Grammar/Actions.pm6 b/lib/old-IRC/Grammar/Actions.pm6
new file mode 100644
index 0000000..234e392
--- /dev/null
+++ b/lib/old-IRC/Grammar/Actions.pm6
@@ -0,0 +1,26 @@
+unit class IRC::Grammar::Actions;
+method TOP ($/) { $/.make: $<message>>>.made }
+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;
+}