浏览代码

Parser can now have it's Program Counter Label (PCLabel) defined. Defaults to '__PC__'. The symbole '*' is no longer used.

master
Bryan Miller 5 年前
父节点
当前提交
da3a8b826f
共有 1 个文件被更改,包括 11 次插入1 次删除
  1. +11
    -1
      src/compiler/parser.js

+ 11
- 1
src/compiler/parser.js 查看文件

@@ -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
}

正在加载...
取消
保存