scanner: fix SlashEqual generation not skipping its own chars

- parser: allow SlashEqual on main mkAssign/mkSet call
 - readme: += and gang are done
This commit is contained in:
Luna 2019-08-27 12:05:29 -03:00
parent e0a60ddc2c
commit 4479e78356
3 changed files with 8 additions and 5 deletions

View file

@ -34,7 +34,6 @@ negatively charged towards
## wip
- `+=`, `-=`, and the rest of the gang
- no `for` yet
- no arrays yet
- no `map` yet

View file

@ -756,7 +756,7 @@ pub const Parser = struct {
.ColonEqual => return try self.mkVarDecl(expr.Variable, value, mutable),
.Equal => return try self.mkAssign(expr.Variable, value),
.PlusEqual, .MinusEqual, .StarEqual => {
.PlusEqual, .MinusEqual, .StarEqual, .SlashEqual => {
var new_op = try self.mkToken(new_op_ttype, new_lexeme, op.line);
return try self.mkAssign(
expr.Variable,
@ -775,7 +775,9 @@ pub const Parser = struct {
return Result.CompileError;
},
.PlusEqual, .MinusEqual, .StarEqual => {
.Equal => return try self.mkSet(get.struc, get.name, value),
.PlusEqual, .MinusEqual, .StarEqual, .SlashEqual => {
var new_op = try self.mkToken(new_op_ttype, new_lexeme, op.line);
return try self.mkSet(
get.struc,
@ -784,7 +786,6 @@ pub const Parser = struct {
);
},
.Equal => return try self.mkSet(get.struc, get.name, value),
else => unreachable,
}
},

View file

@ -317,7 +317,10 @@ pub const Scanner = struct {
var next = self.peekNext();
switch (next) {
'=' => return self.makeToken(.SlashEqual),
'=' => {
self.current += 1;
return self.makeToken(.SlashEqual);
},
'/' => blk2: {
while (self.peek() != '\n' and !self.isAtEnd()) {