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
@@ -64,6 +64,7 @@ concrete CatBul of Cat = CommonX - [IAdv,AdV] ** open ResBul, Prelude, Predef, (
Numeral = {s : CardOrd => Str; n : Number} ;
Digits = {s : CardOrd => Str; n : Number; tail : DTail} ;
Decimal = {s : CardOrd => Str; n : Number; hasDot : Bool} ;
-- Structural
+1 -8
View File
@@ -116,10 +116,9 @@ concrete NounBul of Noun = CatBul ** open ResBul, Prelude in {
NumCard n = {s=n.s; nn=n.nn; nonEmpty = True} ;
NumDigits n = {s = \\gspec => n.s ! NCard gspec; nn = case n.n of {Sg => NNum Sg; Pl => NCountable}} ;
NumDecimal n = {s = \\gspec => n.s ! NCard gspec; nn = case n.n of {Sg => NNum Sg; Pl => NCountable}} ;
OrdDigits n = {s = \\aform => n.s ! NOrd aform} ;
NumFloat n1 n2 = {s = \\gspec => n1.s ! NCard (CFMasc Indef NonHuman) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard gspec ; nn = NCountable} ;
NumNumeral numeral = {s = \\gspec => numeral.s ! NCard gspec; nn = case numeral.n of {Sg => NNum Sg; Pl => NCountable}} ;
OrdNumeral numeral = {s = \\aform => numeral.s ! NOrd aform} ;
@@ -247,10 +246,4 @@ concrete NounBul of Noun = CatBul ** open ResBul, Prelude in {
p = NounP3 Pos
} ;
QuantityFloatNP n1 n2 m = {
s = \\role => preOrPost m.isPre m.s (n1.s ! NCard (CFMasc Indef NonHuman) ++ BIND ++ "." ++ BIND ++ n2.s ! NCard (CFMasc Indef NonHuman)) ;
gn = gennum (AMasc NonHuman) Pl ;
p = NounP3 Pos
} ;
}
+33 -7
View File
@@ -1,5 +1,5 @@
--# -coding=utf8
concrete NumeralBul of Numeral = CatBul [Numeral,Digits] ** open Prelude, ResBul in {
concrete NumeralBul of Numeral = CatBul [Numeral,Digits,Decimal] ** open Prelude, ResBul in {
flags coding=utf8 ;
@@ -97,8 +97,11 @@ lin pot3plus n m = {
n = Pl
} ;
lin pot3as4 n = n ;
lin pot3float f = {
s = \\c,nf => f.s ++ mkCardOrd100 "хиляди" "хилядите" "хиляден" ! c ;
lin pot3decimal d = {
s = \\c,nf => case d.n of {
Sg => mkCardOrd100 "хиляда" "хилядата" "хиляден" ! NCard (CFMasc Indef NonHuman) ;
Pl => d.s ! NCard (CFFem Indef) ++ mkCardOrd100 "хиляди" "хилядите" "хиляден" ! c
} ;
n = Pl
} ;
@@ -118,8 +121,17 @@ lin pot4plus n1 n2 = {
n = Pl
} ;
lin pot4as5 n = n ;
lin pot4float f = {
s = \\c,nf => f.s ++ mkCardOrd100 "милиона" "милиона" "милионен" ! c ;
lin pot4decimal d = {
s = \\c,nf => case c of {
NCard (CFMasc s a) => d.s ! NCard (CFMasc s NonHuman) ;
NCard (CFMascDefNom a) => d.s ! NCard (CFMascDefNom NonHuman) ;
NCard cf => d.s ! NCard cf ;
NOrd _ => d.s ! NCard (CFMasc Indef NonHuman)
} ++
case d.n of {
Sg => "милион" ;
Pl => "милиона"
} ;
n = Pl
} ;
@@ -138,8 +150,12 @@ lin pot5plus n1 n2 = {
s = \\o,f => (pot5 n1).s ! o ! f ++ "и" ++ n2.s ! o ! f;
n = Pl
} ;
lin pot5float f = {
s = \\c,nf => f.s ++ mkCardOrd100 "милиярда" "милиярда" "милиярден" ! c ;
lin pot5decimal d = {
s = \\c,nf => d.s ! NCard (CFFem Indef) ++
case d.n of {
Sg => mkCardOrd100 "милиярд" "милиярда" "милиярден" ! c ;
Pl => mkCardOrd100 "милиярди" "милиярдите" "милиярден" ! c
} ;
n = Pl
} ;
@@ -168,6 +184,16 @@ lin pot5float f = {
D_8 = mk3Dig "8" "8на" "8ми" Pl ;
D_9 = mk3Dig "9" "9има" "9ти" Pl ;
PosDecimal d = d ** {hasDot=False} ;
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False; n = Pl} ;
IFrac d i = {
s = \\o => d.s ! NCard (CFMasc Indef NonHuman) ++
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
i.s ! o;
n = Pl ;
hasDot=True
} ;
oper
spaceIf : DTail -> Str = \t -> case t of {
T3 => SOFT_BIND ;