37 lines
725 B
Plaintext
37 lines
725 B
Plaintext
main -> seed eol map:+ {% d=> {
|
|
return {
|
|
seeds: d[0],
|
|
map: d[2]
|
|
}
|
|
}
|
|
%}
|
|
seed -> "seeds" _ ":" (__ int):+ eol {% d=> {
|
|
return d[3].map(s => s[1]);
|
|
}
|
|
%}
|
|
|
|
map -> [a-zA-Z]:+ "-to-" [a-zA-Z]:+ __ "map" _ ":" eol data eol:? {% d=> {
|
|
return {
|
|
from: d[0].join(""),
|
|
to: d[2].join(""),
|
|
data: d[8].toSorted((a,b)=> a.src - b.src)
|
|
}
|
|
} %}
|
|
|
|
data -> dataRecord:+ {% d=>
|
|
d[0]
|
|
%}
|
|
|
|
dataRecord -> int __ int __ int eol {%
|
|
(data)=> ({
|
|
dst: data[0],
|
|
src: data[2],
|
|
range: data[4]})
|
|
%}
|
|
|
|
eol -> "\n" | "\r\n" {% d=> null %}
|
|
|
|
int -> [0-9]:+ {% d=> parseInt(d[0].join("")) %}
|
|
_ -> wschar:* {% d=> null %}
|
|
__ -> wschar:+ {% d=> null %}
|
|
wschar -> [ \t] {% id %} |