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

View File

@@ -66,6 +66,7 @@ concrete CatCze of Cat =
lincat Numeral = Determiner ; ---- TODO: should contain Ord as well
lincat Digits = {s:Str ; size : NumSize} ;
lincat Decimal = {s:Str ; size : NumSize ; hasDot : Bool} ;
}

View File

@@ -96,6 +96,7 @@ lin
NumCard c = c ;
NumDigits ds = ds ** {s = \\_,_ => ds.s} ;
NumDecimal ds = ds ** {s = \\_,_ => ds.s} ;
NumNumeral nu = nu ;

View File

@@ -1,6 +1,6 @@
concrete NumeralCze of Numeral =
CatCze [Numeral,Digits] **
CatCze [Numeral,Digits,Decimal] **
open
ResCze,
@@ -117,4 +117,18 @@ oper determinerStr : Determiner -> Str = \d -> d.s ! Masc Anim ! Nom ;
D_8 = { s = "8" ; size = Num5} ;
D_9 = { s = "9" ; size = Num5} ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = "-" ++ Predef.BIND ++ d.s ;
size = Num5 ;
hasDot=False
} ;
IFrac d i = {
s = d.s ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ;
size = Num5 ;
hasDot=True
} ;
}