|
@@ -135,9 +135,33 @@ class CodeBox {
|
|
|
this.maxBoxWidth = maxRowLength - 1;
|
|
|
this.maxBoxHeight = this.box.length - 1;
|
|
|
|
|
|
+ if (this.initialStackDOM.value != "") {
|
|
|
+ this.ParseInitialStack();
|
|
|
+ }
|
|
|
+
|
|
|
this.Run();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Parse the value provided for the stack at run time
|
|
|
+ */
|
|
|
+ ParseInitialStack() {
|
|
|
+ const separator = /(["'].+?["']|\d+)/g;
|
|
|
+ const stackValues = this.initialStackDOM.value.split(separator).filter((v) => v.trim().length);
|
|
|
+
|
|
|
+ for (const val of stackValues) {
|
|
|
+ const intVal = parseInt(val);
|
|
|
+ if (!Number.isNaN(intVal)) {
|
|
|
+ this.stacks[this.curr_stack].Push(intVal);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ let chars = val.substr(1, val.length - 2).split('');
|
|
|
+ chars = chars.map((c) => dec(c));
|
|
|
+ this.stacks[this.curr_stack].Push(chars);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Make all the rows in the code box the same length
|
|
|
*
|