The new Decimal API

This commit is contained in:
Krasimir Angelov
2023-08-21 20:14:26 +02:00
parent 58da8deca8
commit fb398c603e
147 changed files with 918 additions and 188 deletions
+1
View File
@@ -68,5 +68,6 @@ concrete CatHrv of Cat =
lincat Numeral = {s : AdjForms ; size : NumSize} ;
lincat Digits = {s : Str ; size : NumSize} ;
lincat Decimal = {s : Str ; size : NumSize ; hasDot : Bool} ;
}
+1
View File
@@ -89,6 +89,7 @@ lin
NumCard c = c ;
NumDigits ds = ds ** {s = \\_,_ => ds.s} ;
NumDecimal dec = dec ** {s = \\_,_ => dec.s} ;
NumNumeral nu = {
s = \\g,c => (adjFormsAdjective nu.s).s ! g ! Sg ! c ; ---- TODO Sg?
size = nu.size
+15 -1
View File
@@ -1,6 +1,6 @@
concrete NumeralHrv of Numeral =
CatHrv [Numeral, Digits] **
CatHrv [Numeral, Digits, Decimal] **
open
ResHrv,
@@ -125,6 +125,20 @@ oper mkThousand : Str -> NumSize -> Str = \attr,size ->
IIDig d dd = {s = d.s ++ Predef.BIND ++ dd.s ; size = dd.size} ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ Predef.BIND ++ d.s ;
size = d.size ;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s;
size = d.size ;
hasDot=True
} ;
D_0 = { s = "0" ; size = NS_1} ; ---- ??
D_1 = { s = "1" ; size = NS_1} ;
D_2 = { s = "2" ; size = NS_2_4} ;