mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-21 09:16:22 -06:00
The new Decimal API
This commit is contained in:
@@ -80,6 +80,7 @@ concrete CatRon of Cat =
|
||||
sp : ACase => CardOrd => NumF => Str ; size : Size } ;
|
||||
|
||||
Digits = {s : CardOrd => Str ; n : Size ; isDig : Bool} ;
|
||||
Decimal = {s : CardOrd => Str ; n : Size ; isDig : Bool; hasDot : Bool} ;
|
||||
|
||||
Num = {s : Gender => Str ; sp : Gender => Str ;
|
||||
isNum : Bool ; n : Number; size : Str } ;
|
||||
|
||||
@@ -172,8 +172,8 @@ in {
|
||||
isPre = True
|
||||
};
|
||||
|
||||
NumFloat n1 n2 = {s,sp = \\g => n1.s ! NCard g ++ BIND ++ "." ++ BIND ++ n2.s ! NCard g ;
|
||||
size = n1.n; n = Pl };
|
||||
NumDecimal nu = {s,sp = \\g => nu.s ! NCard g ;
|
||||
size = nu.n; n = getNumber nu.n };
|
||||
|
||||
NumNumeral nu = {s = \\g => nu.s ! ANomAcc ! (NCard g) ! Formal ;
|
||||
sp = \\g => nu.sp ! ANomAcc ! (NCard g) ! Formal ;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralRon of Numeral = CatRon [Numeral,Digits] **
|
||||
concrete NumeralRon of Numeral = CatRon [Numeral,Digits,Decimal] **
|
||||
open MorphoRon, CatRon, Prelude in {
|
||||
|
||||
flags coding = utf8 ;
|
||||
@@ -247,6 +247,21 @@ lin
|
||||
D_8 = mkDig "8" ;
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
lin PosDecimal d = d ** {hasDot=False} ;
|
||||
lin NegDecimal d = {
|
||||
s = \\o => "-" ++ BIND ++ d.s ! o ;
|
||||
n = pl;
|
||||
isDig = False ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s = \\o => d.s ! NCard Masc ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o ;
|
||||
n = pl ;
|
||||
isDig = False ;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
oper mkDig : Str -> Dig = \c -> mk3Dig c (c + "lea") (c + "a") less20 ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user