From 7714c08846391ce2fabc75e8c31fb171d8f826fc Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 3 Sep 2022 12:58:06 -0400 Subject: [PATCH] Tokens with a dash beginning are positioned correctly --- lexer/lexer.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lexer/lexer.go b/lexer/lexer.go index 3109252..80170c9 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -372,11 +372,11 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) { } func (lexer *LexingOperation) tokenizeDashBeginning () (err error) { + token := lexer.newToken() err = lexer.nextRune() if err != nil { return } if lexer.char == '-' { - token := lexer.newToken() token.kind = TokenKindDecrement token.location.SetWidth(2) @@ -390,18 +390,16 @@ func (lexer *LexingOperation) tokenizeDashBeginning () (err error) { } lexer.addToken(token) } else if lexer.char == '>' { - token := lexer.newToken() token.kind = TokenKindReturnDirection token.location.SetWidth(2) - err = lexer.nextRune() + err = lexer.nextRune() if err != nil { return } lexer.addToken(token) } else if lexer.char >= '0' && lexer.char <= '9' { lexer.tokenizeNumberBeginning(true) } else { - token := lexer.newToken() token.kind = TokenKindMinus lexer.addToken(token) }