Created
December 5, 2015 18:33
-
-
Save zoffixznet/9f64995f16faa6fc7925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
# use Grammar::Tracer; | |
grammar IRC::Grammar:ver<1.001001> { | |
token TOP { [ <message> \n ]+ } | |
token message { [':' <prefix> ' '+ ]? <command> <params> } | |
token prefix { [<servername> | <nick>] [ '!' <user> ]? [ '@' <host> ]? } | |
token command { <[a..zA..Z]>+ | <[0..9]>**3 } | |
token params { ' '* [ ':' <trailing> | <middle> <params> ]? } | |
token middle { <-[:\ \0\r\n]> <-[\ \0\r\n]>+ } | |
token trailing { <-[\0\r\n]>+ } | |
token target { <to> [ ',' <target> ]? } | |
token to { <channel> | <user> '@' <servername> | <nick> | <mask> } | |
token channel { ['#' | '&'] <chstring> } | |
token servername { <host> } # see RFC 952 [DNS:4] for allowed hostnames | |
token host { <-[\s!@]>+ } # see RFC 952 [DNS:4] for allowed hostnames | |
token nick { <[a..zA..Z]> [ <[a..zA..Z0..9]> | <[-\[\]\\`^{}]> ]+ } | |
token mask { <[#$]> <chstring> } | |
token chstring { <-[\ \a\0\r\n,]> } | |
token user { <-[\ \0\r\n]>+ } | |
} | |
my @messages = ( | |
":verne.freenode.net 372 Perl6IRC :- running for their sustained support.\r\n", | |
); | |
say so IRC::Grammar.parse(@messages[$_]) for 0..@messages.elems-1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment