aboutsummaryrefslogtreecommitdiff
path: root/lib/IRC
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IRC')
-rw-r--r--lib/IRC/Grammar.pm651
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/IRC/Grammar.pm6 b/lib/IRC/Grammar.pm6
new file mode 100644
index 0000000..f859edc
--- /dev/null
+++ b/lib/IRC/Grammar.pm6
@@ -0,0 +1,51 @@
+#! /usr/bin/env false
+
+use v6.d;
+
+unit grammar IRC::Grammar;
+
+regex TOP {
+ [ ':' <prefix> <.ws> ]?
+ <command>
+ <.ws>
+ <params>* % <.ws>
+
+ # Use an OPTIONAL crlf, as opposed to RFC 2812's required crlf, to make
+ # it easier for people to use this in regular programs, where they're
+ # more likely to encounter the IRC messages without \r\n.
+ "\r\n"?
+}
+
+token prefix { <nickname> [ [ '!' <user> ]? '@' <host> ]? | <servername=.host> }
+token command { \d ** 3 | \w+ }
+token middle { <.nospcrlfcl>+ }
+token params { <.middle> | [ ':' <( <trailing> )> ] }
+token trailing { <-[ \0 \r \n ]>* }
+token nickname { [ \w | <special> ] [ \w | \d | <special> | '-' ]* }
+token special { <[ [ \] \\ ` _ ^ { | } ]>+ }
+token user { <-[ \r \n \s @ ]>+ }
+token host { <hostname> | <hostaddr> }
+token hostname { <shortname> [ '.' <shortname> ]* '.'? }
+token hostaddr { <ip6addr> | <ip4addr> }
+token ip4addr { [ \d ** 1..3 ] ** 4 % '.' }
+token ip6addr { [ <[ \d a..f A..F ]> ** 1..4 ] ** 8 % ':' }
+token shortname { <[ \w \d / ]> <[ \w \d / \- ]>* <[ \w \d / ]>? }
+token nospcrlfcl { <-[ \0 \r \n \s : ]> }
+
+=begin pod
+
+=NAME IRC::Grammar
+=AUTHOR Patrick Spek <~tyil/raku-devel@lists.sr.ht>
+=VERSION 0.0.0
+
+=head1 Synopsis
+
+=head1 Description
+
+=head1 Examples
+
+=head1 See also
+
+=end pod
+
+# vim: ft=perl6 noet