Grammar refactoring WIP

This commit is contained in:
barsdeveloper
2021-10-22 00:01:24 +02:00
parent 9caea42101
commit 051eed061d
21 changed files with 968 additions and 354 deletions

View File

@@ -2,8 +2,31 @@ import Serializer from "./Serializer";
export default class ObjectSerializer extends Serializer {
showProperty(attributeKey, attributeValue) {
switch (attributeKey.toString()) {
case "Class":
case "Name":
// Serielized separately
return false
}
return super.showProperty(attributeKey, attributeValue)
}
read(value) {
const parseResult = Serializer.grammar.Object.parse(value)
if (!parseResult.status) {
console.error("Error when trying to parse the object.")
return parseResult
}
return parseResult.value
}
write(object) {
let result = `Pin (${this.constructor.subWrite('', this)})`
let result = `
Begin Object Class=${object.Class} Name=${object.Name}
${this.subWrite([], object, "\n", " ")}
End Object
`
return result
}
}