Skip to content

Instantly share code, notes, and snippets.

@KamilaBorowska
Created September 2, 2012 09:42
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 KamilaBorowska/3596274 to your computer and use it in GitHub Desktop.
Save KamilaBorowska/3596274 to your computer and use it in GitHub Desktop.
glitchmr@strawberry ~> cat debug.p6
use Grammar::Tracer;
grammar RawEvent {
token TOP {
^
[':' [<user>|<server=host>] <.space> || <?>]
<command>
[ <.space>+ [':'$<params>=(.*)$ || $<params>=<-space>+] ]*
$
}
token user {
$<nick>=<-[:!]>+ '!' $<ident>=<-[@]>+ '@' <host>
}
token host {
#[ <-space - [. $ @ !]>+ ] ** '.'
#Due to some IRC servers/services allowing anything as a host format,
#I've decided to define a 'host' as 'anything but a space'. Bah.
<-space>+
}
token command {
<.alpha>+ | \d\d\d
}
token params {
[ ':'.*$ | <-space>+ ]
}
}
print so RawEvent.parse(':moorcock.freenode.net 004 SixtySixBot moorcock.freenode.net ircd-seven-1.1.3 DOQRSZaghilopswz CFILMPQbcefgijklmnopqrstvz bkloveqjfI')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment