Compare commits
No commits in common. "a2990e67c7656bd9771e3052f9cdd4afa4a027ba" and "c64767ba59f52ee269fadf6d7ecc1009777a2625" have entirely different histories.
a2990e67c7
...
c64767ba59
@ -258,8 +258,7 @@ const Parser = struct {
|
|||||||
UnexpectedEnd,
|
UnexpectedEnd,
|
||||||
};
|
};
|
||||||
|
|
||||||
const operator_tokens = &.{.symbol_assign, .symbol_plus,
|
const operator_tokens = &.{.symbol_assign, .symbol_plus, .symbol_dash, .symbol_asterisk, .symbol_forward_slash};
|
||||||
.symbol_dash, .symbol_asterisk, .symbol_forward_slash, .symbol_paren_left, .symbol_comma};
|
|
||||||
|
|
||||||
fn parse_expression(self: *Parser) ParseError!void {
|
fn parse_expression(self: *Parser) ParseError!void {
|
||||||
var operators = OperatorStack{};
|
var operators = OperatorStack{};
|
||||||
@ -439,7 +438,7 @@ const Parser = struct {
|
|||||||
else => self.parse_expression(),
|
else => self.parse_expression(),
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (self.current_token) {
|
switch (self.previous_token) {
|
||||||
.symbol_paren_right => break,
|
.symbol_paren_right => break,
|
||||||
.symbol_comma => {},
|
.symbol_comma => {},
|
||||||
else => return error.UnexpectedToken,
|
else => return error.UnexpectedToken,
|
||||||
@ -480,7 +479,6 @@ const Parser = struct {
|
|||||||
|
|
||||||
switch (self.current_token) {
|
switch (self.current_token) {
|
||||||
.symbol_assign => {
|
.symbol_assign => {
|
||||||
try self.step();
|
|
||||||
try self.parse_expression();
|
try self.parse_expression();
|
||||||
|
|
||||||
field_count += 1;
|
field_count += 1;
|
||||||
@ -511,17 +509,10 @@ const Parser = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try self.chunk.emit_opcode(.push_table);
|
|
||||||
try self.chunk.emit_operand(field_count);
|
|
||||||
|
|
||||||
if (is_call_argument) {
|
if (is_call_argument) {
|
||||||
try self.chunk.emit_opcode(.call);
|
try self.chunk.emit_opcode(.call);
|
||||||
try self.chunk.emit_operand(1);
|
try self.chunk.emit_operand(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.step() catch |step_error| switch (step_error) {
|
|
||||||
error.UnexpectedEnd => return,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
else => {
|
else => {
|
||||||
@ -592,7 +583,7 @@ const Parser = struct {
|
|||||||
.symbol_period => switch (self.previous_token) {
|
.symbol_period => switch (self.previous_token) {
|
||||||
.global_identifier => {
|
.global_identifier => {
|
||||||
// Create local copy of identifier because step() will overwrite captures.
|
// 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.step();
|
||||||
try self.current_token.expect(.local_identifier);
|
try self.current_token.expect(.local_identifier);
|
||||||
@ -604,7 +595,7 @@ const Parser = struct {
|
|||||||
|
|
||||||
.local_identifier => {
|
.local_identifier => {
|
||||||
// Create local copy of identifier because step() will overwrite captures.
|
// 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.step();
|
||||||
try self.current_token.expect(.local_identifier);
|
try self.current_token.expect(.local_identifier);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user