1
0
forked from GitHub/gf-rgl

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

@@ -88,6 +88,7 @@ concrete CatGer 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

@@ -117,7 +117,7 @@ concrete NounGer of Noun = CatGer ** open ResGer, MorphoGer, Prelude in {
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
OrdDigits numeral = {s = \\af => numeral.s ! NOrd af} ;
NumFloat dig1 dig2 = {s = \\g,c => dig1.s ! invNum ++ BIND ++ "." ++ BIND ++ dig2.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 = \\af => numeral.s ! NOrd af} ;
@@ -262,12 +262,4 @@ concrete NounGer of Noun = CatGer ** open ResGer, MorphoGer, Prelude in {
ext = "" ;
} ;
QuantityFloatNP dig1 dig2 m = {
s = \\_,c => preOrPost m.isPre m.s (dig1.s ! invNum ++ BIND ++ "." ++ BIND ++ dig2.s ! invNum) ;
a = agrP3 Pl ;
w = WLight ;
rc = "" ;
ext = "" ;
} ;
}

View File

@@ -1,4 +1,4 @@
concrete NumeralGer of Numeral = CatGer [Numeral,Digits] ** open MorphoGer, Prelude in {
concrete NumeralGer of Numeral = CatGer [Numeral,Digits,Decimal] ** open MorphoGer, Prelude in {
flags optimize = all_subs ;
coding=utf8 ;
@@ -50,12 +50,12 @@ lin
pot3plus n m = {s = \\g =>
multiple n.s n.n ++ "tausend" ++ m.s ! g ; n = Pl} ;
pot3as4 n = n ;
pot3float f = {s = \\g =>
f.s ++ cardOrd "tausend" "tausendte" ! g ; n = Pl} ; ----
pot3decimal d = {s = \\g =>
d.s ! invNum ++ cardOrd "tausend" "tausendte" ! g ; n = Pl} ; ----
pot4as5 n = n ;
pot4float f = {s = \\g =>
f.s ++ cardOrd "Millionen" "Millionte" ! g ; n = Pl} ; ----
pot4decimal d = {s = \\g =>
d.s ! invNum ++ cardOrd "Millionen" "Millionte" ! g ; n = Pl} ; ----
pot51 = {s = \\g => "einer Milliarde"; n = Pl} ; -- KA: case inflection missing
@@ -88,6 +88,20 @@ oper
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") ;