parser: add PlusEqual and MinusEqual to Get expressions
This commit is contained in:
parent
8007f9e860
commit
a0808b54aa
2 changed files with 19 additions and 16 deletions
|
@ -54,9 +54,10 @@ fn main(a int) int {
|
|||
|
||||
str := 'hello'
|
||||
len := str.len
|
||||
|
||||
// those should yield the same ast
|
||||
str.len = str.len + 1
|
||||
x += 1
|
||||
// str.len += 1
|
||||
str.len += 1
|
||||
}
|
||||
|
||||
fn (v Typ) voidfunc() {}
|
||||
|
|
|
@ -751,21 +751,23 @@ pub const Parser = struct {
|
|||
return Result.CompileError;
|
||||
},
|
||||
|
||||
//.PlusEqual => {
|
||||
// var plus_op = try self.mkToken(.Plus, "+", op.line);
|
||||
// return try self.mkAssign(
|
||||
// expr.Variable,
|
||||
// try self.mkBinary(expr, plus_op, value),
|
||||
// );
|
||||
//},
|
||||
.PlusEqual => {
|
||||
var new_op = try self.mkToken(.Plus, "+", op.line);
|
||||
return try self.mkSet(
|
||||
get.struc,
|
||||
get.name,
|
||||
try self.mkBinary(expr, new_op, value),
|
||||
);
|
||||
},
|
||||
|
||||
//.MinusEqual => {
|
||||
// var new_op = try self.mkToken(.Minus, "-", op.line);
|
||||
// return try self.mkSet(
|
||||
// get.struc, get.name,
|
||||
// try self.mkBinary(expr, new_op, value),
|
||||
// );
|
||||
//},
|
||||
.MinusEqual => {
|
||||
var new_op = try self.mkToken(.Minus, "-", op.line);
|
||||
return try self.mkSet(
|
||||
get.struc,
|
||||
get.name,
|
||||
try self.mkBinary(expr, new_op, value),
|
||||
);
|
||||
},
|
||||
|
||||
.Equal => return try self.mkSet(get.struc, get.name, value),
|
||||
else => unreachable,
|
||||
|
|
Loading…
Reference in a new issue