mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
last-minute bug fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -313,12 +313,16 @@ firstGrammarST = stateGrammarST . firstStateGrammar
|
||||
firstAbstractST = abstractOf . firstGrammarST
|
||||
firstConcreteST = concreteOf . firstGrammarST
|
||||
-}
|
||||
-- command-line option -language=foo overrides the actual grammar in state
|
||||
-- command-line option -lang=foo overrides the actual grammar in state
|
||||
grammarOfOptState :: Options -> ShellState -> StateGrammar
|
||||
grammarOfOptState opts st =
|
||||
maybe (firstStateGrammar st) (stateGrammarOfLang st . language) $
|
||||
getOptVal opts useLanguage
|
||||
|
||||
languageOfOptState :: Options -> ShellState -> Maybe Language
|
||||
languageOfOptState opts st =
|
||||
maybe (concrete st) (return . language) $ getOptVal opts useLanguage
|
||||
|
||||
-- command-line option -cat=foo overrides the possible start cat of a grammar
|
||||
firstCatOpts :: Options -> StateGrammar -> CFCat
|
||||
firstCatOpts opts sgr =
|
||||
|
||||
Reference in New Issue
Block a user