From 9e8703d07e2e49d14e3d2092d77f8f7e75ee7e04 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Mon, 22 May 2023 14:58:52 -0500 Subject: fix line labels ordering --- src/parser/parser.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/parser/parser.js') diff --git a/src/parser/parser.js b/src/parser/parser.js index ef84be3..7d3dd95 100644 --- a/src/parser/parser.js +++ b/src/parser/parser.js @@ -22,15 +22,29 @@ parser.yy = { return this.equ[l]; } - return this.line[l] - this.pc; + return l; + }, + + tidyAddress: function(pc, addr) { + if (typeof(addr.value) === "string") { + addr.value = this.line[addr.value] - pc; + } }, }; + //if (process.argv[1] === 'parser.js' && process.argv.length >= 3) { fs.readFile(process.argv[2], 'utf8', (err, data) => { if (err) throw err; - let result = parser.parse(data.toUpperCase()); - console.log(result); + let program = parser.parse(data.toUpperCase()); + if (typeof(program.start) === "string") { + program.start = parser.yy.line[program.start]; + } + for (let pc=0; pc