mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-23 18:21:11 -06:00
The new Decimal API
This commit is contained in:
@@ -78,6 +78,7 @@ lincat
|
||||
Numeral = {s : CardOrd => Gender => Case => Str ; num : Number} ;
|
||||
|
||||
Digits = {s : CardOrd => Str ; num : Number} ;
|
||||
Decimal = {s : CardOrd => Str ; num : Number ; hasDot : Bool} ;
|
||||
|
||||
-- Structural words
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ lin
|
||||
-- Digits -> Card
|
||||
-- e.g. '51'
|
||||
NumDigits digits = { s = \\_,_ => digits.s ! NCard ; num = digits.num } ;
|
||||
NumDecimal dec = { s = \\_,_ => dec.s ! NCard ; num = dec.num } ;
|
||||
|
||||
-- Numeral -> Card
|
||||
-- e.g. 'fifty-one'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--# -path=.:abstract:common:prelude
|
||||
|
||||
concrete NumeralLav of Numeral = CatLav [Numeral,Digits] ** open ResLav, ParadigmsLav, Prelude in {
|
||||
concrete NumeralLav of Numeral = CatLav [Numeral,Digits,Decimal] ** open ResLav, ParadigmsLav, Prelude in {
|
||||
|
||||
flags coding = utf8 ;
|
||||
|
||||
@@ -109,6 +109,20 @@ lin
|
||||
D_8 = mkDig "8" ;
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = \\o => "-" ++ BIND ++ d.s ! o ;
|
||||
num = Pl ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s = \\o => d.s ! NCard ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o;
|
||||
num = Pl ;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
oper
|
||||
mkDig : Str -> Dig = \c -> mk2Dig c Pl ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user