mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-13 03:37:31 +08:00
RBSerialization 2D Vector
This commit is contained in:
@@ -98,6 +98,7 @@ export default class Grammar {
|
||||
)
|
||||
static guid = P.regex(new RegExp(`${Grammar.Regex.HexDigit.source}{32}`))
|
||||
static commaSeparation = P.regex(/\s*,\s*(?!\))/)
|
||||
static commaOrSpaceSeparation = P.regex(/\s*,\s*(?!\))|\s+/)
|
||||
static equalSeparation = P.regex(/\s*=\s*/)
|
||||
static typeReference = P.alt(P.regex(Grammar.Regex.Path), this.symbol)
|
||||
static hexColorChannel = P.regex(new RegExp(Grammar.Regex.HexDigit.source + "{2}"))
|
||||
@@ -249,7 +250,7 @@ export default class Grammar {
|
||||
* @param {Boolean | Number} acceptUnknownKeys Number to specify the limit or true, to let it be a reasonable value
|
||||
* @returns {Parsimmon.Parser<T>}
|
||||
*/
|
||||
static createEntityGrammar = (entityType, acceptUnknownKeys = true) =>
|
||||
static createEntityGrammar = (entityType, acceptUnknownKeys = true, entriesSeparator = this.commaSeparation) =>
|
||||
P.seq(
|
||||
this.regexMap(
|
||||
entityType.lookbehind instanceof Union
|
||||
@@ -259,7 +260,7 @@ export default class Grammar {
|
||||
: /()\(\s*/,
|
||||
result => result[1]
|
||||
),
|
||||
this.createAttributeGrammar(entityType).sepBy1(this.commaSeparation),
|
||||
this.createAttributeGrammar(entityType).sepBy1(entriesSeparator),
|
||||
P.regex(/\s*(?:,\s*)?\)/), // trailing comma
|
||||
)
|
||||
.map(([lookbehind, attributes, _2]) => {
|
||||
|
||||
@@ -23,6 +23,7 @@ import Parsimmon from "parsimmon"
|
||||
import PathSymbolEntity from "../entity/PathSymbolEntity.js"
|
||||
import PinEntity from "../entity/PinEntity.js"
|
||||
import PinReferenceEntity from "../entity/PinReferenceEntity.js"
|
||||
import RBSerializationVector2DEntity from "../entity/RBSerializationVector2DEntity.js"
|
||||
import RotatorEntity from "../entity/RotatorEntity.js"
|
||||
import Serializer from "./Serializer.js"
|
||||
import SerializerFactory from "./SerializerFactory.js"
|
||||
@@ -241,6 +242,14 @@ export default function initializeSerializerFactory() {
|
||||
new Serializer(TerminalTypeEntity, Serializer.bracketsWrapped)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
RBSerializationVector2DEntity,
|
||||
new CustomSerializer(
|
||||
(value, insideString) => `X=${value.X} Y=${value.Y}`,
|
||||
RBSerializationVector2DEntity
|
||||
)
|
||||
)
|
||||
|
||||
SerializerFactory.registerSerializer(
|
||||
RotatorEntity,
|
||||
new Serializer(RotatorEntity, Serializer.bracketsWrapped)
|
||||
|
||||
Reference in New Issue
Block a user