summaryrefslogtreecommitdiff
path: root/src/GF/Grammar
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-06-20 08:38:44 +0000
committeraarne <aarne@cs.chalmers.se>2006-06-20 08:38:44 +0000
commit402a113b567a96eef61946552b68df6ac6eb6712 (patch)
tree6446bbaf195800c7e0ec71d30cba113c9bcf1f74 /src/GF/Grammar
parentcb168e92e23d0f620b75f6119a4cb298360e6f21 (diff)
made -fcfg default parser; added lexer textvars
Diffstat (limited to 'src/GF/Grammar')
-rw-r--r--src/GF/Grammar/LookAbs.hs5
-rw-r--r--src/GF/Grammar/Macros.hs4
2 files changed, 9 insertions, 0 deletions
diff --git a/src/GF/Grammar/LookAbs.hs b/src/GF/Grammar/LookAbs.hs
index 0c86ae3e9..5bd4c1e41 100644
--- a/src/GF/Grammar/LookAbs.hs
+++ b/src/GF/Grammar/LookAbs.hs
@@ -21,6 +21,7 @@ module GF.Grammar.LookAbs (GFCGrammar,
lookupRef,
refsForType,
funRulesOf,
+ hasHOAS,
allCatsOf,
allBindCatsOf,
funsForType,
@@ -130,6 +131,10 @@ funRulesOf gr =
mtype m == MTAbstract,
(f, C.AbsFun typ _) <- tree2list (jments m)]
+-- testing for higher-order abstract syntax
+hasHOAS :: GFCGrammar -> Bool
+hasHOAS gr = any isHigherOrderType [t | (_,t) <- funRulesOf gr] where
+
allCatsOf :: GFCGrammar -> [(Cat,Context)]
allCatsOf gr =
[((i,c),cont) | (i, ModMod m) <- modules gr,
diff --git a/src/GF/Grammar/Macros.hs b/src/GF/Grammar/Macros.hs
index e7d073382..a3cad8bae 100644
--- a/src/GF/Grammar/Macros.hs
+++ b/src/GF/Grammar/Macros.hs
@@ -136,6 +136,10 @@ isRecursiveType t = errVal False $ do
(cc,c) <- catSkeleton t -- thus recursivity on Cat level
return $ any (== c) cc
+isHigherOrderType :: Type -> Bool
+isHigherOrderType t = errVal True $ do -- pessimistic choice
+ co <- contextOfType t
+ return $ not $ null [x | (x,Prod _ _ _) <- co]
contextOfType :: Type -> Err Context
contextOfType typ = case typ of