mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-24 02:31:10 -06:00
The new Decimal API
This commit is contained in:
@@ -67,6 +67,8 @@ concrete CatAra of Cat = CommonX - [Utt] ** open ResAra, Prelude, ParamX in {
|
||||
n : Size } ;
|
||||
Digits = {s : Str;
|
||||
n : Size};
|
||||
Decimal = {s : Str;
|
||||
n : Size; hasDot : Bool};
|
||||
|
||||
-- Structural
|
||||
|
||||
|
||||
@@ -130,6 +130,10 @@ lin
|
||||
s = \\_,_,_ => digits.s ;
|
||||
isNum = True
|
||||
};
|
||||
NumDecimal dec = dec ** {
|
||||
s = \\_,_,_ => dec.s ;
|
||||
isNum = True
|
||||
};
|
||||
|
||||
NumNumeral numeral = numeral ** {
|
||||
s = numeral.s ! NCard ;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
concrete NumeralAra of Numeral = CatAra [Numeral,Digits] **
|
||||
concrete NumeralAra of Numeral = CatAra [Numeral,Digits,Decimal] **
|
||||
open Predef, Prelude, ResAra, MorphoAra in {
|
||||
|
||||
flags coding=utf8 ;
|
||||
@@ -136,6 +136,20 @@ lincat
|
||||
D_8 = mk1Dig "8" ;
|
||||
D_9 = mk1Dig "9" ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {
|
||||
s = "-" ++ BIND ++ d.s;
|
||||
n = ThreeTen ;
|
||||
hasDot=False
|
||||
} ;
|
||||
IFrac d i = {
|
||||
s = d.s ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ;
|
||||
n = ThreeTen ;
|
||||
hasDot=True
|
||||
} ;
|
||||
|
||||
oper
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user