mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-26 11:36:27 -06:00
The new Decimal API
This commit is contained in:
@@ -68,6 +68,8 @@ concrete CatGre of Cat = CommonGre ** open ResGre, Prelude in {
|
||||
Numeral = {s : CardOrd => Str ; n : Number } ;
|
||||
|
||||
Digits = {s : CardOrd => Str ; n : Number} ;
|
||||
|
||||
Decimal = {s : CardOrd => Str ; n : Number ; hasDot : Bool} ;
|
||||
|
||||
-- Structural
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ concrete NounGre of Noun = CatGre ** open ResGre, ParadigmsGre, Prelude in {
|
||||
NumNumeral numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
|
||||
|
||||
NumDigits numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
|
||||
NumDecimal numeral = {s = \\g,c => numeral.s ! NCard g c; n = numeral.n } ;
|
||||
|
||||
AdNum adn num = {s = \\g,c => adn.s ++ num.s!g!c; n = num.n } ;
|
||||
|
||||
@@ -244,4 +245,4 @@ concrete NounGre of Noun = CatGre ** open ResGre, ParadigmsGre, Prelude in {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+15
-1
@@ -1,4 +1,4 @@
|
||||
concrete NumeralGre of Numeral = CatGre [Numeral,Digits] ** open ResGre,Prelude in {
|
||||
concrete NumeralGre of Numeral = CatGre [Numeral,Digits,Decimal] ** open ResGre,Prelude in {
|
||||
|
||||
flags coding= utf8 ;
|
||||
|
||||
@@ -291,6 +291,20 @@ Xilias : CardOrd -> (CardOrd => Str) -> Number -> Str = \co,d,n ->
|
||||
D_8 = mk2Dig "8" Pl;
|
||||
D_9 = mk2Dig "9" Pl ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = \\o => "-" ++ BIND ++ d.s ! o ;
|
||||
n = Pl ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s = \\o => d.s ! NCard Neut Nom ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o ;
|
||||
n = Pl ;
|
||||
hasDot=False
|
||||
} ;
|
||||
|
||||
oper
|
||||
|
||||
mk3Dig : Str -> Number -> TDigit = \c,n -> {
|
||||
|
||||
Reference in New Issue
Block a user