diff options
Diffstat (limited to 'src/GF/Compile/GetGrammar.hs')
| -rw-r--r-- | src/GF/Compile/GetGrammar.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/GF/Compile/GetGrammar.hs b/src/GF/Compile/GetGrammar.hs index 4e641dc3d..7907a817b 100644 --- a/src/GF/Compile/GetGrammar.hs +++ b/src/GF/Compile/GetGrammar.hs @@ -22,6 +22,7 @@ import EBNF import ReadFiles ---- +import Char (toUpper) import List (nub) import Monad (foldM) @@ -62,7 +63,7 @@ parseOldGrammar :: FilePath -> IOE ([FilePath],[A.TopDef]) parseOldGrammar file = do putStrE $ "reading old file" +++ file s <- ioeIO $ readFileIf file - A.OldGr incl topdefs <- ioeErr $ {- err2err $ -} pOldGrammar $ oldLexer $ fixNewlines s + A.OldGr incl topdefs <- ioeErr $ pOldGrammar $ oldLexer $ fixNewlines s includes <- ioeErr $ transInclude incl return (includes, topdefs) @@ -74,16 +75,16 @@ err2err (E.Bad s) = Bad s ioeEErr = ioeErr . err2err --- To resolve the new reserved words: change them by turning the final letter to Z. +-- To resolve the new reserved words: +-- change them by turning the final letter to upper case. --- There is a risk of clash. oldLexer :: String -> [L.Token] oldLexer = map change . L.tokens where change t = case t of - (L.PT p (L.TS s)) | elem s new -> (L.PT p (L.TV (init s ++ "Z"))) + (L.PT p (L.TS s)) | elem s newReservedWords -> + (L.PT p (L.TV (init s ++ [toUpper (last s)]))) _ -> t - new = words $ "abstract concrete interface incomplete " ++ - "instance out open resource reuse transfer union with where" getCFGrammar :: Options -> FilePath -> IOE SourceGrammar getCFGrammar opts file = do |
