Closed isaaclyman closed 1 month ago
@isaaclyman thank you for raising the issue!
@netalondon can you take a look and see why we can't handle multiple empty lines in the assembler?
I've tried a couple of things, by the way:
@R0
doesn't change the error message.The error I see is actually on line 13:
Which can be "fixed" by changing that to M=D+M or M=D+A
So we need to update the parser to include all the permutations in https://github.com/nand2tetris/web-ide/blob/main/simulator/src/languages/grammars/asm.ohm#L24-L35 and also that error message was very poor.
@DavidSouther I think it's intentional that we allow only D+M as specified in the book.
I'll get working on having a more user-friendly error message for this.
I would say the error message itself isn't the only problem. Observe how the red underline is on the wrong line below:
If you actually count out the lines (which has to be done manually, since line numbers aren't shown), line 21 is where the problem is. But the red underline appears at the end of line 18, which confuses the situation further.
This is the new error message:
This is a correct change from the Java IDE, which did allow both. This aligns the assembler with figure 4.5 in the 2nd edition of the book. As for why, from Shimon:
I think that for the sake of "better education" is better to adhere to the book/course specs to the letter. Also, allowing commutativity hints that D+M is an expression, where in fact it is simply a mnemonic.
Program
Assembler
Interface
Website (https://nand2tetris.github.io/web-ide)
Contact Details
mail@isaaclyman.com
What happened?
In order to solve the "Mult" project in chapter 4, I opened
projects/04/Mult/Mult.asm
in the Assembler and pasted in the following code:Below the editor window, I immediately get the message:
I also see a red underline on the line that says
@R0
after the blank line in the middle of the loop. The online Assembler will not translate this code. However, the legacy Assembler translates it with no issues at all.Additional Comments
No response
Do you want to try to fix this bug?
Code of Conduct