From 4c99687f217ce258f821d55e68f5403233f6dea7 Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 7 Nov 2003 14:54:44 +0000 Subject: Fixed treatment of predefined types (Int, String). Fixed treatment of predefined types (Int, String). Added treatment of new reserved words to reading old grammars. --- src/GF/UseGrammar/GetTree.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/GF/UseGrammar/GetTree.hs') diff --git a/src/GF/UseGrammar/GetTree.hs b/src/GF/UseGrammar/GetTree.hs index 9ad91c21f..0db35baf2 100644 --- a/src/GF/UseGrammar/GetTree.hs +++ b/src/GF/UseGrammar/GetTree.hs @@ -13,6 +13,8 @@ import ShellState import Operations +import Char + -- how to form linearizable trees from strings and from terms of different levels -- -- String --> raw Term --> annot, qualif Term --> Tree @@ -39,11 +41,12 @@ strings2Cat s = (identC m, identC (drop 1 c)) where (m,c) = span (/= '.') s strings2Fun = strings2Cat string2ref :: StateGrammar -> String -> Err G.Term -string2ref _ ('x':'_':ds) = return $ freshAsTerm ds --- hack for generated vars -string2ref gr s = - if elem '.' s - then return $ uncurry G.Q $ strings2Fun s - else return $ G.Vr $ identC s +string2ref gr s = case s of + 'x':'_':ds -> return $ freshAsTerm ds --- hack for generated vars + '"':_:_ -> return $ G.K $ init $ tail s + _:_ | all isDigit s -> return $ G.EInt $ read s + _ | elem '.' s -> return $ uncurry G.Q $ strings2Fun s + _ -> return $ G.Vr $ identC s string2cat :: StateGrammar -> String -> Err G.Cat string2cat gr s = -- cgit v1.2.3