summaryrefslogtreecommitdiff
path: root/src/compiler/types.lm
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-09-27 02:43:50 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-09-27 02:43:50 +0300
commita2b69e5b9479ddeba3c737c8ef01764d5454520c (patch)
tree9ef02540b4f9c877ab73d8ca978bc89f073fd2e6 /src/compiler/types.lm
parent5d253b30c5d84857d06393b77ce91fb974061665 (diff)
implement the binary number type
Diffstat (limited to 'src/compiler/types.lm')
-rw-r--r--src/compiler/types.lm4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compiler/types.lm b/src/compiler/types.lm
index b33adf7..a371695 100644
--- a/src/compiler/types.lm
+++ b/src/compiler/types.lm
@@ -10,14 +10,18 @@ context number
token OCT / '0'[0-7]+ /
token DEC / [0-9]+ /
token HEX / '0x' xdigit+ /
+ literal `0b
end
+ token BIN / [0-1]+ /
+
int strtoull(a:str, b:int) = c_strtoull
def type
value:int
[`false] { lhs.value = 0 }
| [`true] { lhs.value = 1 }
+ | [`0b BIN] { lhs.value = strtoull($r2, 2) }
| [OCT] { lhs.value = strtoull($r1, 8) }
| [DEC] { lhs.value = strtoull($r1, 10) }
| [HEX] { lhs.value = strtoull($r1, 16) }