assembler - Change to make use of improvements in Opter
This commit is contained in:
parent
9c1cf4abba
commit
e25723fcc9
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const argparser = require('./argparser/argparser.js');
|
const Opter = require('./opter/opter.js');
|
||||||
const { logMemory } = require('./logging.js');
|
const { logMemory } = require('./logging.js');
|
||||||
const { num2hex, hex2num, bin2num } = require('./conversions.js');
|
const { num2hex, hex2num, bin2num } = require('./conversions.js');
|
||||||
const DBG = require('./dbg.js');
|
const DBG = require('./dbg.js');
|
||||||
|
|
@ -405,40 +405,26 @@ function stripWhitespaceFromEnds(line) {
|
||||||
|
|
||||||
/** MAIN **/
|
/** MAIN **/
|
||||||
|
|
||||||
// Initialize debugger
|
|
||||||
let dbg = new DBG('nitpick');
|
|
||||||
|
|
||||||
// Handle command-line options...
|
// Handle command-line options...
|
||||||
const args = argparser(process.argv);
|
const opts = new Opter(process.argv);
|
||||||
dbg.d('args', args);
|
opts.synonymize('-d', '--debug');
|
||||||
|
opts.requireOption('-i', 'Input file required (-i prog.asm)');
|
||||||
|
opts.requireOptionArgument('-i', 1, 1, 'Input file required (-i prog.asm)');
|
||||||
|
opts.requireOptionArgument('-o', 1, 1, 'Missing output file name (-o prog.asm)');
|
||||||
|
|
||||||
if (typeof args.i === 'undefined' || args.i.length === 0) {
|
const inputFilename = opts.opts.i[0];
|
||||||
console.error('Input file required (-i prog.asm)');
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
const inputFilename = args.i[0];
|
|
||||||
const inputFile_str = fs.readFileSync(inputFilename, 'utf8');
|
const inputFile_str = fs.readFileSync(inputFilename, 'utf8');
|
||||||
|
|
||||||
if ('o' in args && args.o.length === 0) {
|
let outputFileProvided = opts.contains('-o');
|
||||||
console.error('Missing output file name (-o prog.asm)');
|
let returnOnStdout = !outputFileProvided;
|
||||||
process.exit();
|
let outputFilename = outputFileProvided ? opts.opts.o[0] : null;
|
||||||
}
|
|
||||||
|
|
||||||
let outputFilename = null;
|
let outputWithMetadata = opts.contains('--debug');
|
||||||
let returnOnStdout = 'o' in args ? false : true;
|
|
||||||
if (!returnOnStdout) {
|
|
||||||
outputFilename = args.o[0];
|
|
||||||
} else {
|
|
||||||
dbg = new DBG('none');
|
|
||||||
}
|
|
||||||
|
|
||||||
let outputWithMetadata = false;
|
// Initialize debugger...
|
||||||
if ('d' in args || 'debug' in args) {
|
const dbg = returnOnStdout ? new DBG('none') : new DBG('nitpick');
|
||||||
outputWithMetadata = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: maybe check for too many args?
|
|
||||||
|
|
||||||
|
// Assemble...!
|
||||||
assemble(inputFile_str, outputFilename, outputWithMetadata);
|
assemble(inputFile_str, outputFilename, outputWithMetadata);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit c2ea099bbfddada734b5fc6e4f1125658c8ba578
|
Subproject commit 4dec08afbc0c96e454dd532ed9cfa16a4a1ddd51
|
||||||
Loading…
Reference in New Issue