Well that was 'fun'. I decided that this would be a good time to learn the Go language, and it was. I also decided to go a bit overboard and implement an actual Lexer based off of Rob Pike's talk show here, which has the lexer and parser running concurrently, which I did, but it made the whole experice a tad frustrating at times.
But, using a lexer/parser combo instead of just a regex and straight substitution gives nice things like warnings (two statements like @123, @456 are legal, but the first will have no effect) and I'll be reusing some of the code in the compiler project:
matt assembler # assembler -in Fill.asm -out filler.hack
WARNING - redundant loading of A-Register on line 1
WARNING - redundant loading of A-Register on line 17
I want to go back and possibly re-write the lexer as it's looking way more ugly than the parser, mainly because I wrote it first while still learning.
matt stuff # time assembler -in ~/Google\ Drive/Development/Nand2Tetris/course/projects/06/pong/Pong.asm -out pong.hack
No idea how (comparatively) fast that it, but would be curious to compare it to other implementations, if folks want to start a competition? (Bring on the language fights!)