mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-14 00:54:48 +08:00
Better typing for grammars
This commit is contained in:
@@ -6,25 +6,26 @@ import NumberEntity from "./NumberEntity.js"
|
||||
export default class SimpleSerializationRotatorEntity extends RotatorEntity {
|
||||
|
||||
static attributeSeparator = ", "
|
||||
/** @type {P<SimpleSerializationRotatorEntity>} */
|
||||
static grammar = P.alt(
|
||||
P.regArray(new RegExp(
|
||||
`(${NumberEntity.numberRegexSource})`
|
||||
+ String.raw`\s*,\s*`
|
||||
+ `(${NumberEntity.numberRegexSource})`
|
||||
+ String.raw`\s*,\s*`
|
||||
+ `(${NumberEntity.numberRegexSource})`
|
||||
)).map(([_, p, pPrecision, y, yPrecision, r, rPrecision]) => new this({
|
||||
R: new NumberEntity(r, rPrecision?.length),
|
||||
P: new NumberEntity(p, pPrecision?.length),
|
||||
Y: new NumberEntity(y, yPrecision?.length),
|
||||
})),
|
||||
RotatorEntity.grammar.map(v => new this({
|
||||
R: v.R,
|
||||
P: v.P,
|
||||
Y: v.Y,
|
||||
}))
|
||||
).label("SimpleSerializationRotatorEntity")
|
||||
static grammar = /** @type {P<SimpleSerializationRotatorEntity>} */(
|
||||
P.alt(
|
||||
P.regArray(new RegExp(
|
||||
`(${NumberEntity.numberRegexSource})`
|
||||
+ String.raw`\s*,\s*`
|
||||
+ `(${NumberEntity.numberRegexSource})`
|
||||
+ String.raw`\s*,\s*`
|
||||
+ `(${NumberEntity.numberRegexSource})`
|
||||
)).map(([_, p, pPrecision, y, yPrecision, r, rPrecision]) => new this({
|
||||
R: new NumberEntity(r, rPrecision?.length),
|
||||
P: new NumberEntity(p, pPrecision?.length),
|
||||
Y: new NumberEntity(y, yPrecision?.length),
|
||||
})),
|
||||
RotatorEntity.grammar.map(v => new this({
|
||||
R: v.R,
|
||||
P: v.P,
|
||||
Y: v.Y,
|
||||
}))
|
||||
).label("SimpleSerializationRotatorEntity")
|
||||
)
|
||||
|
||||
toString(
|
||||
insideString = false,
|
||||
|
||||
Reference in New Issue
Block a user