summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Parsing/FCFG.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2008-05-29 10:55:34 +0000
committerkrasimir <krasimir@chalmers.se>2008-05-29 10:55:34 +0000
commit64d3a1226da712bcf3c2744bcc141ebd40acac27 (patch)
tree3427929509359f7ea1cf9c3e7f13a7b3a9fecf8c /src-3.0/GF/Parsing/FCFG.hs
parent45e1eedff34f11a1e267d1e8923c12a33c7a217a (diff)
simplify the Profile type and remove the NameProfile type
Diffstat (limited to 'src-3.0/GF/Parsing/FCFG.hs')
-rw-r--r--src-3.0/GF/Parsing/FCFG.hs32
1 files changed, 8 insertions, 24 deletions
diff --git a/src-3.0/GF/Parsing/FCFG.hs b/src-3.0/GF/Parsing/FCFG.hs
index 30a7801c8..b279caf48 100644
--- a/src-3.0/GF/Parsing/FCFG.hs
+++ b/src-3.0/GF/Parsing/FCFG.hs
@@ -46,7 +46,7 @@ parseFCF strategy pinfo startCat inString =
let chart = fcfParser pinfo startCats inTokens
(i,j) = inputBounds inTokens
finalEdges = [makeFinalEdge cat i j | cat <- startCats]
- forests = map cnv_forests $ chart2forests chart (const False) finalEdges
+ forests = chart2forests chart (const False) finalEdges
filteredForests = forests >>= applyProfileToForest
trees = nubsort $ filteredForests >>= forest2trees
return $ map tree2term trees
@@ -56,22 +56,6 @@ parseFCF strategy pinfo startCat inString =
parseFCF "topdown" = Ok $ Active.parse "t"
parseFCF strat = Bad $ "FCFG parsing strategy not defined: " ++ strat
-
-cnv_forests FMeta = FMeta
-cnv_forests (FNode (Name (CId n) p) fss) = FNode (Name (CId n) (map cnv_profile p)) (map (map cnv_forests) fss)
-cnv_forests (FString x) = FString x
-cnv_forests (FInt x) = FInt x
-cnv_forests (FFloat x) = FFloat x
-
-cnv_profile (Unify x) = Unify x
-cnv_profile (Constant x) = Constant (cnv_forests2 x)
-
-cnv_forests2 FMeta = FMeta
-cnv_forests2 (FNode (CId n) fss) = FNode (CId n) (map (map cnv_forests2) fss)
-cnv_forests2 (FString x) = FString x
-cnv_forests2 (FInt x) = FInt x
-cnv_forests2 (FFloat x) = FFloat x
-
----------------------------------------------------------------------
-- parse trees to GFCC terms
@@ -87,13 +71,13 @@ tree2term (TMeta) = exp0
-- conversion and unification of forests
-- simplest implementation
-applyProfileToForest :: SyntaxForest FName -> [SyntaxForest CId]
-applyProfileToForest (FNode name@(Name fun profile) children)
- | isCoercionF name = concat chForests
- | otherwise = [ FNode fun chForests | not (null chForests) ]
- where chForests = concat [ applyProfileM unifyManyForests profile forests |
- forests0 <- children,
- forests <- mapM applyProfileToForest forests0 ]
+applyProfileToForest :: SyntaxForest (CId,[Profile]) -> [SyntaxForest CId]
+applyProfileToForest (FNode (fun,profiles) children)
+ | fun == wildCId = concat chForests
+ | otherwise = [ FNode fun chForests | not (null chForests) ]
+ where chForests = concat [ mapM (unifyManyForests . map (forests !!)) profiles |
+ forests0 <- children,
+ forests <- mapM applyProfileToForest forests0 ]
applyProfileToForest (FString s) = [FString s]
applyProfileToForest (FInt n) = [FInt n]
applyProfileToForest (FFloat f) = [FFloat f]