summaryrefslogtreecommitdiff
path: root/src/GF/Canon/GetGFC.hs
blob: 8bf2fab8237227b969d4c37f4d34836530bb8b7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module GetGFC where

import Operations
import ParGFC
import GFC
import MkGFC
import Modules
import GetGrammar (err2err) ---
import UseIO

getCanonModule :: FilePath -> IOE CanonModule
getCanonModule file = do
  gr <- getCanonGrammar file
  case modules gr of
    [m] -> return m
    _ -> ioeErr $ Bad "expected exactly one module in a file"

getCanonGrammar :: FilePath -> IOE CanonGrammar
getCanonGrammar file = do
  s <- ioeIO $ readFileIf file
  c <- ioeErr {- $ err2err -} $ pCanon $ myLexer s
  return $ canon2grammar c