Compare commits

...

2 Commits

Author SHA1 Message Date
iko
1bea1efb8f
Simple floats 2024-05-16 23:07:33 +03:00
iko
c0191b63dd
Added hex ints 2024-05-15 23:02:51 +03:00
3 changed files with 82 additions and 27 deletions

View File

@ -2,3 +2,4 @@
- [ ] functioncall
- [ ] any string apart from the basic string with no escapes
- [ ] check if int fits in int or make it a float

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
@ -310,18 +310,26 @@
::
+$ numeral
$%
[%int @s]
:: [%float @rd]
[%int @u]
[%float @rd]
==
++ parse-numeral
%+ knee *numeral
|.
;~ pose
%+ cook
|= [is-neg=(unit *) x=@]
[%int (new:si ?=(~ is-neg) x)]
;~ plug
(punt (just '-'))
|= x=@rd [%float x]
parse-float
::
%+ cook
|= x=@u [%int x]
;~ pose
;~ pfix
(just '0')
(mask "xX")
hex
==
::
(bass 10 (plus dit))
==
==
@ -329,7 +337,8 @@
|= [num=numeral]
^- tape
?- -.num
%int (show-s +.num)
%int (show-u +.num)
%float (show-float +.num)
==
:: exprlist
::
@ -510,7 +519,6 @@
^- tape
%- zing
%+ join "," l
:: ++ gawn (cold ~ (plus ;~(pose vul gah)))
++ parse-name
%+ knee *name
|.
@ -524,6 +532,8 @@
;~(plug name-fst-char (star name-char))
++ show-s
|=(s=@s `tape`[?:((syn:si s) %$ '-') (slag 2 (scow %ui (abs:si s)))])
++ show-u
|=(u=@u `tape`(slag 2 (scow %ui u)))
++ bind
|* =mold
|* [prev=rule cont=$-(mold rule)]
@ -542,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
}