aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-017/ozzy/perl6/ch-2.p625
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';