aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Viswanathan <dev@genotrance.com>2020-06-20 13:52:01 -0500
committerGanesh Viswanathan <dev@genotrance.com>2020-06-20 13:52:01 -0500
commit033f134e400a2d928453e9526b9b473a386b4f80 (patch)
treea73ce70a888646b08e81a751b38d21d8332e2aaf
parent2234eead75308085706971a61c7f7498c24eebd4 (diff)
downloadnimterop-033f134e400a2d928453e9526b9b473a386b4f80.tar.gz
nimterop-033f134e400a2d928453e9526b9b473a386b4f80.zip
Improve octal fix
-rw-r--r--nimterop/build.nim5
-rw-r--r--nimterop/build/nimconf.nim3
-rw-r--r--nimterop/toastlib/exprparser.nim22
3 files changed, 16 insertions, 14 deletions
diff --git a/nimterop/build.nim b/nimterop/build.nim
index 99adeca..0754615 100644
--- a/nimterop/build.nim
+++ b/nimterop/build.nim
@@ -1,4 +1,7 @@
-import hashes, macros, osproc, sets, strformat, strutils, tables
+import hashes, osproc, sets, strformat, strutils
+
+when not defined(TOAST):
+ import macros, tables
import os except findExe, sleep
diff --git a/nimterop/build/nimconf.nim b/nimterop/build/nimconf.nim
index 98fc8fe..3ba5ed0 100644
--- a/nimterop/build/nimconf.nim
+++ b/nimterop/build/nimconf.nim
@@ -1,4 +1,4 @@
-import json, macros, os, osproc, sets, strformat, strutils
+import json, os, osproc, sets, strformat, strutils
when nimvm:
when (NimMajor, NimMinor, NimPatch) >= (1, 2, 0):
@@ -55,6 +55,7 @@ proc getProjectDir*(): string =
result = querySetting(projectFull).parentDir()
else:
# Get from `macros`
+ import macros
result = getProjectPath()
else:
discard
diff --git a/nimterop/toastlib/exprparser.nim b/nimterop/toastlib/exprparser.nim
index dc9f97e..28b49d3 100644
--- a/nimterop/toastlib/exprparser.nim
+++ b/nimterop/toastlib/exprparser.nim
@@ -140,15 +140,16 @@ proc getIntNode(number, suffix: string): PNode {.inline.} =
var
val: BiggestInt
flags: TNodeFlags
- if number.startsWith("0X") or number.startsWith("0x"):
- val = parseHexInt(number)
- flags = {nfBase16}
- elif number.startsWith("0B") or number.startsWith("0b"):
- val = parseBinInt(number)
- flags = {nfBase2}
- elif number.startsWith("0O") or number.startsWith("0o"):
- val = parseOctInt(number)
- flags = {nfBase8}
+ if number.len > 1 and number[0] == '0':
+ if number[1] in ['x', 'X']:
+ val = parseHexInt(number)
+ flags = {nfBase16}
+ elif number[1] in ['b', 'B']:
+ val = parseBinInt(number)
+ flags = {nfBase2}
+ else:
+ val = parseOctInt(number)
+ flags = {nfBase8}
else:
val = parseInt(number)
@@ -201,9 +202,6 @@ proc processNumberLiteral(gState: State, node: TSNode): PNode =
if number.startsWith("-"):
number = number[1 ..< number.len]
prefix = "-"
- if number.len > 1 and number[0] == '0' and number[1] notin ['x', 'X']:
- # Octal 0123
- number = "0o" & number[1 .. ^1]
if tripleEndings.any(proc (s: string): bool = number.endsWith(s)):
suffix = number[^3 .. ^1]
number = number[0 ..< ^3]