Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created December 5, 2015 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/629e13e0214cc6e3e2e2 to your computer and use it in GitHub Desktop.
Save zoffixznet/629e13e0214cc6e3e2e2 to your computer and use it in GitHub Desktop.
use v6;
use Grammar::Debugger;
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 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 user { <-[\ \0\r\n]>+ }
}
say IRC::Grammar.parse(":verne.freenode.net 372 Perl6IRC :- running for their sustained support.\r\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment