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:
parent
e0a60ddc2c
commit
4479e78356
3 changed files with 8 additions and 5 deletions
|
@ -34,7 +34,6 @@ negatively charged towards
|
|||
|
||||
## wip
|
||||
|
||||
- `+=`, `-=`, and the rest of the gang
|
||||
- no `for` yet
|
||||
- no arrays yet
|
||||
- no `map` yet
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in a new issue