Fix empty array grammar

This commit is contained in:
barsdeveloper
2024-03-25 23:57:11 +01:00
parent cc9e3d833a
commit 77a583e17f
4 changed files with 9 additions and 6 deletions

5
dist/ueblueprint.js vendored
View File

@@ -3083,6 +3083,7 @@ class Grammar {
/**
* @template T
* @param {AttributeInfo<T>} attribute
* @returns {Parsernostrum<DescribedType<T>>}
*/
static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) {
let result = defaultGrammar;
@@ -3092,9 +3093,9 @@ class Grammar {
}
result = Parsernostrum.seq(
Parsernostrum.reg(/\(\s*/),
this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation),
this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation).opt(),
Parsernostrum.reg(/\s*(?:,\s*)?\)/),
).map(([_0, values, _3]) => values);
).map(([_0, values, _3]) => values instanceof Array ? values : []);
} else if (type instanceof Union) {
result = type.values
.map(v => this.grammarFor(undefined, v))

File diff suppressed because one or more lines are too long