forked from GitHub/gf-rgl
The new Decimal API
This commit is contained in:
@@ -81,6 +81,7 @@ concrete CatEng of Cat = CommonX - [Pol,CAdv] ** open ResEng, Prelude in {
|
||||
|
||||
Numeral = {s : Bool => CardOrd => Case => Str ; n : Number} ;
|
||||
Digits = {s : CardOrd => Case => Str ; n : Number ; tail : DTail} ;
|
||||
Decimal = {s : CardOrd => Case => Str ; n : Number ; hasDot : Bool} ;
|
||||
|
||||
-- Structural
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
--# -path=.:../abstract:../common
|
||||
concrete DocumentationEng of Documentation = CatEng ** open
|
||||
ResEng, Prelude,
|
||||
ResEng,
|
||||
Prelude,
|
||||
HTML in {
|
||||
|
||||
lincat
|
||||
|
||||
@@ -77,7 +77,7 @@ concrete NounEng of Noun = CatEng ** open MorphoEng, ResEng, Prelude in {
|
||||
NumDigits n = {s,sp = \\_ => n.s ! NCard ; n = n.n} ;
|
||||
OrdDigits n = {s = n.s ! NOrd} ;
|
||||
|
||||
NumFloat n1 n2 = {s,sp = \\_,c => n1.s ! NCard ! Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard ! c ; n = Pl} ;
|
||||
NumDecimal d = {s,sp = \\_ => d.s ! NCard ; n = d.n} ;
|
||||
|
||||
NumNumeral numeral = {s,sp = \\d => numeral.s ! d ! NCard; n = numeral.n} ;
|
||||
OrdNumeral numeral = {s = numeral.s ! True ! NOrd} ;
|
||||
@@ -181,9 +181,4 @@ concrete NounEng of Noun = CatEng ** open MorphoEng, ResEng, Prelude in {
|
||||
a = agrgP3 n.n Neutr
|
||||
} ;
|
||||
|
||||
QuantityFloatNP n1 n2 m = {
|
||||
s = \\c => preOrPost m.isPre m.s (n1.s ! NCard ! Nom ++ BIND ++ "." ++ BIND ++ n2.s ! NCard ! Nom) ;
|
||||
a = agrgP3 Pl Neutr
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralEng of Numeral = CatEng [Numeral,Digits] ** open Prelude, ResEng in {
|
||||
concrete NumeralEng of Numeral = CatEng [Numeral,Digits,Decimal] ** open Prelude, ResEng in {
|
||||
|
||||
lincat
|
||||
Digit = {s : DForm => CardOrd => Case => Str} ;
|
||||
@@ -57,8 +57,8 @@ lin pot3 n = {
|
||||
lin pot3plus n m = {
|
||||
s = \\d,o,c => n.s ! d ! NCard ! Nom ++ "thousand" ++ m.s ! False ! o ! c; n = Pl} ;
|
||||
lin pot3as4 n = n ;
|
||||
lin pot3float f = {
|
||||
s = \\d,o,c => f.s ++ mkCard o "thousand" ! c ; n = Pl} ;
|
||||
lin pot3decimal f = {
|
||||
s = \\d,o,c => f.s ! NCard ! Nom ++ mkCard o "thousand" ! c ; n = Pl} ;
|
||||
|
||||
lin pot41 = {
|
||||
s = \\d,o,c => case d of {True => []; False => "a"} ++
|
||||
@@ -74,8 +74,8 @@ lin pot4plus n1 n2 = {
|
||||
n = Pl
|
||||
} ;
|
||||
lin pot4as5 n = n ;
|
||||
lin pot4float f = {
|
||||
s = \\d,o,c => f.s ++ pot41.s ! True ! o ! c ; n = Pl} ;
|
||||
lin pot4decimal f = {
|
||||
s = \\d,o,c => f.s ! NCard ! Nom ++ pot41.s ! True ! o ! c ; n = Pl} ;
|
||||
|
||||
lin pot51 = {
|
||||
s = \\d,o,c => case d of {True => []; False => "a"} ++
|
||||
@@ -90,8 +90,8 @@ lin pot5plus n1 n2 = {
|
||||
s = \\d,o,c => n1.s ! d ! NCard ! Nom ++ pot51.s ! True ! NCard ! Nom ++ "and" ++ n2.s ! True ! o ! c;
|
||||
n = Pl
|
||||
} ;
|
||||
lin pot5float f = {
|
||||
s = \\d,o,c => f.s ++ pot51.s ! True ! o ! c ; n = Pl} ;
|
||||
lin pot5decimal f = {
|
||||
s = \\d,o,c => f.s ! NCard ! Nom ++ pot51.s ! True ! o ! c ; n = Pl} ;
|
||||
|
||||
-- numerals as sequences of digits
|
||||
|
||||
@@ -118,6 +118,16 @@ lin pot5float f = {
|
||||
D_8 = mkDig "8" ;
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
lin PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {s=\\o,c=>"-" ++ BIND ++ d.s ! o ! c; hasDot=False; n = Pl} ;
|
||||
IFrac d i = {
|
||||
s=\\o,c=>d.s ! NCard ! Nom ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o ! c ;
|
||||
hasDot=True;
|
||||
n = Pl
|
||||
} ;
|
||||
|
||||
oper
|
||||
commaIf : DTail -> Str = \t -> case t of {
|
||||
T3 => BIND ++ "," ++ BIND ;
|
||||
|
||||
Reference in New Issue
Block a user