aboutsummaryrefslogtreecommitdiff
path: root/lib/URL/Grammar.pm6
blob: 2f5cd452d30f88f58c2ab392135ca587a84f4571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/env false

use v6.d;

unit grammar URL::Grammar;

token TOP {
	[ <scheme> ":" ]?
	"//"?
	[ <userinfo> "@" ]?
	<host>?
	<path>?
	[ "?" <query> ]?
	[ "#" <fragment> ]?
}

token scheme { <[ a..z ]> <[ a..z 0..9 . + - ]>* }
token userinfo { <username> [ ":" <password> ] }
token username { <-[ : @ ]>+ }
token password { <-[ @ ]>+ }
token host { <hostname> [ ":" <port> ]? }
token hostname { [ <-[ / : # ? \h ]>+ | "[" <-[ \] ]>+ "]" ] }
token port { \d ** 1..5 }
token path { "/" <part=.path-part>* % "/" }
token path-part { <-[ / ? # ]>+ }
token query { <part=.query-part>* % "&" }
token query-part { <key=.query-part-key> "=" <value=.query-part-value> }
token query-part-key { <-[ = # & ]>+ }
token query-part-value { <-[ # & ]>+ }
token fragment { <-[ \s ]>+ }

=begin pod

=NAME    URL::Grammar
=AUTHOR  Patrick Spek <p.spek@tyil.work>
=VERSION 0.2.0

=head1 Synopsis

=head1 Description

=head1 Examples

=head1 See also

=end pod

# vim: ft=perl6 noet