From 07cc6db148bba9828f60e6afd64db52632997f3d Mon Sep 17 00:00:00 2001 From: camdenorrb <5360339+camdenorrb@users.noreply.github.com> Date: Thu, 26 Aug 2021 16:01:13 -0500 Subject: [PATCH] Negative numbers! --- src/main/kotlin/me/camdenorrb/crescentvm/Main.kt | 2 +- .../kotlin/me/camdenorrb/crescentvm/lexers/CrescentLexer.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/me/camdenorrb/crescentvm/Main.kt b/src/main/kotlin/me/camdenorrb/crescentvm/Main.kt index 9eb4110..a9dbe6b 100644 --- a/src/main/kotlin/me/camdenorrb/crescentvm/Main.kt +++ b/src/main/kotlin/me/camdenorrb/crescentvm/Main.kt @@ -21,7 +21,7 @@ object Main { val code = """ fun main() { - println(round(-2.5)) + println(-.5) } """ /* diff --git a/src/main/kotlin/me/camdenorrb/crescentvm/lexers/CrescentLexer.kt b/src/main/kotlin/me/camdenorrb/crescentvm/lexers/CrescentLexer.kt index a42ddcf..0c8c9e3 100644 --- a/src/main/kotlin/me/camdenorrb/crescentvm/lexers/CrescentLexer.kt +++ b/src/main/kotlin/me/camdenorrb/crescentvm/lexers/CrescentLexer.kt @@ -35,7 +35,7 @@ object CrescentLexer { val next = charIterator.next() val peek = charIterator.peekNext() - if (next == '-' && (peek.isDigit() || (peek == '.' && charIterator.peekNext(2).isDigit()))) { + if (next == '-' && (peek.isDigit() || (peek == '.' && charIterator.peekNext(1).isDigit()))) { isANumber = true "-${readNumber(charIterator)}" }