parser: add PlusEqual and MinusEqual to Get expressions

This commit is contained in:
Luna 2019-08-27 11:29:17 -03:00
parent 8007f9e860
commit a0808b54aa
2 changed files with 19 additions and 16 deletions

View file

@ -54,9 +54,10 @@ fn main(a int) int {
str := 'hello' str := 'hello'
len := str.len len := str.len
// those should yield the same ast
str.len = str.len + 1 str.len = str.len + 1
x += 1 str.len += 1
// str.len += 1
} }
fn (v Typ) voidfunc() {} fn (v Typ) voidfunc() {}

View file

@ -751,21 +751,23 @@ pub const Parser = struct {
return Result.CompileError; return Result.CompileError;
}, },
//.PlusEqual => { .PlusEqual => {
// var plus_op = try self.mkToken(.Plus, "+", op.line); var new_op = try self.mkToken(.Plus, "+", op.line);
// return try self.mkAssign( return try self.mkSet(
// expr.Variable, get.struc,
// try self.mkBinary(expr, plus_op, value), get.name,
// ); try self.mkBinary(expr, new_op, value),
//}, );
},
//.MinusEqual => { .MinusEqual => {
// var new_op = try self.mkToken(.Minus, "-", op.line); var new_op = try self.mkToken(.Minus, "-", op.line);
// return try self.mkSet( return try self.mkSet(
// get.struc, get.name, get.struc,
// try self.mkBinary(expr, new_op, value), get.name,
// ); try self.mkBinary(expr, new_op, value),
//}, );
},
.Equal => return try self.mkSet(get.struc, get.name, value), .Equal => return try self.mkSet(get.struc, get.name, value),
else => unreachable, else => unreachable,