1
0
forked from GitHub/gf-rgl

get some basic numerals working

This commit is contained in:
Herbert Lange
2019-06-15 19:04:36 +02:00
parent abb3f4d60f
commit 9772134edc

View File

@@ -8,41 +8,42 @@ concrete NumeralLat of Numeral = CatLat ** open ResLat,ParadigmsLat,Prelude in {
lin lin
num x = x ; num x = x ;
-- n2 = lin Digit ( mkDigit "duo" "viginti" "ducenti" "secundus" ) ; n2 = lin Digit ( mkDigit "duo" "viginti" "ducenti" "secundus" ) ;
-- n3 = lin Numeral ( mkNum "tres" "triginta" "trecenti" "tertius" ) ; n3 = lin Digit ( mkDigit "tres" "triginta" "trecenti" "tertius" ) ;
-- n4 = lin Numeral ( mkNum "quattuor" "quadraginta" "quadringenti" "quartus" ) ; n4 = lin Digit ( mkDigit "quattuor" "quadraginta" "quadringenti" "quartus" ) ;
-- n5 = lin Numeral ( mkNum "quinque" "quinquaginta" "quingenti" "quintus" ) ; n5 = lin Digit ( mkDigit "quinque" "quinquaginta" "quingenti" "quintus" ) ;
-- n6 = lin Numeral ( mkNum "sex" "sexaginta" "sescenti" "sextus" ) ; n6 = lin Digit ( mkDigit "sex" "sexaginta" "sescenti" "sextus" ) ;
-- n7 = lin Numeral ( mkNum "septem" "septuaginta" "septingenti" "septimus" ) ; n7 = lin Digit ( mkDigit "septem" "septuaginta" "septingenti" "septimus" ) ;
-- n8 = lin Numeral ( mkNum "octo" "octoginta" "octingenti" "ocatvus" ) ; n8 = lin Digit ( mkDigit "octo" "octoginta" "octingenti" "ocatvus" ) ;
-- n9 = lin Numeral ( mkNum "novem" "nonaginta" "nongenti" "nonus") ; n9 = lin Digit ( mkDigit "novem" "nonaginta" "nongenti" "nonus") ;
-- -- 1 -- 1
-- pot01 = pot01 = { s = n1.s ! one ; n = Sg } ;
-- -- d * 1 -- d * 1
-- pot0 d = d ; pot0 d = { s = d.s ! one ; n = Pl } ;
-- -- 10 -- 10
-- pot110 = pot01 ; pot110 = { s = n1.s ! ten ; n = Sg } ;
-- -- 11 -- 11
-- -- pot111 = pot1to19 pot01 ; -- pot111 = pot1to19 pot01 ;
-- -- 10 + d -- -- 10 + d
-- -- pot1to19 d = mkNum "" "" "" "" ; -- {s = d.s ! teen} ** {n = Pl} ; -- -- pot1to19 d = mkNum "" "" "" "" ; -- {s = d.s ! teen} ** {n = Pl} ;
-- -- coercion of 1..9 -- coercion of 1..9
-- pot0as1 n = n ; pot0as1 n = n ;
-- -- d * 10 -- d * 10
-- --lin pot1 d = {s = d.s ! ten} ** {n = Pl} ; pot1 d = {s = d.s ! ten ; n = Pl} ;
-- -- d * 10 + n -- d * 10 + n
-- --lin pot1plus d e = { -- pot1plus d e = {
-- -- s = \\c => d.s ! ten ! NCard ++ "-" ++ e.s ! unit ! c ; n = Pl} ; -- s = \\c => d.s ! ten ++ "-" ++ e.s ! one ! c ;
-- -- coercion of 1..99 -- n = Pl} ;
-- pot1as2 n = n ; -- coercion of 1..99
-- -- m * 100 pot1as2 n = n ;
-- --lin pot2 d = {s = \\c => d.s ! unit ! NCard ++ mkCard c "hundred"} ** {n = Pl} ; -- m * 100
-- pot2 d = {s = d.s ! hundred ; n = Pl} ;
-- -- m * 100 + n -- -- m * 100 + n
-- --lin pot2plus d e = { -- --lin pot2plus d e = {
-- -- s = \\c => d.s ! unit ! NCard ++ "hundred" ++ "and" ++ e.s ! c ; n = Pl} ; -- -- s = \\c => d.s ! unit ! NCard ++ "hundred" ++ "and" ++ e.s ! c ; n = Pl} ;
-- -- coercion of 1..999 -- coercion of 1..999
-- pot2as3 n = n ; pot2as3 n = n ;
-- -- m * 1000 -- -- m * 1000
-- --lin pot3 n = { -- --lin pot3 n = {
-- -- s = \\c => n.s ! NCard ++ mkCard c "thousand" ; n = Pl} ; -- -- s = \\c => n.s ! NCard ++ mkCard c "thousand" ; n = Pl} ;
@@ -56,10 +57,11 @@ concrete NumeralLat of Numeral = CatLat ** open ResLat,ParadigmsLat,Prelude in {
mkDigit : (ones, tens, hundreds, ord : Str) -> TDigit = mkDigit : (ones, tens, hundreds, ord : Str) -> TDigit =
\ones, tens, hundreds, ord -> \ones, tens, hundreds, ord ->
case <tens,hundreds> of { case <tens,hundreds> of {
-- <"decem",_> => fullDigit ones tens hundreds ord "decimus" "centesimus" ; <"decem",_> => fullDigit ones tens hundreds ord "decimus" "centesimus" ;
-- <"viginta",_> => fullDigit ones tens hundreds ord "vicesimus" "ducentesimus" ; <"viginti",_> => fullDigit ones tens hundreds ord "vicesimus" "ducentesimus" ;
-- <"triginta",_> => fullDigit ones tens hundreds ord "tricesimus" "trecentesimus" ; <"triginta",_> => fullDigit ones tens hundreds ord "tricesimus" "trecentesimus" ;
<quadra + "ginta",quadringent + "i"> => fullDigit ones tens hundreds ord (quadra + "gesimus") (quadringent + "esimus") <quadra + "ginta",quadringent + "i"> => fullDigit ones tens hundreds ord (quadra + "gesimus") (quadringent + "esimus") ;
_ => Predef.error "Invalid number"
} ; } ;
fullDigit : (ones, tens, hundreds, ord1,ord10,ord100 : Str) -> TDigit = fullDigit : (ones, tens, hundreds, ord1,ord10,ord100 : Str) -> TDigit =
\ones, tens, hundreds, ord1,ord10,ord100 -> \ones, tens, hundreds, ord1,ord10,ord100 ->