74 lines
4.2 KiB
JavaScript
74 lines
4.2 KiB
JavaScript
|
// Generated automatically by nearley, version 2.20.1
|
||
|
// http://github.com/Hardmath123/nearley
|
||
|
(function () {
|
||
|
function id(x) { return x[0]; }
|
||
|
var grammar = {
|
||
|
Lexer: undefined,
|
||
|
ParserRules: [
|
||
|
{"name": "main$ebnf$1", "symbols": ["map"]},
|
||
|
{"name": "main$ebnf$1", "symbols": ["main$ebnf$1", "map"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "main", "symbols": ["seed", "eol", "main$ebnf$1"], "postprocess": d=> {
|
||
|
return {
|
||
|
seeds: d[0],
|
||
|
map: d[2]
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{"name": "seed$string$1", "symbols": [{"literal":"s"}, {"literal":"e"}, {"literal":"e"}, {"literal":"d"}, {"literal":"s"}], "postprocess": function joiner(d) {return d.join('');}},
|
||
|
{"name": "seed$ebnf$1$subexpression$1", "symbols": ["__", "int"]},
|
||
|
{"name": "seed$ebnf$1", "symbols": ["seed$ebnf$1$subexpression$1"]},
|
||
|
{"name": "seed$ebnf$1$subexpression$2", "symbols": ["__", "int"]},
|
||
|
{"name": "seed$ebnf$1", "symbols": ["seed$ebnf$1", "seed$ebnf$1$subexpression$2"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "seed", "symbols": ["seed$string$1", "_", {"literal":":"}, "seed$ebnf$1", "eol"], "postprocess": d=> {
|
||
|
return d[3].map(s => s[1]);
|
||
|
}
|
||
|
},
|
||
|
{"name": "map$ebnf$1", "symbols": [/[a-zA-Z]/]},
|
||
|
{"name": "map$ebnf$1", "symbols": ["map$ebnf$1", /[a-zA-Z]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "map$string$1", "symbols": [{"literal":"-"}, {"literal":"t"}, {"literal":"o"}, {"literal":"-"}], "postprocess": function joiner(d) {return d.join('');}},
|
||
|
{"name": "map$ebnf$2", "symbols": [/[a-zA-Z]/]},
|
||
|
{"name": "map$ebnf$2", "symbols": ["map$ebnf$2", /[a-zA-Z]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "map$string$2", "symbols": [{"literal":"m"}, {"literal":"a"}, {"literal":"p"}], "postprocess": function joiner(d) {return d.join('');}},
|
||
|
{"name": "map$ebnf$3", "symbols": ["eol"], "postprocess": id},
|
||
|
{"name": "map$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
|
||
|
{"name": "map", "symbols": ["map$ebnf$1", "map$string$1", "map$ebnf$2", "__", "map$string$2", "_", {"literal":":"}, "eol", "data", "map$ebnf$3"], "postprocess": d=> {
|
||
|
return {
|
||
|
from: d[0].join(""),
|
||
|
to: d[2].join(""),
|
||
|
data: d[8].toSorted((a,b)=> a.src - b.src)
|
||
|
}
|
||
|
} },
|
||
|
{"name": "data$ebnf$1", "symbols": ["dataRecord"]},
|
||
|
{"name": "data$ebnf$1", "symbols": ["data$ebnf$1", "dataRecord"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "data", "symbols": ["data$ebnf$1"], "postprocess": d=>
|
||
|
d[0]
|
||
|
},
|
||
|
{"name": "dataRecord", "symbols": ["int", "__", "int", "__", "int", "eol"], "postprocess":
|
||
|
(data)=> ({
|
||
|
dst: data[0],
|
||
|
src: data[2],
|
||
|
range: data[4]})
|
||
|
},
|
||
|
{"name": "eol", "symbols": [{"literal":"\n"}]},
|
||
|
{"name": "eol$string$1", "symbols": [{"literal":"\r"}, {"literal":"\n"}], "postprocess": function joiner(d) {return d.join('');}},
|
||
|
{"name": "eol", "symbols": ["eol$string$1"], "postprocess": d=> null},
|
||
|
{"name": "int$ebnf$1", "symbols": [/[0-9]/]},
|
||
|
{"name": "int$ebnf$1", "symbols": ["int$ebnf$1", /[0-9]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "int", "symbols": ["int$ebnf$1"], "postprocess": d=> parseInt(d[0].join(""))},
|
||
|
{"name": "_$ebnf$1", "symbols": []},
|
||
|
{"name": "_$ebnf$1", "symbols": ["_$ebnf$1", "wschar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "_", "symbols": ["_$ebnf$1"], "postprocess": d=> null},
|
||
|
{"name": "__$ebnf$1", "symbols": ["wschar"]},
|
||
|
{"name": "__$ebnf$1", "symbols": ["__$ebnf$1", "wschar"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
|
||
|
{"name": "__", "symbols": ["__$ebnf$1"], "postprocess": d=> null},
|
||
|
{"name": "wschar", "symbols": [/[ \t]/], "postprocess": id}
|
||
|
]
|
||
|
, ParserStart: "main"
|
||
|
}
|
||
|
if (typeof module !== 'undefined'&& typeof module.exports !== 'undefined') {
|
||
|
module.exports = grammar;
|
||
|
} else {
|
||
|
window.grammar = grammar;
|
||
|
}
|
||
|
})();
|