Skip to main content

module lang::uri::\syntax::RFC3986

rascal-0.40.16

Usage

import lang::uri::\syntax::RFC3986;

syntax Top

start syntax Top = URI;

syntax URI

lexical URI = Scheme scheme ":" HierPart ("?" Query)? ("#" Fragment)?;

syntax PctEncoded

lexical PctEncoded = "%" [A-Fa-f0-9] [A-Fa-f0-9];

syntax Reserved

lexical Reserved = GenDelims | SubDelims;

syntax GenDelims

lexical GenDelims = [:/?#\[\]@];

syntax SubDelims

lexical SubDelims = [!$&\'()*+,;=];

syntax Unreserved

lexical Unreserved = [A-Za-z0-9\-._~];

syntax HierPart

lexical HierPart 
= "//" Authority PathAbEmpty
| PathAbsolute
| PathRootless
| PathEmpty
;

syntax Scheme

lexical Scheme = [A-Za-z] [A-Za-z0-9+\-.]*;

syntax Authority

lexical Authority = (Userinfo "@")? Host (":" Port)?;

syntax Userinfo

lexical Userinfo = (Unreserved | PctEncoded | SubDelims | ":")*;

syntax Host

lexical Host = IPLiteral | IPv4Address | RegName;

syntax IPLiteral

lexical IPLiteral = "[" (IPv6addres | IPvFuture) "]";

syntax IPvFuture

lexical IPvFuture = "v" [A-Fa-f0-9]+ "." (Unreserved | SubDelims | ":")+;

syntax IPv6addres

lexical IPv6addres 
= H16 ":" H16 ":" H16 ":" H16 ":" H16 ":" H16 ":" LS32
| "::" H16 ":" H16 ":" H16 ":" H16 ":" H16 ":" LS32
| H16? "::" H16 ":" H16 ":" H16 ":" H16 ":" LS32
| (H16 ":" H16)? "::" H16 ":" H16 ":" H16 ":" LS32
| (H16 ":" H16 ":" H16)? "::" H16 ":" H16 ":" LS32
| (H16 ":" H16 ":" H16 ":" H16)? "::" H16 ":" LS32
| (H16 ":" H16 ":" H16 ":" H16 ":" H16)? "::" LS32
| (H16 ":" H16 ":" H16 ":" H16 ":" H16 ":" H16)? "::" H16
| (H16 ":" H16 ":" H16 ":" H16 ":" H16 ":" H16 ":" H16)? "::"
;

syntax LS32

lexical LS32 = H16 ":" H16 | IPv4Address;

syntax H16

lexical H16 = [A-Fa-f0-9] [A-Fa-f0-9] [A-Fa-f0-9] [A-Fa-f0-9] ;

syntax IPv4Address

lexical IPv4Address = DecOctet "." DecOctet "." DecOctet "." DecOctet;

syntax DecOctet

lexical DecOctet 
= [0-9]
| [1-9] [0-9]
| "1" [0-9] [0-9]
| "2" [0-4] [0-9]
| "25" [0-5]
;

syntax RegName

lexical RegName = (Unreserved | PctEncoded | SubDelims)*;

syntax Port

lexical Port = [0-9]*;

syntax Path

lexical Path 
= PathAbEmpty
| PathAbsolute
| PathNoScheme
| PathRootless
| PathEmpty
;

syntax PathAbEmpty

lexical PathAbEmpty = ("/" Segment)*;

syntax PathAbsolute

lexical PathAbsolute = "/" (SegmentNz ("/" Segment)*)? ;

syntax PathNoScheme

lexical PathNoScheme = SegmentNzNc ("/" Segment)*;

syntax PathRootless

lexical PathRootless = SegmentNz ("/" Segment)*;

syntax PathEmpty

lexical PathEmpty = ;

syntax Segment

lexical Segment = Pchar*;

syntax SegmentNz

lexical SegmentNz = Pchar+;

syntax SegmentNzNc

lexical SegmentNzNc = (Unreserved | PctEncoded | SubDelims | "@")+;

syntax Pchar

lexical Pchar = Unreserved | PctEncoded | SubDelims | ":" | "@";

syntax Query

lexical Query = (Pchar | "/" | "?")*;

syntax Fragment

lexical Fragment = (Pchar | "/" | "?")*;