unit class IRC::Client::Grammar::Actions; use IRC::Client::Message::Numeric; has $.irc; has $.server; method TOP ($/) { $/.make: ( $ยป.made, ~( $ // '' ), ); } method message ($match) { my %args; my $pref = $match; for qw/nick user host/ { $pref{$_}.defined or next; %args{$_} = ~$pref{$_}; } %args = ~$pref if $pref.defined; my $p = $match; loop { if ( $p.defined ) { %args.append: ~$p; } if ( $p.defined ) { %args.append: ~$p; last; } last unless $p.defined; $p = $p; } my %msg-args = irc => $!irc, nick => %args//'', username => %args//'', host => %args//'', server => $!server; . = . ~ '!' ~ . ~ '@' ~ . given %msg-args; my $msg; given ~$match { when /^ $=(<[0..9]>**3) $/ { $msg = IRC::Client::Message::Numeric.new: :command( ~$ ), :args( %args ), |%msg-args; } } $match.make: $msg; }