diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-07-21 18:21:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-21 18:21:36 +0100 |
| commit | 6ba8a9c79bb3368c25bf3c1aebd05bb888dd07b4 (patch) | |
| tree | e183904b2421a1df2ffdb29b966b252d7eadfb1b | |
| parent | d3555cbcb94591c037667d64c72ad06cc9dd127a (diff) | |
| parent | 7386f0133e54d93b83a999b8d9888f38095a9ded (diff) | |
| download | perlweeklychallenge-club-6ba8a9c79bb3368c25bf3c1aebd05bb888dd07b4.tar.gz perlweeklychallenge-club-6ba8a9c79bb3368c25bf3c1aebd05bb888dd07b4.tar.bz2 perlweeklychallenge-club-6ba8a9c79bb3368c25bf3c1aebd05bb888dd07b4.zip | |
Merge pull request #400 from threadless-screw/threadless-screw-wk17ch2p6
Create ch-2.p6
| -rw-r--r-- | challenge-017/ozzy/perl6/ch-2.p6 | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-017/ozzy/perl6/ch-2.p6 b/challenge-017/ozzy/perl6/ch-2.p6 new file mode 100644 index 0000000000..47ea2a415b --- /dev/null +++ b/challenge-017/ozzy/perl6/ch-2.p6 @@ -0,0 +1,25 @@ +#!/usr/bin/env perl6 +# +# Destructuring a URI +# URI = scheme:[//authority]path[?query][#fragment] +# authority = [userinfo@]host[:port] + +grammar G { + + regex TOP { ^ <scheme> ':' ['//' <authority>]? <path> ['?' <query>]? ['#' <fragment>]? $ } + + token scheme { <+alpha-[_]> <[\w \+ \. \-]>+ } + + token authority { [<userinfo> '@']? <host> [':' <port>]? } + token userinfo { <user> [':' <password>]? } + token user { \w+ } + token password { \w* } + token host { <[\w\.\[\]]>+ } + token port { \d+ } + + token path { [ '/' \w+ ]+ } + token query { <[=\w]>+ } + token fragment { \w+ } +} + +say G.parse: 'jdbc://user:password@localhost:3306/pwc?profile=true#h1'; |
