Skip to content

Commit

Permalink
compiler: Equality comparison operator compilation error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanChaudhary committed Apr 19, 2024
1 parent c0b4d8e commit f90f179
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* divide the Jack tutorial into more subsections
* arguments keyword in docs (nArgs doesnt matter)

* ub: abs -32768, stack overflows, operator priority modifying stack frame, modifying registers, < and >, too few arguments (mention it is a wontfix)
* hardware limitations
* max ROM 32768 and max static 240 and max stack 1792 and screen stuff and multi keyboard input

Expand Down
5 changes: 5 additions & 0 deletions src/compiler/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,12 @@ export default class Engine {
this.compileTerm();
const op = this.tokenizer.token() as SymbolToken;
if (OPS.includes(op)) {
const currentIsEquals = op === SymbolToken.EQUAL;
this.tokenizer.advance();
const nextIsEquals = this.tokenizer.token() === SymbolToken.EQUAL;
if (currentIsEquals && nextIsEquals) {
throw this.tokenizer.syntaxError("", "use '=' instead of '==' for the equality comparison");
}
this.compileExpression();
this.vmwriter.writeArithmetic(op);
}
Expand Down

0 comments on commit f90f179

Please sign in to comment.