# Taken/Copied with relatively minor translation to Perl6 # from RFC 3986 (http://www.ietf.org/rfc/rfc3986.txt) # Rule names moved from snake case with _ to kebab case with - # 9/2015. The rfc grammar is specified in kebab case. use IETF::RFC_Grammar::IPv6; unit grammar IETF::RFC_Grammar::URI:ver<0.02> is IETF::RFC_Grammar::IPv6; token TOP { }; token TOP-non-empty { | }; token URI-reference { | }; token absolute-URI { ':' <.hier-part> [ '?' query ]? }; token relative-ref { [ '?' ]? [ '#' ]? }; token relative-part { | '//' | | | }; token relative-ref-non-empty { [ '?' ]? [ '#' ]? }; token relative-part-non-empty { | '//' | | }; token URI { ':' ['?' ]? [ '#' ]? }; token hier-part { | '//' | | | }; token scheme { <.uri-alpha> <[\-+.] +uri-alpha +digit>* }; token authority { [ '@' ]? [ ':' ]? }; token userinfo { [ ':' | ]* }; # the rfc refers to username:password as deprecated token likely-userinfo-component { <+unreserved +sub-delims>+ | <.pct-encoded>+ }; token host { | | }; token port { <.digit>* }; token IP-literal { '[' [ | ] ']' }; token IPvFuture { 'v' <.xdigit>+ '.' <[:] +unreserved +sub-delims>+ }; token reg-name { [ <+unreserved +sub-delims> | <.pct-encoded> ]* }; token path-abempty { [ '/' ]* }; token path-absolute { '/' [ [ '/' ]* ]? }; token path-noscheme { [ '/' ]* }; token path-rootless { [ '/' ]* }; token path-empty { <.pchar> ** 0 }; # yes - zero characters token segment { <.pchar>* }; token segment-nz { <.pchar>+ }; token segment-nz-nc { [ <+unenc-pchar - [:]> | <.pct-encoded> ] + }; token query { <.fragment> }; token fragment { [ <[/?] +unenc-pchar> | <.pct-encoded> ]* }; token pchar { <.unenc-pchar> | <.pct-encoded> }; token unenc-pchar { <[:@] +unreserved +sub-delims> }; token pct-encoded { '%' <.xdigit> <.xdigit> }; token unreserved { <[\-._~] +uri-alphanum> }; token reserved { <+gen-delims +sub-delims> }; token gen-delims { <[:/?\#\[\]@]> }; token sub-delims { <[;!$&'()*+,=]> }; token uri-alphanum { <+uri-alpha +:N +:S> }; token uri-alpha { };