Browse Source

Another bug fix(arithmetic assign)

master
Stephen 1 month ago
parent
commit
0e92e5ce49
3 changed files with 3 additions and 2 deletions
  1. +0
    -1
      src/compiler.rs
  2. +2
    -0
      src/parser.rs
  3. +1
    -1
      tests/control.rs

+ 0
- 1
src/compiler.rs View File

@ -264,7 +264,6 @@ impl StmtVisitor<()> for Compiler {
//x > max value
self.patch_jmp(for_end_jmp, line);
//self.emit_opcode(OpCode::Pop);
}
fn visit_return_stmt(&mut self, stmt: &ReturnStmt, _: usize) {


+ 2
- 0
src/parser.rs View File

@ -151,6 +151,8 @@ impl<'a> Parser<'a> {
let operator = self.advance();
let val = self.expression()?;
self.consume(TokenType::Newline, "Expected newline after assignment.")?;
return Some(Stmt::new_binary_assign(
identifier,
operator.token_type,


+ 1
- 1
tests/control.rs View File

@ -248,7 +248,7 @@ fn nested_for_loop() {
a = 0
for x = 1 to 192
for y = 1 to 108
a = a + 1
a += 1
next y
next x
print a


Loading…
Cancel
Save