| } | } | ||||
| class Parser{ | class Parser{ | ||||
| constructor(pof){ | constructor(pof){ | ||||
| if (typeof(pof) !== 'function') | if (typeof(pof) !== 'function') | ||||
| this.__stream = null; | this.__stream = null; | ||||
| this.__SKIPEOL = false; | this.__SKIPEOL = false; | ||||
| this.__output = null; | this.__output = null; | ||||
| this.__PCLabel = "__PC__"; | |||||
| this.parseOpCode = pof(this); | this.parseOpCode = pof(this); | ||||
| } | } | ||||
| this.__SKIPEOL = false; | this.__SKIPEOL = false; | ||||
| } | } | ||||
| get stream(){return this.__stream;} | get stream(){return this.__stream;} | ||||
| get PCLabel(){return this.__PCLabel;} | |||||
| set PCLabel(pcl){ | |||||
| if (typeof(pcl) !== 'string' || pcl === "") | |||||
| throw new TypeError("PC Label must be a non-zero-length string."); | |||||
| this.__PCLabel = pcl; | |||||
| } | |||||
| isPunc(ch){ | isPunc(ch){ | ||||
| type: "assign", | type: "assign", | ||||
| op: "=", | op: "=", | ||||
| left: t, | left: t, | ||||
| right: "*", // To designate "current program counter". | |||||
| right: this.__PCLabel, // To designate "current program counter". | |||||
| line: t.line, | line: t.line, | ||||
| col: t.col | col: t.col | ||||
| } | } |