1
0
forked from GitHub/gf-core

the lincat of Int simplified to SS again (Linear,Lookup,CheckGrammar by commenting out)

This commit is contained in:
aarne
2007-10-21 10:01:14 +00:00
parent 16f3df2311
commit 01bc4c138e
4 changed files with 43 additions and 35 deletions

View File

@@ -1,20 +1,20 @@
--# -path=.:prelude:present incomplete concrete BaseI of Base =
open Syntax, (G = Grammar), Symbolic, LexBase in {
concrete BaseEng of Base = open Syntax, (G = Grammar), Symbolic, LexBase in {
flags lexer=literals ; unlexer=text ; flags lexer=literals ; unlexer=text ;
lincat lincat
Question = Phr ; Question = G.Phr ;
Answer = Phr ; Answer = G.Phr ;
S = Cl ; S = Cl ;
NP = NP ; NP = G.NP ;
PN = NP ; PN = G.NP ;
CN = CN ; CN = G.CN ;
AP = AP ; AP = G.AP ;
A2 = A2 ; A2 = G.A2 ;
Conj = Conj ; Conj = G.Conj ;
ListPN = ListNP ; ListPN = G.ListNP ;
lin lin
PredAP = mkCl ; PredAP = mkCl ;
@@ -34,33 +34,37 @@ lin
And = and_Conj ; And = and_Conj ;
Or = or_Conj ; Or = or_Conj ;
UseInt = symb ; UseInt i = symb i ;
Number = mkCN number_N ; Number = mkCN number_N ;
Even = mkAP even_A ; Even = mkAP even_A ;
Odd = mkAP odd_A ; Odd = mkAP odd_A ;
Prime = mkAP prime_A ; Prime = mkAP prime_A ;
Equal = mkA2 equal_A2 ; Equal = equal_A2 ;
Greater = mkA2 greater_A2 ; Greater = greater_A2 ;
Smaller = mkA2 smaller_A2 ; Smaller = smaller_A2 ;
Divisible = mkA2 divisible_A2 ; Divisible = divisible_A2 ;
Sum pns = mkNP defSgDet (mkCN sum_N2 (mkNP and_Conj pns)) ; Sum = prefix sum_N2 ;
--- Product = prefixSS ["the product of"] ; Product = prefix product_N2 ;
--- GCD = prefixSS ["the greatest common divisor of"] ; --- GCD = prefixSS ["the greatest common divisor of"] ;
--- WhatIs = prefixSS ["what is"] ; WhatIs np = mkPhr (mkQS (mkQCl whatSg_IP (mkVP np))) ;
--- WhichAre cn ap = ss ("which" ++ cn.s ++ "is" ++ ap.s) ; ---- are WhichAre cn ap = mkPhr (mkQS (mkQCl (mkIP whichPl_IDet cn) (mkVP ap))) ;
QuestS s = mkPhr (mkQCl s) ; QuestS s = mkPhr (mkQS (mkQCl s)) ;
Yes = yes_Phr ; Yes = yes_Phr ;
No = no_Phr ; No = no_Phr ;
Value np = mkPhr (mkUtt np) ; Value np = mkPhr (mkUtt np) ;
Many list = list ; Many list = mkNP and_Conj list ;
BasePN = G.BaseNP ; BasePN = G.BaseNP ;
ConsPN = G.ConsNP ; ConsPN = G.ConsNP ;
oper
prefix : G.N2 -> G.ListNP -> G.NP = \n2,nps ->
mkNP defSgDet (mkCN n2 (mkNP and_Conj nps)) ;
} }

View File

@@ -311,10 +311,10 @@ computeLType gr t = do
Q m c | elem c [cPredef,cPredefAbs] -> return ty Q m c | elem c [cPredef,cPredefAbs] -> return ty
Q m c | elem c [zIdent "Int"] -> Q m c | elem c [zIdent "Int"] ->
let ints k = App (Q (IC "Predef") (IC "Ints")) (EInt k) in return $ defLinType
return $ ---- let ints k = App (Q (IC "Predef") (IC "Ints")) (EInt k) in
RecType [ ---- RecType [
(LIdent "s", typeStr), (LIdent "last",ints 9),(LIdent "size",ints 1)] ---- (LIdent "last",ints 9),(LIdent "s", typeStr), (LIdent "size",ints 1)]
Q m c | elem c [zIdent "Float",zIdent "String"] -> return defLinType ---- Q m c | elem c [zIdent "Float",zIdent "String"] -> return defLinType ----
Q m ident -> checkIn ("module" +++ prt m) $ do Q m ident -> checkIn ("module" +++ prt m) $ do

View File

@@ -230,12 +230,14 @@ lookupAbsDef gr m c = errIn ("looking up absdef of" +++ prt c) $ do
lookupLincat :: SourceGrammar -> Ident -> Ident -> Err Type lookupLincat :: SourceGrammar -> Ident -> Ident -> Err Type
{- ----
lookupLincat gr m c | elem c [zIdent "Int"] = lookupLincat gr m c | elem c [zIdent "Int"] =
let ints k = App (Q (IC "Predef") (IC "Ints")) (EInt k) in let ints k = App (Q (IC "Predef") (IC "Ints")) (EInt k) in
return $ return $
RecType [ RecType [
(LIdent "s", typeStr), (LIdent "last",ints 9),(LIdent "size",ints 1)] (LIdent "last",ints 9),(LIdent "s", typeStr),(LIdent "size",ints 1)]
lookupLincat gr m c | elem c [zIdent "String", zIdent "Float"] = -}
lookupLincat gr m c | elem c [zIdent "String", zIdent "Float", zIdent "Int"] =
return defLinType --- ad hoc; not needed? return defLinType --- ad hoc; not needed?
lookupLincat gr m c = do lookupLincat gr m c = do

View File

@@ -80,9 +80,11 @@ linearizeToRecord gr mk m = lin [] where
recS t = R [Ass (L (identC "s")) t] ---- recS t = R [Ass (L (identC "s")) t] ----
recInt i = R [Ass (L (identC "s")) (tK $ show i), recInt i = R [
Ass (L (identC "last")) (EInt (rem i 10)), ----Ass (L (identC "last")) (EInt (rem i 10)),
Ass (L (identC "size")) (EInt (if i > 9 then 1 else 0))] Ass (L (identC "s")) (tK $ show i) ----,
----Ass (L (identC "size")) (EInt (if i > 9 then 1 else 0))
]
lookCat = return . errVal defLindef . look lookCat = return . errVal defLindef . look
---- should always be given in the module ---- should always be given in the module