mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
* Move grammar parsers to entity classes * Fix includes * Fix Entity5 test * Small detail * Fix unknown keys entities * Persistent grammar objects * Fix grammar * Grammar from variable
28 lines
758 B
JavaScript
28 lines
758 B
JavaScript
import Parsimmon from "parsimmon"
|
|
import RotatorEntity from "./RotatorEntity.js"
|
|
import Grammar from "../serialization/Grammar.js"
|
|
|
|
export default class SimpleSerializationRotatorEntity extends RotatorEntity {
|
|
|
|
static grammar = this.createGrammar()
|
|
|
|
static createGrammar() {
|
|
return Parsimmon.alt(
|
|
Parsimmon.seq(
|
|
Grammar.number,
|
|
Grammar.commaSeparation,
|
|
Grammar.number,
|
|
Grammar.commaSeparation,
|
|
Grammar.number,
|
|
).map(([p, _1, y, _3, r]) =>
|
|
new this({
|
|
R: r,
|
|
P: p,
|
|
Y: y,
|
|
})
|
|
),
|
|
RotatorEntity.createGrammar()
|
|
)
|
|
}
|
|
}
|