summaryrefslogtreecommitdiff
path: root/src/GF/UseGrammar
diff options
context:
space:
mode:
authoraarne <unknown>2004-08-24 11:49:46 +0000
committeraarne <unknown>2004-08-24 11:49:46 +0000
commitc86192273657fe17d4dfe246f0d850379b9e5866 (patch)
tree0c388671f158d8be47582766939b9bdb59a92f15 /src/GF/UseGrammar
parentb57e3fff8c445bcc926c1018ac50a67e6417bf15 (diff)
some var parser bug fixes
Diffstat (limited to 'src/GF/UseGrammar')
-rw-r--r--src/GF/UseGrammar/Custom.hs1
-rw-r--r--src/GF/UseGrammar/Parsing.hs6
-rw-r--r--src/GF/UseGrammar/Tokenize.hs5
3 files changed, 11 insertions, 1 deletions
diff --git a/src/GF/UseGrammar/Custom.hs b/src/GF/UseGrammar/Custom.hs
index 035099acc..e7989de30 100644
--- a/src/GF/UseGrammar/Custom.hs
+++ b/src/GF/UseGrammar/Custom.hs
@@ -320,6 +320,7 @@ customTokenizer =
,(strCI "vars", const $ tokVars)
,(strCI "chars", const $ map (tS . singleton))
,(strCI "code", const $ lexHaskell)
+ ,(strCI "codevars", const $ (mkTokVars lexHaskell))
,(strCI "text", const $ lexText)
,(strCI "unglue", \gr -> map tS . decomposeWords (stateMorpho gr))
,(strCI "codelit", lexHaskellLiteral . stateIsWord)
diff --git a/src/GF/UseGrammar/Parsing.hs b/src/GF/UseGrammar/Parsing.hs
index 1e736d24e..ba0669029 100644
--- a/src/GF/UseGrammar/Parsing.hs
+++ b/src/GF/UseGrammar/Parsing.hs
@@ -20,6 +20,7 @@ import Option
import Custom
import ShellState
+import PPrCF (prCFTree)
import qualified ParseGFC as N
import Operations
@@ -69,7 +70,10 @@ trees2trms opts sg cn as ts0 info = do
_ | null ts0 -> checkWarn "No success in cf parsing" >> return []
_ | raw -> do
ts1 <- return (map cf2trm0 ts0) ----- should not need annot
- mapM (checkErr . (annotate gr) . trExp) ts1 ---- complicated; often fails
+ checks [
+ mapM (checkErr . (annotate gr) . trExp) ts1 ---- complicated, often fails
+ ,checkWarn (unlines ("Raw CF trees:":(map prCFTree ts0))) >> return []
+ ]
_ -> do
let num = optIntOrN opts flagRawtrees 99999
let (ts01,rest) = splitAt num ts0
diff --git a/src/GF/UseGrammar/Tokenize.hs b/src/GF/UseGrammar/Tokenize.hs
index 22d70a9b1..77c6222ac 100644
--- a/src/GF/UseGrammar/Tokenize.hs
+++ b/src/GF/UseGrammar/Tokenize.hs
@@ -35,6 +35,11 @@ mkCFTokVar s = case s of
'$':xs@(_:_) -> if last s == '$' then tV (init xs) else tS s
_ -> tS s
+mkTokVars :: (String -> [CFTok]) -> String -> [CFTok]
+mkTokVars tok = map tv . tok where
+ tv (TS s) = mkCFTokVar s
+ tv t = t
+
mkLit :: String -> CFTok
mkLit s = if (all isDigit s) then (tI s) else (tL s)