|
|
@@ -225,6 +225,26 @@ class Parser{ |
|
|
|
return t; |
|
|
|
} |
|
|
|
|
|
|
|
parseTempLabel(){ |
|
|
|
let isEOL = this.stream.eol(); |
|
|
|
this.stream.next(); |
|
|
|
if (isEOL){ |
|
|
|
this.__SKIPEOL = true; |
|
|
|
return { |
|
|
|
type:"temp-label", |
|
|
|
val:-1, // Value of -1 means "set new temp label" |
|
|
|
line:this.stream.line(), |
|
|
|
col:this.stream.col() |
|
|
|
}; |
|
|
|
} |
|
|
|
let t = this.stream.next(); |
|
|
|
if (t.type === "number"){ |
|
|
|
t.type = "temp-label"; |
|
|
|
return t; |
|
|
|
} |
|
|
|
this.stream.die("Temp label missing index. New temp labels must be defined at the start of the line."); |
|
|
|
} |
|
|
|
|
|
|
|
parseAtom(){ |
|
|
|
if (this.isPunc("(")){ |
|
|
|
this.stream.next(); |
|
|
@@ -233,6 +253,8 @@ class Parser{ |
|
|
|
this.stream.next(); |
|
|
|
return exp; |
|
|
|
} |
|
|
|
} else if (this.isPunc(":")){ |
|
|
|
return this.parseTempLabel(); |
|
|
|
} else if (this.isOpCode()){ |
|
|
|
return this.parseOpCode(); |
|
|
|
} else if (this.isDirective(".if")){ |
|
|
@@ -242,10 +264,10 @@ class Parser{ |
|
|
|
} |
|
|
|
|
|
|
|
let tok = this.stream.next(); |
|
|
|
if (tok.type === "number" || tok.type === "string" || tok.type === "label"){ |
|
|
|
if (tok.type === "label") |
|
|
|
return this.parseLabel(tok); |
|
|
|
if (tok.type === "number" || tok.type === "string"){ |
|
|
|
return tok; |
|
|
|
} else if (tok.type === "label"){ |
|
|
|
return this.parseLabel(tok); |
|
|
|
} |
|
|
|
this.stream.die("Unexpected token {type:" + tok.type + ", val:'" + tok.val + "'}."); |
|
|
|
} |