mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-10 13:24:40 +08:00
37 lines
910 B
JavaScript
Executable File
37 lines
910 B
JavaScript
Executable File
import P from "parsernostrum"
|
|
import Utility from "../Utility.js"
|
|
import IEntity from "./IEntity.js"
|
|
|
|
export default class StringEntity extends IEntity {
|
|
|
|
static grammar = /** @type {P<StringEntity>} */(
|
|
P.doubleQuotedString
|
|
.map(insideString => new this(Utility.unescapeString(insideString)))
|
|
.label("StringEntity")
|
|
)
|
|
|
|
/** @param {String} value */
|
|
constructor(value = "") {
|
|
super()
|
|
this.value = value
|
|
}
|
|
|
|
valueOf() {
|
|
return this.value
|
|
}
|
|
|
|
toString(
|
|
insideString = false,
|
|
indentation = "",
|
|
Self = this.Self(),
|
|
printKey = Self.printKey,
|
|
wrap = Self.wrap,
|
|
) {
|
|
let result = `"${Utility.escapeString(this.value)}"`
|
|
if (insideString) {
|
|
result = Utility.escapeString(result, false)
|
|
}
|
|
return result
|
|
}
|
|
}
|