mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-17 19:03:27 +08:00
Fix empty array grammar
This commit is contained in:
5
dist/ueblueprint.js
vendored
5
dist/ueblueprint.js
vendored
@@ -3083,6 +3083,7 @@ class Grammar {
|
|||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* @param {AttributeInfo<T>} attribute
|
* @param {AttributeInfo<T>} attribute
|
||||||
|
* @returns {Parsernostrum<DescribedType<T>>}
|
||||||
*/
|
*/
|
||||||
static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) {
|
static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) {
|
||||||
let result = defaultGrammar;
|
let result = defaultGrammar;
|
||||||
@@ -3092,9 +3093,9 @@ class Grammar {
|
|||||||
}
|
}
|
||||||
result = Parsernostrum.seq(
|
result = Parsernostrum.seq(
|
||||||
Parsernostrum.reg(/\(\s*/),
|
Parsernostrum.reg(/\(\s*/),
|
||||||
this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation),
|
this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation).opt(),
|
||||||
Parsernostrum.reg(/\s*(?:,\s*)?\)/),
|
Parsernostrum.reg(/\s*(?:,\s*)?\)/),
|
||||||
).map(([_0, values, _3]) => values);
|
).map(([_0, values, _3]) => values instanceof Array ? values : []);
|
||||||
} else if (type instanceof Union) {
|
} else if (type instanceof Union) {
|
||||||
result = type.values
|
result = type.values
|
||||||
.map(v => this.grammarFor(undefined, v))
|
.map(v => this.grammarFor(undefined, v))
|
||||||
|
|||||||
2
dist/ueblueprint.min.js
vendored
2
dist/ueblueprint.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -69,6 +69,7 @@ export default class Grammar {
|
|||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* @param {AttributeInfo<T>} attribute
|
* @param {AttributeInfo<T>} attribute
|
||||||
|
* @returns {Parsernostrum<T>}
|
||||||
*/
|
*/
|
||||||
static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) {
|
static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) {
|
||||||
let result = defaultGrammar
|
let result = defaultGrammar
|
||||||
@@ -78,9 +79,9 @@ export default class Grammar {
|
|||||||
}
|
}
|
||||||
result = Parsernostrum.seq(
|
result = Parsernostrum.seq(
|
||||||
Parsernostrum.reg(/\(\s*/),
|
Parsernostrum.reg(/\(\s*/),
|
||||||
this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation),
|
this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation).opt(),
|
||||||
Parsernostrum.reg(/\s*(?:,\s*)?\)/),
|
Parsernostrum.reg(/\s*(?:,\s*)?\)/),
|
||||||
).map(([_0, values, _3]) => values)
|
).map(([_0, values, _3]) => values instanceof Array ? values : [])
|
||||||
} else if (type instanceof Union) {
|
} else if (type instanceof Union) {
|
||||||
result = type.values
|
result = type.values
|
||||||
.map(v => this.grammarFor(undefined, v))
|
.map(v => this.grammarFor(undefined, v))
|
||||||
@@ -89,6 +90,7 @@ export default class Grammar {
|
|||||||
: Parsernostrum.alt(acc, cur)
|
: Parsernostrum.alt(acc, cur)
|
||||||
)
|
)
|
||||||
} else if (type instanceof MirroredEntity) {
|
} else if (type instanceof MirroredEntity) {
|
||||||
|
// @ts-expect-error
|
||||||
return this.grammarFor(undefined, type.getTargetType())
|
return this.grammarFor(undefined, type.getTargetType())
|
||||||
.map(v => new MirroredEntity(type.type, () => v))
|
.map(v => new MirroredEntity(type.type, () => v))
|
||||||
} else if (attribute?.constructor === Object) {
|
} else if (attribute?.constructor === Object) {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import ObjectReferenceEntity from "../entity/ObjectReferenceEntity.js"
|
|||||||
import PathSymbolEntity from "../entity/PathSymbolEntity.js"
|
import PathSymbolEntity from "../entity/PathSymbolEntity.js"
|
||||||
import PinEntity from "../entity/PinEntity.js"
|
import PinEntity from "../entity/PinEntity.js"
|
||||||
import PinReferenceEntity from "../entity/PinReferenceEntity.js"
|
import PinReferenceEntity from "../entity/PinReferenceEntity.js"
|
||||||
|
import PinTypeEntity from "../entity/PinTypeEntity.js"
|
||||||
import RBSerializationVector2DEntity from "../entity/RBSerializationVector2DEntity.js"
|
import RBSerializationVector2DEntity from "../entity/RBSerializationVector2DEntity.js"
|
||||||
import RotatorEntity from "../entity/RotatorEntity.js"
|
import RotatorEntity from "../entity/RotatorEntity.js"
|
||||||
import SimpleSerializationRotatorEntity from "../entity/SimpleSerializationRotatorEntity.js"
|
import SimpleSerializationRotatorEntity from "../entity/SimpleSerializationRotatorEntity.js"
|
||||||
@@ -39,7 +40,6 @@ import ObjectSerializer from "./ObjectSerializer.js"
|
|||||||
import Serializer from "./Serializer.js"
|
import Serializer from "./Serializer.js"
|
||||||
import SerializerFactory from "./SerializerFactory.js"
|
import SerializerFactory from "./SerializerFactory.js"
|
||||||
import ToStringSerializer from "./ToStringSerializer.js"
|
import ToStringSerializer from "./ToStringSerializer.js"
|
||||||
import PinTypeEntity from "../entity/PinTypeEntity.js"
|
|
||||||
|
|
||||||
Grammar.unknownValue =
|
Grammar.unknownValue =
|
||||||
Parsernostrum.alt(
|
Parsernostrum.alt(
|
||||||
|
|||||||
Reference in New Issue
Block a user