| return t; | 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(){ | parseAtom(){ | ||||
| if (this.isPunc("(")){ | if (this.isPunc("(")){ | ||||
| this.stream.next(); | this.stream.next(); | ||||
| this.stream.next(); | this.stream.next(); | ||||
| return exp; | return exp; | ||||
| } | } | ||||
| } else if (this.isPunc(":")){ | |||||
| return this.parseTempLabel(); | |||||
| } else if (this.isOpCode()){ | } else if (this.isOpCode()){ | ||||
| return this.parseOpCode(); | return this.parseOpCode(); | ||||
| } else if (this.isDirective(".if")){ | } else if (this.isDirective(".if")){ | ||||
| } | } | ||||
| let tok = this.stream.next(); | 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; | return tok; | ||||
| } else if (tok.type === "label"){ | |||||
| return this.parseLabel(tok); | |||||
| } | } | ||||
| this.stream.die("Unexpected token {type:" + tok.type + ", val:'" + tok.val + "'}."); | this.stream.die("Unexpected token {type:" + tok.type + ", val:'" + tok.val + "'}."); | ||||
| } | } |