mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 00:24:48 +08:00
33 lines
769 B
JavaScript
Executable File
33 lines
769 B
JavaScript
Executable File
import P from "parsernostrum"
|
|
import Utility from "../Utility.js"
|
|
import IPrintableEntity from "./IPrintableEntity.js"
|
|
|
|
export default class StringEntity extends IPrintableEntity {
|
|
|
|
static grammar = P.doubleQuotedString
|
|
.map(insideString => new this(Utility.unescapeString(insideString)))
|
|
.label("StringEntity")
|
|
|
|
/** @param {String} value */
|
|
constructor(value = "") {
|
|
super()
|
|
this.value = value
|
|
}
|
|
|
|
print() {
|
|
return this.value
|
|
}
|
|
|
|
valueOf() {
|
|
return this.value
|
|
}
|
|
|
|
toString(insideString = false) {
|
|
let result = Utility.escapeString(this.value)
|
|
if (!insideString) {
|
|
result = `"${result}"`
|
|
}
|
|
return result
|
|
}
|
|
}
|