From a2b69e5b9479ddeba3c737c8ef01764d5454520c Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Thu, 27 Sep 2018 02:43:50 +0300 Subject: implement the binary number type --- src/compiler/types.lm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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) } -- cgit v1.2.3-70-g09d2