From 075de8aa775d048792ecd9c88be4959d0f705ecb Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 11 May 2019 15:31:09 -0400 Subject: [PATCH] DASM: more efficient parsing of multiple files, better unresolved symbol detection --- doc/notes.txt | 9 ++++---- src/views.ts | 2 +- src/worker/workermain.ts | 44 ++++++++++++++++------------------------ 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index 9c721d5a..056e0deb 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -59,7 +59,6 @@ TODO: - error showing replay div before rom starts - compiler flags for final ROM build - workermain: split build functions, better msg types -- vcs: INPTx needs to be added to control state - sdcc: can't link asm files before c files (e.g. acheader.s must be last) - what if >1 file with same name? (local/nonlocal/directory) - what if .c and .s names collide? @@ -77,7 +76,6 @@ TODO: - https://makecode.com/language? - open ROM from URL? - game starts even if switched away before first load -- vcs: break on # of lines changed (maybe using getRasterPosition?) - profiler restarts when paused - it's pretty easy to add a new file named like a library file (bcd.c) - or have neslib.h in a subdirectory... @@ -129,10 +127,13 @@ TODO: - replay doesn't work for nes (force background tile redraw) - nes debug view toolbar - support NES_HEADER_16K? -- vcs sound continues when paused +- vcs + - vcs sound continues when paused + - vcs: INPTx needs to be added to control state + - vcs: break on # of lines changed (maybe using getRasterPosition?) + - chrome looks blurry on vcs - upload multiple files/zip file to subdirectory - allow "include graphics.asm" instead of "include project/graphics.asm" -- chrome looks blurry on vcs - convert more stuff to Promises - target ES6 - don't have to include bootstrap-tourist each time? diff --git a/src/views.ts b/src/views.ts index 04bc4090..2b52d47c 100644 --- a/src/views.ts +++ b/src/views.ts @@ -608,7 +608,7 @@ export class MemoryView implements ProjectView { for (var i=n1; i= 0) { var cmt = l.indexOf(';'); if (cmt < 0 || cmt > pos) { - errors.push({ - path:filename, - line:linenum, - msg:"Unresolved symbol '" + key + "'" - }); + // make sure identifier is flanked by non-word chars + if (/\w+/.test(key) && new RegExp("\\b"+key+"\\b").test(key)) { + errors.push({ + path:filename, + line:linenum, + msg:"Unresolved symbol '" + key + "'" + }); + } } } } @@ -727,8 +730,6 @@ function parseDASMListing(code:string, unresolved:{}, mainFilename:string) { } } // TODO: use macrolines - // TODO: return {text:code, asmlines:lines, macrolines:macrolines, errors:errors}; - return {lines:lines, macrolines:macrolines, errors:errors}; } function assembleDASM(step:BuildStep) { @@ -768,22 +769,13 @@ function assembleDASM(step:BuildStep) { "-o"+binpath, "-s"+sympath ]); var alst = FS.readFile(lstpath, {'encoding':'utf8'}); - // parse main listing, get errors - var listing = parseDASMListing(alst, unresolved, step.path); - errors = errors.concat(listing.errors); - if (errors.length) { - return {errors:errors}; - } + // parse main listing, get errors and listings for each file var listings = {}; - listings[lstpath] = listing; - // parse include files - // TODO: kinda wasted effort - for (var fn of step.files) { - if (fn != step.path) { - var lst = parseDASMListing(alst, unresolved, fn); - listings[fn] = lst; // TODO: foo.asm.lst - } + for (let path of step.files) { + listings[path] = {lines:[]}; } + parseDASMListing(alst, listings, errors, unresolved); + // read binary rom output and symbols var aout, asym; aout = FS.readFile(binpath); try {