| @@ -68,6 +68,8 @@ function isTokenType(stream, type, val){ | |||
| } | |||
| class Parser{ | |||
| constructor(pof){ | |||
| if (typeof(pof) !== 'function') | |||
| @@ -75,6 +77,7 @@ class Parser{ | |||
| this.__stream = null; | |||
| this.__SKIPEOL = false; | |||
| this.__output = null; | |||
| this.__PCLabel = "__PC__"; | |||
| this.parseOpCode = pof(this); | |||
| } | |||
| @@ -84,6 +87,13 @@ class Parser{ | |||
| this.__SKIPEOL = false; | |||
| } | |||
| 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){ | |||
| @@ -206,7 +216,7 @@ class Parser{ | |||
| type: "assign", | |||
| op: "=", | |||
| left: t, | |||
| right: "*", // To designate "current program counter". | |||
| right: this.__PCLabel, // To designate "current program counter". | |||
| line: t.line, | |||
| col: t.col | |||
| } | |||