Simple floats

This commit is contained in:
iko 2024-05-16 23:07:33 +03:00
parent c0191b63dd
commit 1bea1efb8f
Signed by untrusted user: iko
GPG Key ID: 82C257048D1026F2
2 changed files with 69 additions and 21 deletions

View File

@ -64,7 +64,7 @@
++ parse-expr-list
%+ knee *(interlist binop expr)
|.
%+ parse-interlist parse-binop parse-atomic-expr
%+ parse-interlist (ifix [ws ws] parse-binop) parse-atomic-expr
:: TODO: This is mock and should take operator priority into account.
::
++ process-expr-list
@ -311,12 +311,16 @@
+$ numeral
$%
[%int @u]
:: [%float @rd]
[%float @rd]
==
++ parse-numeral
%+ knee *numeral
|.
;~ pose
%+ cook
|= x=@rd [%float x]
parse-float
::
%+ cook
|= x=@u [%int x]
;~ pose
@ -334,6 +338,7 @@
^- tape
?- -.num
%int (show-u +.num)
%float (show-float +.num)
==
:: exprlist
::
@ -514,7 +519,6 @@
^- tape
%- zing
%+ join "," l
:: ++ gawn (cold ~ (plus ;~(pose vul gah)))
++ parse-name
%+ knee *name
|.
@ -548,4 +552,43 @@
++ wss
%+ cold ~
%- plus w
--
++ parse-float
%+ knee *@rd
|.
%+ cook ryld
%+ cook royl-cell:so
%+ sear
|= [int=@ frac=(unit [@ @]) exp=(unit [exp-sign=? exp=@])]
?: ?=([~ ~] [frac exp]) ~
%- some
:*
%d
&
int
(fall frac [0 0])
(fall exp [& 0])
==
=/ moo
|= a=tape
:- (lent a)
(scan a (bass 10 (plus sid:ab)))
;~ plug
;~ plug
dim:ag
::
(punt ;~(pfix dot (cook moo (plus (shim '0' '9')))))
::
%- punt
;~ pfix
(mask "eE")
;~(plug ;~(pose (cold | hep) (easy &)) dim:ag)
==
==
==
++ show-float
|= x=@rd
^- tape
%- r-co:co
%- rlyd
x
--

View File

@ -4,36 +4,41 @@ baz = bar[nil]
baz = bar
i = 3
i, a[i] = i+1, 20>>9
i, a[i] = i + 1, 20 >> 9
hello = "hellodkndjвговшов"
x = {[hello] = 8, hello = 12}
x = { [hello] = 8, hello = 12 }
;
test_cases = {
{ 0x7fffffff, "2147483647" },
{ 2147483647, "2147483647" },
{ 0x7fffffff, "2147483647" },
{ 2147483647, "2147483647" },
{ 0xffffffff, "4294967295" },
{ 4294967295, "4294967295" },
{ 0xffffffff, "4294967295" },
{ 4294967295, "4294967295" },
{ 0x7fffffffffffffff, "9.2233720368548e+18" },
{ 9223372036854775807, "9.2233720368548e+18" },
{ 0x7fffffffffffffff, "9.2233720368548e+18" },
{ 9223372036854775807, "9.2233720368548e+18" },
{ 0xffffffffffffffff, "1.844674407371e+19" },
{ 0xffffffffffffffff, "1.844674407371e+19" },
{ 18446744073709551615, "1.844674407371e+19" },
{ 0x100000000, "4294967296" },
{ 4294967296, "4294967296" },
{ 0x100000000, "4294967296" },
{ 4294967296, "4294967296" },
{ 0x100000000000, "17592186044416" },
{ 17592186044416, "17592186044416" },
{ 0x100000000000, "17592186044416" },
{ 17592186044416, "17592186044416" },
{ 0x80000000, "2147483648" },
{ 2147483648, "2147483648" },
{ 0x80000000, "2147483648" },
{ 2147483648, "2147483648" },
{ 0x800000000000, "1.4073748835533e+14" },
{ 140737488355328, "1.4073748835533e+14" },
{ 0x800000000000, "1.4073748835533e+14" },
{ 140737488355328, "1.4073748835533e+14" },
}
foo = {
3.0, 3.1416, 314.16e-2, 0.31416E1, 34e1,
0x0.1E, 0xA23p-4, 0X1.921FB54442D18P+1
}