Explorar el Código

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

master
Bryan Miller hace 5 años
padre
commit
da3a8b826f
Se han modificado 1 ficheros con 11 adiciones y 1 borrados
  1. +11
    -1
      src/compiler/parser.js

+ 11
- 1
src/compiler/parser.js Ver fichero

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

Cargando…
Cancelar
Guardar