Fix ScriptVariables parsing

This commit is contained in:
barsdeveloper
2024-09-14 22:54:09 +02:00
parent 3f0185fca5
commit 5ea4d75a81
4 changed files with 43 additions and 47 deletions

44
dist/ueblueprint.js vendored
View File

@@ -4482,8 +4482,7 @@ class ArrayEntity extends IEntity {
if ((trailing !== undefined) !== Self.trailing) { if ((trailing !== undefined) !== Self.trailing) {
Self = Self.flagTrailing(trailing !== undefined); Self = Self.flagTrailing(trailing !== undefined);
} }
const result = new Self(values); return new Self(values)
return result
}).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`) }).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`)
} }
@@ -6239,7 +6238,7 @@ class ObjectEntity extends IEntity {
NodeGuid: GuidEntity, NodeGuid: GuidEntity,
ErrorType: IntegerEntity, ErrorType: IntegerEntity,
ErrorMsg: StringEntity, ErrorMsg: StringEntity,
ScriptVariables: ArrayEntity.of(ScriptVariableEntity), ScriptVariables: ArrayEntity.flagInlined().of(ScriptVariableEntity),
Node: MirroredEntity.of(ObjectReferenceEntity), Node: MirroredEntity.of(ObjectReferenceEntity),
ExportedNodes: StringEntity, ExportedNodes: StringEntity,
CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(), CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(),
@@ -6258,28 +6257,27 @@ class ObjectEntity extends IEntity {
Grammar.symbol.map(v => [v, false]), Grammar.symbol.map(v => [v, false]),
), ),
Parsernostrum.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) Parsernostrum.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number)
) ).chain(
.chain( /** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */
/** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */ ([[symbol, quoted], index]) =>
([[symbol, quoted], index]) => (this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue =>
(this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue => values => {
values => { if (values[symbol] === undefined) {
if (values[symbol] === undefined) { let arrayEntity = ArrayEntity;
let arrayEntity = ArrayEntity; if (quoted != arrayEntity.quoted) {
if (quoted != arrayEntity.quoted) { arrayEntity = arrayEntity.flagQuoted(quoted);
arrayEntity = arrayEntity.flagQuoted(quoted);
}
if (!arrayEntity.inlined) {
arrayEntity = arrayEntity.flagInlined();
}
values[symbol] = new arrayEntity();
} }
/** @type {ArrayEntity} */ if (!arrayEntity.inlined) {
const target = values[symbol]; arrayEntity = arrayEntity.flagInlined();
target.values[index] = currentValue; }
values[symbol] = new arrayEntity();
} }
) /** @type {ArrayEntity} */
) const target = values[symbol];
target.values[index] = currentValue;
}
)
)
static grammar = this.createGrammar() static grammar = this.createGrammar()
static grammarMultipleObjects = Parsernostrum.seq( static grammarMultipleObjects = Parsernostrum.seq(
Parsernostrum.whitespaceOpt, Parsernostrum.whitespaceOpt,

File diff suppressed because one or more lines are too long

View File

@@ -33,8 +33,7 @@ export default class ArrayEntity extends IEntity {
if ((trailing !== undefined) !== Self.trailing) { if ((trailing !== undefined) !== Self.trailing) {
Self = Self.flagTrailing(trailing !== undefined) Self = Self.flagTrailing(trailing !== undefined)
} }
const result = new Self(values) return new Self(values)
return result
}).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`) }).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`)
} }

View File

@@ -136,7 +136,7 @@ export default class ObjectEntity extends IEntity {
NodeGuid: GuidEntity, NodeGuid: GuidEntity,
ErrorType: IntegerEntity, ErrorType: IntegerEntity,
ErrorMsg: StringEntity, ErrorMsg: StringEntity,
ScriptVariables: ArrayEntity.of(ScriptVariableEntity), ScriptVariables: ArrayEntity.flagInlined().of(ScriptVariableEntity),
Node: MirroredEntity.of(ObjectReferenceEntity), Node: MirroredEntity.of(ObjectReferenceEntity),
ExportedNodes: StringEntity, ExportedNodes: StringEntity,
CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(), CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(),
@@ -155,28 +155,27 @@ export default class ObjectEntity extends IEntity {
Grammar.symbol.map(v => [v, false]), Grammar.symbol.map(v => [v, false]),
), ),
P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number)
) ).chain(
.chain( /** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */
/** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */ ([[symbol, quoted], index]) =>
([[symbol, quoted], index]) => (this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue =>
(this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue => values => {
values => { if (values[symbol] === undefined) {
if (values[symbol] === undefined) { let arrayEntity = ArrayEntity
let arrayEntity = ArrayEntity if (quoted != arrayEntity.quoted) {
if (quoted != arrayEntity.quoted) { arrayEntity = arrayEntity.flagQuoted(quoted)
arrayEntity = arrayEntity.flagQuoted(quoted)
}
if (!arrayEntity.inlined) {
arrayEntity = arrayEntity.flagInlined()
}
values[symbol] = new arrayEntity()
} }
/** @type {ArrayEntity} */ if (!arrayEntity.inlined) {
const target = values[symbol] arrayEntity = arrayEntity.flagInlined()
target.values[index] = currentValue }
values[symbol] = new arrayEntity()
} }
) /** @type {ArrayEntity} */
) const target = values[symbol]
target.values[index] = currentValue
}
)
)
static grammar = this.createGrammar() static grammar = this.createGrammar()
static grammarMultipleObjects = P.seq( static grammarMultipleObjects = P.seq(
P.whitespaceOpt, P.whitespaceOpt,