168 lines
14 KiB
JavaScript
168 lines
14 KiB
JavaScript
![]() |
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
// Generated automatically by nearley, version 2.20.1
|
||
|
// http://github.com/Hardmath123/nearley
|
||
|
// Bypasses TS6133. Allow declared but unused functions.
|
||
|
// @ts-ignore
|
||
|
function id(d) { return d[0]; }
|
||
|
const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
|
||
|
function flat_string(d) {
|
||
|
if (d) {
|
||
|
if (Array.isArray(d))
|
||
|
return deepFlatten(d).join("");
|
||
|
return d;
|
||
|
}
|
||
|
return "";
|
||
|
}
|
||
|
;
|
||
|
;
|
||
|
;
|
||
|
;
|
||
|
const grammar = {
|
||
|
Lexer: undefined,
|
||
|
ParserRules: [
|
||
|
{ "name": "Reverse_path", "symbols": ["Path"] },
|
||
|
{ "name": "Reverse_path$string$1", "symbols": [{ "literal": "<" }, { "literal": ">" }], "postprocess": (d) => d.join('') },
|
||
|
{ "name": "Reverse_path", "symbols": ["Reverse_path$string$1"] },
|
||
|
{ "name": "Forward_path$subexpression$1$subexpression$1", "symbols": [{ "literal": "<" }, /[pP]/, /[oO]/, /[sS]/, /[tT]/, /[mM]/, /[aA]/, /[sS]/, /[tT]/, /[eE]/, /[rR]/, { "literal": "@" }], "postprocess": function (d) { return d.join(""); } },
|
||
|
{ "name": "Forward_path$subexpression$1", "symbols": ["Forward_path$subexpression$1$subexpression$1", "Domain", { "literal": ">" }] },
|
||
|
{ "name": "Forward_path", "symbols": ["Forward_path$subexpression$1"] },
|
||
|
{ "name": "Forward_path$subexpression$2", "symbols": [{ "literal": "<" }, /[pP]/, /[oO]/, /[sS]/, /[tT]/, /[mM]/, /[aA]/, /[sS]/, /[tT]/, /[eE]/, /[rR]/, { "literal": ">" }], "postprocess": function (d) { return d.join(""); } },
|
||
|
{ "name": "Forward_path", "symbols": ["Forward_path$subexpression$2"] },
|
||
|
{ "name": "Forward_path", "symbols": ["Path"] },
|
||
|
{ "name": "Path$ebnf$1$subexpression$1", "symbols": ["A_d_l", { "literal": ":" }] },
|
||
|
{ "name": "Path$ebnf$1", "symbols": ["Path$ebnf$1$subexpression$1"], "postprocess": id },
|
||
|
{ "name": "Path$ebnf$1", "symbols": [], "postprocess": () => null },
|
||
|
{ "name": "Path", "symbols": [{ "literal": "<" }, "Path$ebnf$1", "Mailbox", { "literal": ">" }] },
|
||
|
{ "name": "A_d_l$ebnf$1", "symbols": [] },
|
||
|
{ "name": "A_d_l$ebnf$1$subexpression$1", "symbols": [{ "literal": "," }, "At_domain"] },
|
||
|
{ "name": "A_d_l$ebnf$1", "symbols": ["A_d_l$ebnf$1", "A_d_l$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "A_d_l", "symbols": ["At_domain", "A_d_l$ebnf$1"] },
|
||
|
{ "name": "At_domain", "symbols": [{ "literal": "@" }, "Domain"] },
|
||
|
{ "name": "Domain$ebnf$1", "symbols": [] },
|
||
|
{ "name": "Domain$ebnf$1$subexpression$1", "symbols": [{ "literal": "." }, "sub_domain"] },
|
||
|
{ "name": "Domain$ebnf$1", "symbols": ["Domain$ebnf$1", "Domain$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "Domain", "symbols": ["sub_domain", "Domain$ebnf$1"] },
|
||
|
{ "name": "sub_domain", "symbols": ["U_label"] },
|
||
|
{ "name": "Let_dig", "symbols": ["ALPHA_DIGIT"], "postprocess": id },
|
||
|
{ "name": "Ldh_str$ebnf$1", "symbols": [] },
|
||
|
{ "name": "Ldh_str$ebnf$1", "symbols": ["Ldh_str$ebnf$1", "ALPHA_DIG_DASH"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "Ldh_str", "symbols": ["Ldh_str$ebnf$1", "Let_dig"] },
|
||
|
{ "name": "U_Let_dig", "symbols": ["ALPHA_DIGIT_U"], "postprocess": id },
|
||
|
{ "name": "U_Ldh_str$ebnf$1", "symbols": [] },
|
||
|
{ "name": "U_Ldh_str$ebnf$1", "symbols": ["U_Ldh_str$ebnf$1", "ALPHA_DIG_DASH_U"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "U_Ldh_str", "symbols": ["U_Ldh_str$ebnf$1", "U_Let_dig"] },
|
||
|
{ "name": "U_label$ebnf$1$subexpression$1", "symbols": ["U_Ldh_str"] },
|
||
|
{ "name": "U_label$ebnf$1", "symbols": ["U_label$ebnf$1$subexpression$1"], "postprocess": id },
|
||
|
{ "name": "U_label$ebnf$1", "symbols": [], "postprocess": () => null },
|
||
|
{ "name": "U_label", "symbols": ["U_Let_dig", "U_label$ebnf$1"] },
|
||
|
{ "name": "address_literal$subexpression$1", "symbols": ["IPv4_address_literal"] },
|
||
|
{ "name": "address_literal$subexpression$1", "symbols": ["IPv6_address_literal"] },
|
||
|
{ "name": "address_literal$subexpression$1", "symbols": ["General_address_literal"] },
|
||
|
{ "name": "address_literal", "symbols": [{ "literal": "[" }, "address_literal$subexpression$1", { "literal": "]" }] },
|
||
|
{ "name": "non_local_part", "symbols": ["Domain"], "postprocess": function (d) {
|
||
|
return { DomainName: flat_string(d[0]) };
|
||
|
}
|
||
|
},
|
||
|
{ "name": "non_local_part", "symbols": ["address_literal"], "postprocess": function (d) {
|
||
|
return { AddressLiteral: flat_string(d[0]) };
|
||
|
}
|
||
|
},
|
||
|
{ "name": "Mailbox", "symbols": ["Local_part", { "literal": "@" }, "non_local_part"], "postprocess": function (d) {
|
||
|
return { localPart: flat_string(d[0]), domainPart: flat_string(d[2]) };
|
||
|
}
|
||
|
},
|
||
|
{ "name": "Local_part", "symbols": ["Dot_string"], "postprocess": function (d) {
|
||
|
return { DotString: flat_string(d[0]) };
|
||
|
}
|
||
|
},
|
||
|
{ "name": "Local_part", "symbols": ["Quoted_string"], "postprocess": function (d) {
|
||
|
return { QuotedString: flat_string(d[0]) };
|
||
|
}
|
||
|
},
|
||
|
{ "name": "Dot_string$ebnf$1", "symbols": [] },
|
||
|
{ "name": "Dot_string$ebnf$1$subexpression$1", "symbols": [{ "literal": "." }, "Atom"] },
|
||
|
{ "name": "Dot_string$ebnf$1", "symbols": ["Dot_string$ebnf$1", "Dot_string$ebnf$1$subexpression$1"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "Dot_string", "symbols": ["Atom", "Dot_string$ebnf$1"] },
|
||
|
{ "name": "Atom$ebnf$1", "symbols": [/[0-9A-Za-z!#$%&'*+\-/=?^_`{|}~\u0080-\uFFFF/]/] },
|
||
|
{ "name": "Atom$ebnf$1", "symbols": ["Atom$ebnf$1", /[0-9A-Za-z!#$%&'*+\-/=?^_`{|}~\u0080-\uFFFF/]/], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "Atom", "symbols": ["Atom$ebnf$1"] },
|
||
|
{ "name": "Quoted_string$ebnf$1", "symbols": [] },
|
||
|
{ "name": "Quoted_string$ebnf$1", "symbols": ["Quoted_string$ebnf$1", "QcontentSMTP"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "Quoted_string", "symbols": ["DQUOTE", "Quoted_string$ebnf$1", "DQUOTE"] },
|
||
|
{ "name": "QcontentSMTP", "symbols": ["qtextSMTP"] },
|
||
|
{ "name": "QcontentSMTP", "symbols": ["quoted_pairSMTP"] },
|
||
|
{ "name": "quoted_pairSMTP", "symbols": [{ "literal": "\\" }, /[\x20-\x7e]/] },
|
||
|
{ "name": "qtextSMTP", "symbols": [/[\x20-\x21\x23-\x5b\x5d-\x7e\u0080-\uFFFF]/], "postprocess": id },
|
||
|
{ "name": "IPv4_address_literal$macrocall$2", "symbols": [{ "literal": "." }, "Snum"] },
|
||
|
{ "name": "IPv4_address_literal$macrocall$1", "symbols": ["IPv4_address_literal$macrocall$2", "IPv4_address_literal$macrocall$2", "IPv4_address_literal$macrocall$2"] },
|
||
|
{ "name": "IPv4_address_literal", "symbols": ["Snum", "IPv4_address_literal$macrocall$1"] },
|
||
|
{ "name": "IPv6_address_literal$subexpression$1", "symbols": [/[iI]/, /[pP]/, /[vV]/, { "literal": "6" }, { "literal": ":" }], "postprocess": function (d) { return d.join(""); } },
|
||
|
{ "name": "IPv6_address_literal", "symbols": ["IPv6_address_literal$subexpression$1", "IPv6_addr"] },
|
||
|
{ "name": "General_address_literal$ebnf$1", "symbols": ["dcontent"] },
|
||
|
{ "name": "General_address_literal$ebnf$1", "symbols": ["General_address_literal$ebnf$1", "dcontent"], "postprocess": (d) => d[0].concat([d[1]]) },
|
||
|
{ "name": "General_address_literal", "symbols": ["Standardized_tag", { "literal": ":" }, "General_address_literal$ebnf$1"] },
|
||
|
{ "name": "Standardized_tag", "symbols": ["Ldh_str"] },
|
||
|
{ "name": "dcontent", "symbols": [/[\x21-\x5a\x5e-\x7e]/], "postprocess": id },
|
||
|
{ "name": "Snum", "symbols": ["DIGIT"] },
|
||
|
{ "name": "Snum$subexpression$1", "symbols": [/[1-9]/, "DIGIT"] },
|
||
|
{ "name": "Snum", "symbols": ["Snum$subexpression$1"] },
|
||
|
{ "name": "Snum$subexpression$2", "symbols": [{ "literal": "1" }, "DIGIT", "DIGIT"] },
|
||
|
{ "name": "Snum", "symbols": ["Snum$subexpression$2"] },
|
||
|
{ "name": "Snum$subexpression$3", "symbols": [{ "literal": "2" }, /[0-4]/, "DIGIT"] },
|
||
|
{ "name": "Snum", "symbols": ["Snum$subexpression$3"] },
|
||
|
{ "name": "Snum$subexpression$4", "symbols": [{ "literal": "2" }, { "literal": "5" }, /[0-5]/] },
|
||
|
{ "name": "Snum", "symbols": ["Snum$subexpression$4"] },
|
||
|
{ "name": "IPv6_addr", "symbols": ["IPv6_full"] },
|
||
|
{ "name": "IPv6_addr", "symbols": ["IPv6_comp"] },
|
||
|
{ "name": "IPv6_addr", "symbols": ["IPv6v4_full"] },
|
||
|
{ "name": "IPv6_addr", "symbols": ["IPv6v4_comp"] },
|
||
|
{ "name": "IPv6_hex", "symbols": ["HEXDIG"] },
|
||
|
{ "name": "IPv6_hex$subexpression$1", "symbols": ["HEXDIG", "HEXDIG"] },
|
||
|
{ "name": "IPv6_hex", "symbols": ["IPv6_hex$subexpression$1"] },
|
||
|
{ "name": "IPv6_hex$subexpression$2", "symbols": ["HEXDIG", "HEXDIG", "HEXDIG"] },
|
||
|
{ "name": "IPv6_hex", "symbols": ["IPv6_hex$subexpression$2"] },
|
||
|
{ "name": "IPv6_hex$subexpression$3", "symbols": ["HEXDIG", "HEXDIG", "HEXDIG", "HEXDIG"] },
|
||
|
{ "name": "IPv6_hex", "symbols": ["IPv6_hex$subexpression$3"] },
|
||
|
{ "name": "IPv6_full$macrocall$2", "symbols": [{ "literal": ":" }, "IPv6_hex"] },
|
||
|
{ "name": "IPv6_full$macrocall$1", "symbols": ["IPv6_full$macrocall$2", "IPv6_full$macrocall$2", "IPv6_full$macrocall$2", "IPv6_full$macrocall$2", "IPv6_full$macrocall$2", "IPv6_full$macrocall$2", "IPv6_full$macrocall$2"] },
|
||
|
{ "name": "IPv6_full", "symbols": ["IPv6_hex", "IPv6_full$macrocall$1"] },
|
||
|
{ "name": "IPv6_comp$ebnf$1$subexpression$1$macrocall$2", "symbols": [{ "literal": ":" }, "IPv6_hex"] },
|
||
|
{ "name": "IPv6_comp$ebnf$1$subexpression$1$macrocall$1", "symbols": ["IPv6_comp$ebnf$1$subexpression$1$macrocall$2", "IPv6_comp$ebnf$1$subexpression$1$macrocall$2", "IPv6_comp$ebnf$1$subexpression$1$macrocall$2", "IPv6_comp$ebnf$1$subexpression$1$macrocall$2", "IPv6_comp$ebnf$1$subexpression$1$macrocall$2"] },
|
||
|
{ "name": "IPv6_comp$ebnf$1$subexpression$1", "symbols": ["IPv6_hex", "IPv6_comp$ebnf$1$subexpression$1$macrocall$1"] },
|
||
|
{ "name": "IPv6_comp$ebnf$1", "symbols": ["IPv6_comp$ebnf$1$subexpression$1"], "postprocess": id },
|
||
|
{ "name": "IPv6_comp$ebnf$1", "symbols": [], "postprocess": () => null },
|
||
|
{ "name": "IPv6_comp$string$1", "symbols": [{ "literal": ":" }, { "literal": ":" }], "postprocess": (d) => d.join('') },
|
||
|
{ "name": "IPv6_comp$ebnf$2$subexpression$1$macrocall$2", "symbols": [{ "literal": ":" }, "IPv6_hex"] },
|
||
|
{ "name": "IPv6_comp$ebnf$2$subexpression$1$macrocall$1", "symbols": ["IPv6_comp$ebnf$2$subexpression$1$macrocall$2", "IPv6_comp$ebnf$2$subexpression$1$macrocall$2", "IPv6_comp$ebnf$2$subexpression$1$macrocall$2", "IPv6_comp$ebnf$2$subexpression$1$macrocall$2", "IPv6_comp$ebnf$2$subexpression$1$macrocall$2"] },
|
||
|
{ "name": "IPv6_comp$ebnf$2$subexpression$1", "symbols": ["IPv6_hex", "IPv6_comp$ebnf$2$subexpression$1$macrocall$1"] },
|
||
|
{ "name": "IPv6_comp$ebnf$2", "symbols": ["IPv6_comp$ebnf$2$subexpression$1"], "postprocess": id },
|
||
|
{ "name": "IPv6_comp$ebnf$2", "symbols": [], "postprocess": () => null },
|
||
|
{ "name": "IPv6_comp", "symbols": ["IPv6_comp$ebnf$1", "IPv6_comp$string$1", "IPv6_comp$ebnf$2"] },
|
||
|
{ "name": "IPv6v4_full$macrocall$2", "symbols": [{ "literal": ":" }, "IPv6_hex"] },
|
||
|
{ "name": "IPv6v4_full$macrocall$1", "symbols": ["IPv6v4_full$macrocall$2", "IPv6v4_full$macrocall$2", "IPv6v4_full$macrocall$2", "IPv6v4_full$macrocall$2", "IPv6v4_full$macrocall$2"] },
|
||
|
{ "name": "IPv6v4_full", "symbols": ["IPv6_hex", "IPv6v4_full$macrocall$1", { "literal": ":" }, "IPv4_address_literal"] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$1$subexpression$1$macrocall$2", "symbols": [{ "literal": ":" }, "IPv6_hex"] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$1$subexpression$1$macrocall$1", "symbols": ["IPv6v4_comp$ebnf$1$subexpression$1$macrocall$2", "IPv6v4_comp$ebnf$1$subexpression$1$macrocall$2", "IPv6v4_comp$ebnf$1$subexpression$1$macrocall$2"] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$1$subexpression$1", "symbols": ["IPv6_hex", "IPv6v4_comp$ebnf$1$subexpression$1$macrocall$1"] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$1", "symbols": ["IPv6v4_comp$ebnf$1$subexpression$1"], "postprocess": id },
|
||
|
{ "name": "IPv6v4_comp$ebnf$1", "symbols": [], "postprocess": () => null },
|
||
|
{ "name": "IPv6v4_comp$string$1", "symbols": [{ "literal": ":" }, { "literal": ":" }], "postprocess": (d) => d.join('') },
|
||
|
{ "name": "IPv6v4_comp$ebnf$2$subexpression$1$macrocall$2", "symbols": [{ "literal": ":" }, "IPv6_hex"] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$2$subexpression$1$macrocall$1", "symbols": ["IPv6v4_comp$ebnf$2$subexpression$1$macrocall$2", "IPv6v4_comp$ebnf$2$subexpression$1$macrocall$2", "IPv6v4_comp$ebnf$2$subexpression$1$macrocall$2"] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$2$subexpression$1", "symbols": ["IPv6_hex", "IPv6v4_comp$ebnf$2$subexpression$1$macrocall$1", { "literal": ":" }] },
|
||
|
{ "name": "IPv6v4_comp$ebnf$2", "symbols": ["IPv6v4_comp$ebnf$2$subexpression$1"], "postprocess": id },
|
||
|
{ "name": "IPv6v4_comp$ebnf$2", "symbols": [], "postprocess": () => null },
|
||
|
{ "name": "IPv6v4_comp", "symbols": ["IPv6v4_comp$ebnf$1", "IPv6v4_comp$string$1", "IPv6v4_comp$ebnf$2", "IPv4_address_literal"] },
|
||
|
{ "name": "DIGIT", "symbols": [/[0-9]/], "postprocess": id },
|
||
|
{ "name": "ALPHA_DIGIT_U", "symbols": [/[0-9A-Za-z\u0080-\uFFFF]/], "postprocess": id },
|
||
|
{ "name": "ALPHA_DIGIT", "symbols": [/[0-9A-Za-z]/], "postprocess": id },
|
||
|
{ "name": "ALPHA_DIG_DASH", "symbols": [/[-0-9A-Za-z]/], "postprocess": id },
|
||
|
{ "name": "ALPHA_DIG_DASH_U", "symbols": [/[-0-9A-Za-z\u0080-\uFFFF]/], "postprocess": id },
|
||
|
{ "name": "HEXDIG", "symbols": [/[0-9A-Fa-f]/], "postprocess": id },
|
||
|
{ "name": "DQUOTE", "symbols": [{ "literal": "\"" }], "postprocess": id }
|
||
|
],
|
||
|
ParserStart: "Reverse_path",
|
||
|
};
|
||
|
exports.default = grammar;
|
||
|
//# sourceMappingURL=grammar.js.map
|