mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-12 02:57:32 +08:00
Small refactoring
This commit is contained in:
@@ -10,28 +10,27 @@ export default class UnknownKeysEntity extends IEntity {
|
||||
IEntity.unknownEntity = this
|
||||
}
|
||||
|
||||
/** @returns {P<UnknownKeysEntity>} */
|
||||
static createGrammar() {
|
||||
return /** @type {P<UnknownKeysEntity>} */(
|
||||
P.seq(
|
||||
// Lookbehind
|
||||
P.reg(new RegExp(`(${Grammar.Regex.Path.source}|${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), 1),
|
||||
P.seq(Grammar.attributeName, Grammar.equalSeparation).map(([attribute, equal]) => attribute)
|
||||
.chain(attributeName =>
|
||||
this.unknownEntityGrammar.map(attributeValue =>
|
||||
values => values[attributeName] = attributeValue
|
||||
)
|
||||
return P.seq(
|
||||
// Lookbehind
|
||||
P.reg(new RegExp(`(${Grammar.Regex.Path.source}|${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), 1),
|
||||
P.seq(Grammar.attributeName, Grammar.equalSeparation).map(([attribute, equal]) => attribute)
|
||||
.chain(attributeName =>
|
||||
this.unknownEntityGrammar.map(attributeValue =>
|
||||
values => values[attributeName] = attributeValue
|
||||
)
|
||||
.sepBy(Grammar.commaSeparation),
|
||||
P.reg(/\s*(?:,\s*)?\)/),
|
||||
).map(([lookbehind, attributes, _2]) => {
|
||||
lookbehind ??= ""
|
||||
let values = {}
|
||||
if (lookbehind.length) {
|
||||
values.lookbehind = lookbehind
|
||||
}
|
||||
attributes.forEach(attributeSetter => attributeSetter(values))
|
||||
return new this(values)
|
||||
}).label("UnknownKeysEntity")
|
||||
)
|
||||
)
|
||||
.sepBy(Grammar.commaSeparation),
|
||||
P.reg(/\s*(?:,\s*)?\)/),
|
||||
).map(([lookbehind, attributes, _2]) => {
|
||||
lookbehind ??= ""
|
||||
let values = {}
|
||||
if (lookbehind.length) {
|
||||
values.lookbehind = lookbehind
|
||||
}
|
||||
attributes.forEach(attributeSetter => attributeSetter(values))
|
||||
return new this(values)
|
||||
}).label("UnknownKeysEntity")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user