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

@@ -93,6 +93,7 @@ abstract Cat = Common ** {
Numeral ; -- cardinal or ordinal in words e.g. "five/fifth"
Digits ; -- cardinal or ordinal in digits e.g. "1,000/1,000th"
Decimal ; -- decimal number e.g. "1/2/3.14/-1"
--2 Structural words

View File

@@ -58,7 +58,7 @@ abstract Noun = Cat ** {
data
NumDigits : Digits -> Card ; -- 51
NumFloat : Digits -> Digits -> Card ; -- 3.14
NumDecimal : Decimal -> Card ; -- 3.14, -1, etc
NumNumeral : Numeral -> Card ; -- fifty-one
-- The construction of numerals is defined in [Numeral Numeral.html].
@@ -158,7 +158,6 @@ abstract Noun = Cat ** {
--2 Quantities
QuantityNP : Digits -> MU -> NP ;
QuantityFloatNP : Digits -> Digits -> MU -> NP ;
QuantityNP : Decimal -> MU -> NP ;
}

View File

@@ -17,7 +17,7 @@
-- parts of a numeral, which is often incorrect - more work on
-- (un)lexing is needed to solve this problem.
abstract Numeral = Cat [Numeral,Digits] ** {
abstract Numeral = Cat [Numeral,Digits,Decimal] ** {
cat
Digit ; -- 2..9
@@ -53,18 +53,18 @@ data
pot3 : Sub1000 -> Sub1000000 ; -- m * 1000
pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n
pot3as4 : Sub1000000 -> Sub1000000000 ; -- coercion of 1..999999
pot3float : Float -> Sub1000000 ; -- 3.5 thousand
pot3decimal : Decimal -> Sub1000000 ; -- 3.5 thousand
pot41 : Sub1000000000 ; -- a million instead of one million
pot4 : Sub1000 -> Sub1000000000 ; -- m * 1000000000
pot4plus : Sub1000 -> Sub1000000 -> Sub1000000000 ; -- m * 1000000000 + n
pot4as5 : Sub1000000000 -> Sub1000000000000 ; -- coercion of 1..999999999
pot4float : Float -> Sub1000000000 ; -- 3.5 million
pot4decimal : Decimal -> Sub1000000000 ; -- 3.5 million
pot51 : Sub1000000000000 ; -- a billion instead of one billion
pot5 : Sub1000 -> Sub1000000000000 ; -- m * 1000000000
pot5plus : Sub1000 -> Sub1000000000 -> Sub1000000000000 ; -- m * 1000000000 + n
pot5float : Float -> Sub1000000000000 ; -- 3.5 billion
pot5decimal : Decimal -> Sub1000000000000 ; -- 3.5 billion
-- Numerals as sequences of digits have a separate, simpler grammar
@@ -77,4 +77,8 @@ data
D_0, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9 : Dig ;
PosDecimal : Digits -> Decimal ; -- 8
NegDecimal : Digits -> Decimal ; -- -8
IFrac : Decimal -> Dig -> Decimal ; -- 3.14 -> 3.141
}