mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-06-16 10:30:11 -06:00
The new Decimal API
This commit is contained in:
@@ -80,6 +80,7 @@ concrete CatMay of Cat = CommonX - [IAdv] ** open ResMay, Prelude in {
|
||||
Card = ResMay.CardNum ;
|
||||
Numeral = ResMay.CardOrdNum ;
|
||||
Digits = ResMay.DigNum ;
|
||||
Decimal = ResMay.DigNum**{hasDot : Bool} ;
|
||||
|
||||
|
||||
|
||||
@@ -132,4 +133,4 @@ concrete CatMay of Cat = CommonX - [IAdv] ** open ResMay, Prelude in {
|
||||
-- Determiner : Type = Quant ** {
|
||||
-- pr : Str ; -- prefix for numbers
|
||||
-- n : NumType ; -- number as in 5 (noun in singular), Sg or Pl
|
||||
-- } ;
|
||||
-- } ;
|
||||
|
||||
@@ -101,6 +101,10 @@ concrete NounMay of Noun = CatMay ** open ResMay, Prelude in {
|
||||
s = dig.s ! NCard
|
||||
} ;
|
||||
|
||||
NumDecimal dec = {
|
||||
s = dec.s ! NCard
|
||||
} ;
|
||||
|
||||
-- : Numeral -> Card ;
|
||||
NumNumeral num = num ;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- David Wahlstedt 2002 (cardinal numbers)
|
||||
-- Inari Listenmaa 2020 (ordinals + cosmetic changes)
|
||||
concrete NumeralMay of Numeral = CatMay [Numeral,Digits] **
|
||||
concrete NumeralMay of Numeral = CatMay [Numeral,Digits,Decimal] **
|
||||
open Prelude, ResMay in {
|
||||
|
||||
lincat
|
||||
@@ -151,6 +151,16 @@ oper
|
||||
D_8 = mkDig "8" ;
|
||||
D_9 = mkDig "9" ;
|
||||
|
||||
PosDecimal d = d ** {hasDot=False} ;
|
||||
NegDecimal d = {s=\\o=>"-" ++ BIND ++ d.s ! o; hasDot=False} ;
|
||||
IFrac d i = {
|
||||
s=\\o=>d.s ! NCard ++
|
||||
if_then_Str d.hasDot BIND (BIND++"."++BIND) ++
|
||||
i.s ! o ;
|
||||
hasDot=True;
|
||||
n = Pl
|
||||
} ;
|
||||
|
||||
oper
|
||||
mkDig : Str -> DigNum = \s -> {
|
||||
s = table {
|
||||
|
||||
Reference in New Issue
Block a user