diff --git a/source/kym/bytecode.zig b/source/kym/bytecode.zig index 9f99b68..28797db 100755 --- a/source/kym/bytecode.zig +++ b/source/kym/bytecode.zig @@ -258,7 +258,8 @@ const Parser = struct { UnexpectedEnd, }; - const operator_tokens = &.{.symbol_assign, .symbol_plus, .symbol_dash, .symbol_asterisk, .symbol_forward_slash}; + const operator_tokens = &.{.symbol_assign, .symbol_plus, + .symbol_dash, .symbol_asterisk, .symbol_forward_slash, .symbol_paren_left, .symbol_comma}; fn parse_expression(self: *Parser) ParseError!void { var operators = OperatorStack{}; @@ -438,7 +439,7 @@ const Parser = struct { else => self.parse_expression(), }; - switch (self.previous_token) { + switch (self.current_token) { .symbol_paren_right => break, .symbol_comma => {}, else => return error.UnexpectedToken, @@ -479,6 +480,7 @@ const Parser = struct { switch (self.current_token) { .symbol_assign => { + try self.step(); try self.parse_expression(); field_count += 1; @@ -516,6 +518,10 @@ const Parser = struct { try self.chunk.emit_opcode(.call); try self.chunk.emit_operand(1); } + + self.step() catch |step_error| switch (step_error) { + error.UnexpectedEnd => return, + }; }, else => { @@ -586,7 +592,7 @@ const Parser = struct { .symbol_period => switch (self.previous_token) { .global_identifier => { // Create local copy of identifier because step() will overwrite captures. - const identifier = self.previous_token.local_identifier; + const identifier = self.previous_token.global_identifier; try self.step(); try self.current_token.expect(.local_identifier); @@ -598,7 +604,7 @@ const Parser = struct { .local_identifier => { // Create local copy of identifier because step() will overwrite captures. - const identifier = self.previous_token.global_identifier; + const identifier = self.previous_token.local_identifier; try self.step(); try self.current_token.expect(.local_identifier);