The new Decimal API

This commit is contained in:
Krasimir Angelov
2023-08-21 20:14:26 +02:00
parent 58da8deca8
commit fb398c603e
147 changed files with 918 additions and 188 deletions

View File

@@ -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

View File

@@ -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 ;

View File

@@ -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