mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-22 17:56:21 -06:00
The new Decimal API
This commit is contained in:
@@ -57,6 +57,7 @@ concrete CatChi of Cat = CommonX - [Tense, Temp, Ant, Adv] ** open ResChi, Prelu
|
||||
|
||||
Numeral = {s,p : Str} ;
|
||||
Card, Digits = {s : Str} ;
|
||||
Decimal = {s : Str ; hasDot : Bool} ;
|
||||
|
||||
-- Structural
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ concrete NounChi of Noun = CatChi ** open ResChi, Prelude in {
|
||||
|
||||
NumCard n = n ** {numType = NTFull} ;
|
||||
NumDigits d = d ** {numType = NTFull} ;
|
||||
NumDecimal d = d ** {numType = NTFull} ;
|
||||
OrdDigits d = {s = ordinal_s ++ d.s} ;
|
||||
|
||||
NumNumeral numeral = {s = numeral.p} ; -- liang instead of yi
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralChi of Numeral = CatChi [Numeral,Digits] ** open ResChi, Prelude in {
|
||||
concrete NumeralChi of Numeral = CatChi [Numeral,Digits,Decimal] ** open ResChi, Prelude in {
|
||||
|
||||
flags coding = utf8 ;
|
||||
|
||||
@@ -162,4 +162,16 @@ lin pot4as5 n = n ;
|
||||
D_8 = ss "8" ;
|
||||
D_9 = ss "9" ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = "-" ++ BIND ++ d.s ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s=d.s ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
@@ -160,4 +160,16 @@ lin pot3plus n m =
|
||||
D_8 = ss "8" ;
|
||||
D_9 = ss "9" ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = "-" ++ BIND ++ d.s ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s=d.s ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user