Administrator
|
Yes, strict implementation of this interface requires hasMoreCommands() to read lines and strip comments and whitespace and only return when it has found a non-blank line or end of file.
I combined hasMoreCommands() into advance() and had advance() return true/false so that my pass1/pass2 loops can simple be "while(parser.advance()) {"
Another thing that I've seen students do, especially in languages like Python that make list manipulation really simple, is to read the entire source file into a list, then strip all the comments and whitespace, then delete any blank lines that may result.
I don't like this pre-stripping because if you later wish to modify your assembler to add source line number information to error messages, or generate a listing file, you have lost all that info.
--Mark
|