mescc: Support binary constants.
* module/language/c99/compiler.mes (cstring->number): Support binary 0bxxx values. * scaffold/t.c (math_test): Test it.
This commit is contained in:
parent
2eae07de72
commit
390059a42d
|
@ -1073,6 +1073,7 @@
|
|||
|
||||
(define (cstring->number s)
|
||||
(cond ((string-prefix? "0x" s) (string->number (string-drop s 2) 16))
|
||||
((string-prefix? "0b" s) (string->number (string-drop s 2) 2))
|
||||
((string-prefix? "0" s) (string->number s 8))
|
||||
(else (string->number s))))
|
||||
|
||||
|
|
|
@ -347,6 +347,15 @@ math_test ()
|
|||
puts ("t: 3 != 3\n");
|
||||
if ((3 != 3) != 0) return 1;
|
||||
|
||||
puts ("t: 011 == 15\n");
|
||||
if (011 != 9) return 1;
|
||||
|
||||
puts ("t: 0b11 == 3\n");
|
||||
if (0b11 != 3) return 1;
|
||||
|
||||
puts ("t: 0x11 == 3\n");
|
||||
if (0x11 != 17) return 1;
|
||||
|
||||
return array_test (env);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue