Created
November 18, 2016 00:14
-
-
Save samcv/7c1fc86a742880a8234c208c642a0ea8 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
#!/usr/bin/env perl6 | |
grammar http { | |
regex TOP { .* <url> .* } | |
regex url { <protocol> <protocoldel> <body>? (<after>+)? } | |
token protocol { (http)|(https)|(ftp)|(git)|(ssh) } | |
token protocoldel { '://' } | |
token body { <units>+ } | |
token units { <:Letter>|'.' } | |
token after { <seperator> (<allowed>+)? } | |
token seperator { '/' } | |
token allowed { <[a..z A..Z % & . = ? ]> } | |
} | |
sub MAIN ( Str $string ) { | |
my $match = http.parse($string); | |
say $match.gist; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment