=begin pod
This document is meant to describe in some detail what's going on in C<val()>
(found in C<src/core/allomorphs.pm>), since it's quite a big function. It
contains a bunch of inner subs to make the process as sane as possible without
resorting to a grammar.
The phrase "or fails" in statements on return values means it returns a
C<ProtoFailure>, something that always presents itself as undefined.
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 { '/' } |
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; | |
=TITLE URL::Find | |
=SUBTITLE A Perl 6 module to find all the URL's in a set of text. | |
=head1 DESCRIPTION | |
=para | |
By default it will match domain names | |
that use unicode characters such as http://правительство.рф. To only match ASCII domains use the | |
:ascii option. It will also find URL's that end in one of the restricted characters, so | |
`https://www.google.com, ` will pull out `https://www.google.com`. It will find all the URL's in a | |
text by default, or you can specify a maximum number with the :limit option. By default it will |
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
grammar url { | |
regex TOP { <anyprotocol> '://' <base> [ ['/' <term>]+ ]? '/'? } | |
token anyprotocol { <[ a..z A..Z ]> <[ a..z A..Z 0..9 . + - ]>+ } | |
token protocol {:i [http|https|ftp|git|ssh] } | |
token baseascii { [ <[a..z A..Z 0..9 \- . ]> ]+ } | |
token base { [ <:Number + :Letter + [ . - ]> ]+ } | |
token protected { <[ $ + ! * ( ) , . ; ? @ = % & # " ' ]> } | |
token allowed { \S } | |
regex term { <allowed>+ <!after <protected>> } | |
# token after { '/' <term> } |
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 IRC::Client::Message; | |
my role perlbot-file { | |
has Str $.filename; | |
has Str $!filename-bak = $!filename ~ '.bak'; | |
has $!file-bak-io = IO::Path.new($!filename-bak); | |
has %!hash; | |
has $!last-saved = 0; | |
method save ( $force? ) { | |
note "Entered save method for $.filename"; | |
say "last saved is $!last-saved"; |
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 IRC::Client::Message; | |
role perlbot-file { | |
has Str $.filename; | |
has Str $!filename-bak = $!filename ~ '.bak'; | |
has $!file-bak-io = IO::Path.new($!filename-bak); | |
has %!hash; | |
has $!last-saved = 0; | |
method save ( $force? ) { | |
note "Entered save method for $.filename"; | |
say "last saved is $!last-saved"; |
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