Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ encoding//src/org/rascalmpl/library/experiments/vis2/lib/MarkdownConverter.js=UT
encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.css=UTF-8
encoding//src/org/rascalmpl/library/experiments/vis2/lib/nv.d3.js=UTF-8
encoding//src/org/rascalmpl/library/experiments/vis2/lib/reset.css=UTF-8
encoding//src/org/rascalmpl/library/lang/rascal/tests/functionality/DataType.rsc=UTF-8
encoding//test/org/rascalmpl/test/data=UTF-8
encoding/<project>=UTF-8
encoding/src=UTF-8
Expand Down
53 changes: 53 additions & 0 deletions src/org/rascalmpl/library/lang/paths/MailAddress.rsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@synopsis{This encodes the mail address part of RFC822}
@pitfalls{
This was taken over literally from RFC822 but not tested.
}
module lang::paths::MailAddress

lexical Address
= adressee: Mailbox
| namedList: Group
;

lexical Group = Phrase ":" {Mailbox ","}+ ";";

lexical Mailbox
= simpleAddress: AddrSpec
| nameAndAddrSpec: Phrase RouteAddr
;

lexical RouteAddr = "\<" Route? AddrSpec "\>";

lexical Route = {Domain "@"}+ ":"; // hard to interpret original: 1#("@" domain) ":"

lexical AddrSpec = globalAddress: LocalPart "@" Domain;

lexical LocalPart = uninterpretedCasePreserved: {Word "."}+ ;

lexical Domain = {SubDomain "."}+;

lexical SubDomain = DomainRef | DomainLiteral;

lexical DomainLiteral = "[" (Dtext | QuotedPair)* "]";

lexical Dtext = (![\\\]\[\n\r\ ] + [\ ])+;

lexical DomainRef = Atom;

lexical Phrase = Word+;

lexical Atom = ![] - [()\<\>@,;:|\".\[\]] - [\a00-a20] - [\ ];

lexical Specials = [()\<\>@,;:|\".\[\]];

lexical Controls = [\a00-\a20];

lexical Word = Atom | QuotedString;

lexical QuotedString = "\"" (Qtext | QuotedPair)* "\"";

lexical Qtext = (![\\\"\n\r] + [\ ])+;

lexical QuotedPair = "\\" CHAR;

lexical CHAR = [\a00-\a7F]; // All of ASCII
119 changes: 119 additions & 0 deletions src/org/rascalmpl/library/lang/paths/URL.rsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
@synopsis{Implements RFC1738 for URL syntax and maps them to `loc` values.}
@pitfalls{
This was taken over literall from RFC1738 but not tested.
}
module lang::paths::URL

extend lang::paths::MailAddress;
lexical URL
= http: "http://" HostPort ( "/" Hpath ( "?" Search)?)?
| ftp: "ftp://" Login ("/" Fpath (";type=" FtpType)?)?
| news: "news:" GroupPart
| nntp: "nntp://" HostPort "/" Group ("/" Digit+)?
| telnet: "telnet://" Login "/"?
| gopher: "gopher://" HostPort ( "/" ( Gtype ( Selector ("%09" Search ("%09" GopherPlusString)? )? )? )? )?
| waisdatabase: "wais://" HostPort "/" Database
| waisindex: "wais://" HostPort "/" Database "?" Search
| waisdoc: "wais://" HostPort "/" Database "/" Wtype "/" Wpath
| mailto: "mailto:" Encoded822addr
| file: "file://" (Host | "localhost")? "/" Fpath
| prospero: "prospero://" HostPort "/" Ppath *[ Fieldspec ]
| other: Scheme ":" SchemePart
;

lexical Ppath = {Psegment "/"}+;

lexical Psegment = (Uchar | [?:@&=])*;

lexical Fieldspec = ";" FieldName "=" FieldValue;

lexical FieldName = (Uchar | [?:@&])*;

lexical FieldValue = (Uchar | [?:@&])*;

lexical Database = Uchar*;
lexical Wtype = Uchar*;
lexical Wpath = Uchar*;

lexical GroupPart = "*" | Group | Article;

lexical Group = Alpha (Alpha | Digit | [\-.+_])*;

lexical Article = (Uchar | [;/?:&=])* "@" Host;

lexical Encoded822addr = Xchar+; // further defined in RFC822

lexical Gtype = Xchar;
lexical Selector = Xchar*;
lexical GopherPlusString = Xchar*;

lexical Hpath = {Hsegment "/"}+;

lexical Hsegment = (Uchar | [;:@&=])*;

lexical Search = (Uchar | [;:@&=])*;

lexical Fpath = {Fsegment "/"}+;

lexical Fsegment= (Uchar | [?:@&=])*;

lexical FtpType = [AIDaid];

lexical Scheme = [a-z0-9+\-.]+;

lexical SchemePart = Xchar* | IpSchemePart;

lexical IpSchemePart = "//" Login ("/" UrlPath);

lexical Login = ( User ( ":" Password )? "@" )? HostPort;

lexical HostPort = Host ( ":" Port )?;

lexical Host = HostName | HostNumber;

lexical HostName = (DomainLabel ".")* TopLabel;

lexical DomainLabel = {AlphaDigit "-"}+;

lexical TopLabel = Alpha {AlphaDigit "-"}+;

lexical HostNumber = Digit+ "." Digit+ "." Digit+ "." Digit+;

lexical Port = Digit+;

lexical User = (Uchar | [;?&=])*;

lexical Password = (Uchar | [;?&=])*;

lexical UrlPath = Xchar* ; //depends on protocol see section 3.1 of RFC1738

lexical Alpha = LowAlpha | HighAlpha;

lexical AlphaDigit = Alpha | Digit;

lexical LowAlpha = [a-z];

lexical HighAlpha = [A-Z];

lexical Digit = [0-9];

lexical Safe = [$ \- _ . +];

lexical Extra = [!*\'(),];

lexical National = [{}|\\^~\[\]`];

lexical Punctuation = [\<\>#%\"];

lexical Reserved = [;/?:@&=];

lexical Hex = Digit | [A-Fa-f];

lexical Escape = "%" Hex Hex;

lexical Unreserved = Alpha | Digit | Safe | Extra;

lexical Uchar = Unreserved | Escape;

lexical Xchar = Unreserved | Reserved | Escape;

Loading