From 7386f0133e54d93b83a999b8d9888f38095a9ded Mon Sep 17 00:00:00 2001 From: Alexander <39702500+threadless-screw@users.noreply.github.com> Date: Sun, 21 Jul 2019 11:52:32 +0200 Subject: Create ch-2.p6 --- challenge-017/ozzy/perl6/ch-2.p6 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 challenge-017/ozzy/perl6/ch-2.p6 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 { ^ ':' ['//' ]? ['?' ]? ['#' ]? $ } + + token scheme { <+alpha-[_]> <[\w \+ \. \-]>+ } + + token authority { [ '@']? [':' ]? } + token userinfo { [':' ]? } + 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'; -- cgit