Changeset 16627 for src/Pugs/CodeGen.hs

Show
Ignore:
Timestamp:
06/04/07 10:08:30 (18 months ago)
Author:
gaal
Message:

* reintroduce the description field in CompUnit?, and chase codeGens

to use the filename where possible.
You may need to "rm blib6/lib/*yml" with this revision.
TODO: think about adding a parser revision number to the compunit

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/CodeGen.hs

    r15297 r16627  
    2525import qualified Data.Map as Map 
    2626 
    27 type Generator = Eval Val 
     27type Generator = FilePath -> Eval Val 
    2828 
    2929generators :: Map String Generator 
     
    4343    , ("Parse-YAML",  genParseYAML) 
    4444    , ("Parse-HsYAML",genParseHsYAML) 
    45     , ("Parse-Pretty",fmap (VStr . (++"\n") . pretty) (asks envBody)) 
     45    , ("Parse-Pretty",const $ fmap (VStr . (++"\n") . pretty) (asks envBody)) 
    4646--  , ("XML",         genXML) 
    4747    ] 
     
    8585        key -> Map.lookup key generators 
    8686 
    87 codeGen :: String -> Env -> IO String 
    88 codeGen s env = do 
     87codeGen :: String -> FilePath -> Env -> IO String 
     88codeGen s file env = do 
    8989    gen <- catchIO (doLookup s) . const $ do 
    90         fail $ "Cannot generate code for " ++ s 
    91     rv <- runEvalIO env gen 
     90        fail $ "Cannot generate code for " ++ s ++ ": " ++ file 
     91    rv <- runEvalIO env (gen file) 
    9292    case rv of 
    9393        VStr str    -> return str