Deduce quoted object reference

This commit is contained in:
barsdeveloper
2024-09-09 15:16:48 +02:00
parent 4601c9dc48
commit 4885a988f9
6 changed files with 41 additions and 17 deletions

View File

@@ -10,6 +10,7 @@ export default class NullEntity extends IEntity {
// @ts-expect-error
return P.reg(new RegExp(String.raw`\(${P.whitespaceInlineOpt.getParser().regexp.source}\)`))
.map(v => new this())
.label("NullEntity")
}
serialize(

View File

@@ -19,6 +19,7 @@ import UnknownKeysEntity from "../entity/UnknownKeysEntity.js"
import Vector2DEntity from "../entity/Vector2DEntity.js"
import Vector4DEntity from "../entity/Vector4DEntity.js"
import VectorEntity from "../entity/VectorEntity.js"
import Grammar from "./Grammar.js"
export default function initializeSerializerFactory() {
IEntity.unknownEntityGrammar =
@@ -29,7 +30,13 @@ export default function initializeSerializerFactory() {
Parsernostrum.str("None").map(() => ObjectReferenceEntity.createNoneInstance()),
NullEntity.grammar,
NumberEntity.grammar,
ObjectReferenceEntity.fullReferenceGrammar,
Parsernostrum.alt(
ObjectReferenceEntity.fullReferenceGrammar,
Parsernostrum.regArray(
// @ts-expect-error
new RegExp(`"(${Grammar.Regex.Path.source})'(${Grammar.symbol.getParser().regexp.source})'"`)
).map(([full, type, path]) => new ObjectReferenceEntity(type, path, full))
),
StringEntity.grammar,
LocalizedTextEntity.grammar,
InvariantTextEntity.grammar,