-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathURI.lex
57 lines (35 loc) · 1.6 KB
/
URI.lex
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
49
50
51
52
53
54
55
56
alpha = [a-zA-Z];
digit = [0-9];
xdigit = [0-9a-fA-F];
pct_encoded = "%" xdigit xdigit;
gen_delims = ":" | "/" | "?" | "#" | "[" | "]" | "@";
sub_delims = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "=";
reserved = gen_delims | sub_delims;
unreserved = alpha | digit | "-" | "." | "_" | "~";
delims = "<" | ">" | "%" | "#" | '"';
unwise = " " | "{" | "}" | "|" | "\\" | "^" | "[" | "]" | "`";
pchar = unreserved | pct_encoded | sub_delims | ":" | "@" | delims | unwise;
slash = "/" | "\\";
path_char = pchar - ("?" | "#");
Path = slash ( path_char+ ( slash path_char* )* )? ;
drivePath = (slash|(alpha ":" slash)) ( path_char+ ( slash path_char* )* )? ;
Scheme = (alpha ( alpha | digit | "+" | "-" | "." )*) ':' ;
dec_octet = digit{1,3};
IPv4address = dec_octet "." dec_octet "." dec_octet "." dec_octet;
IPvFuture = "v" xdigit+ "." ( unreserved | sub_delims | ":" )+;
IPv6address = (":" | xdigit)+ IPv4address?;
IP_literal = "[" ( IPv6address | IPvFuture ) "]";
reg_name = ( unreserved | pct_encoded | sub_delims )+;
User = ( unreserved | pct_encoded | sub_delims | ":" | "@" )*;
Host = IP_literal | IPv4address | reg_name ;
Port = (pchar - ("/" | "?" | "#")){1,5} ;
authority = "//" ( ( User "@" )? Host ( ":" Port )? ) ;
Fragment = ( pchar | "/" | "?" )* ;
Query = (pchar - "#")* ;
full_ref = Path ( "?" Query )? ( "#" Fragment )?;
relative_ref = Path ( "?" Query )? ( "#" Fragment )?;
absolute_hier_part = authority? full_ref?;
hier_part = authority? relative_ref?;
absolute_URI = Scheme? absolute_hier_part;
URI = absolute_URI | relative_ref ;
Root = URI;