mirror of https://github.com/nocturn9x/nimkalc.git
The lexer now skips newlines
This commit is contained in:
parent
d1f96da9d1
commit
24785c9a0f
|
@ -92,7 +92,7 @@ func createToken(self: Lexer, tokenType: TokenType): Token =
|
||||||
result = Token(kind: tokenType,
|
result = Token(kind: tokenType,
|
||||||
lexeme: self.source[self.start..<self.current],
|
lexeme: self.source[self.start..<self.current],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
proc parseNumber(self: Lexer) =
|
proc parseNumber(self: Lexer) =
|
||||||
## Parses numeric literals
|
## Parses numeric literals
|
||||||
|
@ -140,7 +140,7 @@ proc scanToken(self: Lexer) =
|
||||||
## called iteratively until the source
|
## called iteratively until the source
|
||||||
## string reaches EOF
|
## string reaches EOF
|
||||||
var single = self.step()
|
var single = self.step()
|
||||||
if single in [' ', '\t', '\r']: # We skip whitespaces, tabs and other stuff
|
if single in [' ', '\t', '\r', '\n']: # We skip whitespaces, tabs and other stuff
|
||||||
return
|
return
|
||||||
elif single.isDigit():
|
elif single.isDigit():
|
||||||
self.parseNumber()
|
self.parseNumber()
|
||||||
|
|
Loading…
Reference in New Issue