Split grammar (#15)

* Move grammar parsers to entity classes

* Fix includes

* Fix Entity5 test

* Small detail

* Fix unknown keys entities

* Persistent grammar objects

* Fix grammar

* Grammar from variable
This commit is contained in:
barsdeveloper
2023-09-18 21:13:28 +02:00
committed by GitHub
parent 872bdb7128
commit 78c62ee59a
48 changed files with 1807 additions and 1845 deletions

View File

@@ -3,7 +3,6 @@ import Configuration from "../Configuration.js"
import ElementFactory from "./ElementFactory.js"
import EnumPinTemplate from "../template/pin/EnumPinTemplate.js"
import ExecPinTemplate from "../template/pin/ExecPinTemplate.js"
import Grammar from "../serialization/Grammar.js"
import GuidEntity from "../entity/GuidEntity.js"
import IElement from "./IElement.js"
import Int64PinTemplate from "../template/pin/Int64PinTemplate.js"
@@ -61,7 +60,7 @@ export default class PinElement extends IElement {
type: GuidEntity,
converter: {
fromAttribute: (value, type) => value
? /** @type {Success<GuidEntity>} */(Grammar.guidEntity.parse(value)).value
? /** @type {Success<GuidEntity>} */(GuidEntity.grammar.parse(value)).value
: null,
toAttribute: (value, type) => value?.toString(),
},
@@ -82,7 +81,7 @@ export default class PinElement extends IElement {
type: LinearColorEntity,
converter: {
fromAttribute: (value, type) => value
? /** @type {Success<LinearColorEntity>} */(Grammar.linearColorFromAnyFormat.parse(value)).value
? /** @type {Success<LinearColorEntity>} */(LinearColorEntity.getLinearColorFromAnyFormat().parse(value)).value
: null,
toAttribute: (value, type) => value ? Utility.printLinearColor(value) : null,
},