mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-24 16:04:44 +08:00
Better typing for grammars
This commit is contained in:
@@ -4,17 +4,19 @@ import PinEntity from "./PinEntity.js"
|
||||
|
||||
export default class UnknownPinEntity extends PinEntity {
|
||||
|
||||
static grammar = P.seq(
|
||||
P.reg(new RegExp(`(${Grammar.Regex.Symbol.source})\\s*\\(\\s*`), 1),
|
||||
Grammar.createAttributeGrammar(this).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("UnknownPinEntity")
|
||||
static grammar = /** @type {P<UnknownPinEntity>} */(
|
||||
P.seq(
|
||||
P.reg(new RegExp(`(${Grammar.Regex.Symbol.source})\\s*\\(\\s*`), 1),
|
||||
Grammar.createAttributeGrammar(this).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("UnknownPinEntity")
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user