diff options
| author | aarne <unknown> | 2003-11-03 16:27:55 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2003-11-03 16:27:55 +0000 |
| commit | 94326929b144913642121bef8f8ecc98feb992e7 (patch) | |
| tree | 07d59cc33cbef2ac79c6f3f573b9718c51322e7a /src/GF/UseGrammar | |
| parent | 2728e6e7ceec92c7f781368b4a523b37e5dee3b9 (diff) | |
Fixed several things, e.g. tokenizer.
Diffstat (limited to 'src/GF/UseGrammar')
| -rw-r--r-- | src/GF/UseGrammar/GetTree.hs | 6 | ||||
| -rw-r--r-- | src/GF/UseGrammar/Linear.hs | 8 | ||||
| -rw-r--r-- | src/GF/UseGrammar/Tokenize.hs | 6 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/GF/UseGrammar/GetTree.hs b/src/GF/UseGrammar/GetTree.hs index 9b545c7dd..9ad91c21f 100644 --- a/src/GF/UseGrammar/GetTree.hs +++ b/src/GF/UseGrammar/GetTree.hs @@ -44,3 +44,9 @@ string2ref gr s = if elem '.' s then return $ uncurry G.Q $ strings2Fun s else return $ G.Vr $ identC s + +string2cat :: StateGrammar -> String -> Err G.Cat +string2cat gr s = + if elem '.' s + then return $ strings2Fun s + else return $ curry id (absId gr) (identC s) diff --git a/src/GF/UseGrammar/Linear.hs b/src/GF/UseGrammar/Linear.hs index 929273562..a46200b36 100644 --- a/src/GF/UseGrammar/Linear.hs +++ b/src/GF/UseGrammar/Linear.hs @@ -12,7 +12,7 @@ import LookAbs import MMacros import TypeCheck (annotate) ---- import Str -import Unlex +import Text ----import TypeCheck -- to annotate import Operations @@ -105,10 +105,14 @@ linLab0 = L (identC "s") sTables2strs :: [[([Patt],[Str])]] -> [[Str]] sTables2strs = map snd . concat --- from this, to get a list of strings --- customize unlexer +-- from this, to get a list of strings strs2strings :: [[Str]] -> [String] strs2strings = map unlex +-- this is just unwords; use an unlexer from Text to postprocess +unlex :: [Str] -> String +unlex = performBinds . concat . map sstr . take 1 ---- + -- finally, a top-level function to get a string from an expression linTree2string :: Marker -> CanonGrammar -> Ident -> A.Tree -> String linTree2string mk gr m e = err id id $ do diff --git a/src/GF/UseGrammar/Tokenize.hs b/src/GF/UseGrammar/Tokenize.hs index dd0879931..ac28276f5 100644 --- a/src/GF/UseGrammar/Tokenize.hs +++ b/src/GF/UseGrammar/Tokenize.hs @@ -21,7 +21,11 @@ tokVars :: String -> [CFTok] tokVars = map mkCFTokVar . words mkCFTok :: String -> CFTok -mkCFTok s = tS s ---- if (isLiteral s) then (mkLit s) else (tS s) +mkCFTok s = case s of + '"' :cs@(_:_) -> tL $ init cs + '\'':cs@(_:_) -> tL $ init cs --- 's Gravenhage + _:_ | all isDigit s -> tI s + _ -> tS s mkCFTokVar :: String -> CFTok mkCFTokVar s = case s of |
