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

@@ -90,6 +90,7 @@ lincat
} ;
Numeral = {s : Res.CardOrd=>Res.Agreement=> Str ; g : Res.Gender; n: Res.Number} ;
Digits = {s : Res.CardOrd => Res.Agreement=>Str ; n : Res.Number ; tail : Px.DTail} ;
Decimal = {s : Res.CardOrd => Res.Agreement=>Str ; n : Res.Number; hasDot : Bool} ;
Ord = {s :Res.Agreement=>Str; position:Res.Position} ;
Card = {s :Res.Agreement=>Str; n : Res.Number} ;
A2 = Res.Adjective ** { c2 : Str ; isPre : Bool} ;

View File

@@ -116,6 +116,7 @@ lin
--NumDigits : Digits -> Card ; -- 51
NumDigits dig = {s = dig.s!NCard ; n=dig.n};
NumDecimal dec = {s = dec.s!NCard ; n=dec.n};
--NumNumeral : Numeral -> Card ; -- fifty-one
NumNumeral numeral = {s=numeral.s!NCard; n=numeral.n};
--OrdDigits : Digits -> Ord ; -- 51st

View File

@@ -1,6 +1,6 @@
--# -path=.:../prelude:../abstract:../common
concrete NumeralCgg of Numeral = CatCgg [Numeral,Digits] **
concrete NumeralCgg of Numeral = CatCgg [Numeral,Digits,Decimal] **
open ResCgg, Prelude in {
lincat
@@ -100,6 +100,16 @@ lin pot3plus n m = let
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o,a=>"-" ++ BIND ++ d.s ! o ! a; hasDot=False; n = Pl} ;
IFrac d i = {
s=\\o,a=>d.s ! NCard ! a ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ! a ;
hasDot=True;
n = Pl
} ;
oper
commaIf : DTail -> Str = \t -> case t of {
T3 => BIND ++ "," ++ BIND ;