blob: 0bc86f7223167e54d877eec08df0e084fc84d07f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 ] ** 1..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
|