diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-09-22 11:49:15 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-09-22 11:49:15 +0000 |
| commit | 98665df78b8018af30051cb4a9a31f845e0ba19d (patch) | |
| tree | 67ba30b09e2b9590a00a4b193bf7611caa935af8 /next-lib/src/abstract/Numeral.gf | |
| parent | 4862018f140a1bdcc7961d445ed9aa92facd742f (diff) | |
moved lib/next-resource to next-lib/src, to enable linking with next-lib as value of GF_LIB_PATH
Diffstat (limited to 'next-lib/src/abstract/Numeral.gf')
| -rw-r--r-- | next-lib/src/abstract/Numeral.gf | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/next-lib/src/abstract/Numeral.gf b/next-lib/src/abstract/Numeral.gf new file mode 100644 index 000000000..43c6f8111 --- /dev/null +++ b/next-lib/src/abstract/Numeral.gf @@ -0,0 +1,60 @@ +--1 Numerals + +-- This grammar defines numerals from 1 to 999999. +-- The implementations are adapted from the +-- [numerals library http://www.cs.chalmers.se/~aarne/GF/examples/numerals/] +-- which defines numerals for 88 languages. +-- The resource grammar implementations add to this inflection (if needed) +-- and ordinal numbers. +-- +-- *Note* 1. Number 1 as defined +-- in the category $Numeral$ here should not be used in the formation of +-- noun phrases, and should therefore be removed. Instead, one should use +-- [Structural Structural.html]$.one_Quant$. This makes the grammar simpler +-- because we can assume that numbers form plural noun phrases. +-- +-- *Note* 2. The implementations introduce spaces between +-- parts of a numeral, which is often incorrect - more work on +-- (un)lexing is needed to solve this problem. + +abstract Numeral = Cat ** { + +cat + Digit ; -- 2..9 + Sub10 ; -- 1..9 + Sub100 ; -- 1..99 + Sub1000 ; -- 1..999 + Sub1000000 ; -- 1..999999 + +fun + num : Sub1000000 -> Numeral ; + + n2, n3, n4, n5, n6, n7, n8, n9 : Digit ; + + pot01 : Sub10 ; -- 1 + pot0 : Digit -> Sub10 ; -- d * 1 + pot110 : Sub100 ; -- 10 + pot111 : Sub100 ; -- 11 + pot1to19 : Digit -> Sub100 ; -- 10 + d + pot0as1 : Sub10 -> Sub100 ; -- coercion of 1..9 + pot1 : Digit -> Sub100 ; -- d * 10 + pot1plus : Digit -> Sub10 -> Sub100 ; -- d * 10 + n + pot1as2 : Sub100 -> Sub1000 ; -- coercion of 1..99 + pot2 : Sub10 -> Sub1000 ; -- m * 100 + pot2plus : Sub10 -> Sub100 -> Sub1000 ; -- m * 100 + n + pot2as3 : Sub1000 -> Sub1000000 ; -- coercion of 1..999 + pot3 : Sub1000 -> Sub1000000 ; -- m * 1000 + pot3plus : Sub1000 -> Sub1000 -> Sub1000000 ; -- m * 1000 + n + +-- Numerals as sequences of digits have a separate, simpler grammar + + cat + Dig ; -- single digit 0..9 + + fun + IDig : Dig -> Digits ; -- 8 + IIDig : Dig -> Digits -> Digits ; -- 876 + + D_0, D_1, D_2, D_3, D_4, D_5, D_6, D_7, D_8, D_9 : Dig ; + +} |
