summaryrefslogtreecommitdiff
path: root/src/parser/parser.js
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-22 14:58:52 -0500
committersanine-a <sanine.not@pm.me>2023-05-22 14:58:52 -0500
commit9e8703d07e2e49d14e3d2092d77f8f7e75ee7e04 (patch)
tree548572958e4f368d7d1dbe0144c9e27a160c2ec3 /src/parser/parser.js
parentf2a515a940ea5e66c9fbc9669e6293ae32b7041a (diff)
fix line labels ordering
Diffstat (limited to 'src/parser/parser.js')
-rw-r--r--src/parser/parser.js20
1 files changed, 17 insertions, 3 deletions
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<program.program.length; pc += 1) {
+ parser.yy.tidyAddress(pc, program.program[pc].a);
+ parser.yy.tidyAddress(pc, program.program[pc].b);
+ }
+ console.log(program);
console.log(parser.yy);
});
//}