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

@@ -59,6 +59,7 @@ concrete CatDut of Cat =
Numeral = {s : CardOrd => Str ; n : Number } ;
Digits = {s : CardOrd => Str ; n : Number } ;
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
-- Structural

View File

@@ -85,7 +85,7 @@ concrete NounDut of Noun = CatDut ** open ResDut, Prelude in {
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdDigits numeral = {s = \\af => numeral.s ! NOrd af} ;
NumFloat n1 n2 = {s = \\g,c => n1.s ! NCard Utr Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard g c; n = Pl } ;
NumDecimal numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdNumeral numeral = {s = let tiende : AForm => Str = \\af => numeral.s ! NOrd af
@@ -207,10 +207,4 @@ concrete NounDut of Noun = CatDut ** open ResDut, Prelude in {
isPron = False
} ;
QuantityFloatNP n1 n2 m = noMerge ** {
s = \\role => preOrPost m.isPre m.s (n1.s ! NCard Utr Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard Utr Nom) ;
a = agrP3 Pl ;
isPron = False
} ;
}

View File

@@ -1,4 +1,4 @@
concrete NumeralDut of Numeral = CatDut [Numeral,Digits] ** open ResDut, Prelude in {
concrete NumeralDut of Numeral = CatDut [Numeral,Digits,Decimal] ** open ResDut, Prelude in {
flags optimize = all_subs ;
coding=utf8 ;
@@ -74,6 +74,20 @@ lin
D_8 = mkDig "8" ;
D_9 = mkDig "9" ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {
s = \\o => "-" ++ BIND ++ d.s ! o ;
n = Pl ;
hasDot=False
} ;
IFrac d i = {
s = \\o => d.s ! invNum ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o ;
n = Pl ;
hasDot=True
} ;
oper
mk2Dig : Str -> Str -> TDigit = \c,o -> mk3Dig c o Pl ;
mkDig : Str -> TDigit = \c -> mk2Dig c (c + "e") ;