The compiler interface
- xmlPhase :: (Qual FType, AlgPlan AlgRes) -> PhaseResult String
- boxingPhase :: CoreExpr -> PhaseResult CoreExpr
- rewritePhase :: CoreExpr -> PhaseResult CoreExpr
- algebraPhase :: CoreExpr -> PhaseResult (Qual FType, AlgPlan AlgRes)
- typeInferPhase :: CoreExpr -> PhaseResult CoreExpr
- data FerryError
- = NoSuchFile String
- | ParserError ParseError
- | UnificationError FType FType
- | UnificationRecError [(RLabel, FType)] [(RLabel, FType)]
- | ClassAlreadyDefinedError String
- | SuperClassNotDefined String [String]
- | ClassNotDefined String
- | RecordDuplicateFields (Maybe String) [(RLabel, FType)]
- | NotARecordType FType
- | RecordWithoutI FType String
- | UnificationOfRecordFieldsFailed RLabel RLabel
- | UnificationFail RLabel RLabel
- | ProcessComplete
- handleError :: FerryError -> IO ()
- typedCoreToAlgebra :: CoreExpr -> String
- data Config = Config {}
- data Mode
- data Artefact
- = Echo
- | PrettyAST
- | PrettyNormalAST
- | PrettyCore
- | DotAST
- | DotCore
- | DotType
- | DotRewrite
- | DotBox
- | DotAlg
- | XML
- | Type
- allArtefacts :: [Artefact]
- data Input
- defaultConfig :: Config
- type ArtefactResult = Reader Config String
- type PhaseResult r = ErrorT FerryError (WriterT Log (WriterT [File] (Reader Config))) r
- type FileName = String
- type File = (Maybe FileName, String)
- data CompilationStep a b = CompilationStep {
- stageName :: Name
- stageMode :: Mode
- stageStep :: a -> PhaseResult b
- stageArtefacts :: [(Artefact, String, b -> ArtefactResult)]
- type Name = String
- type Stage = Int
- type Log = [String]
- artefactToPhaseResult :: ArtefactResult -> PhaseResult String
- getConfig :: PhaseResult Config
- getLog :: Config -> PhaseResult r -> Log
- getFiles :: Config -> PhaseResult r -> [File]
- runPhase :: Config -> PhaseResult r -> (Either FerryError r, Log, [File])
- newError :: FerryError -> PhaseResult r
- endProcess :: PhaseResult b
- line :: String
- logMsg :: MonadWriter [t] m => t -> m ()
- addFile :: Maybe FileName -> String -> PhaseResult ()
- backEndPipeline :: CoreExpr -> PhaseResult ()
- backEndPipeline' :: CoreExpr -> PhaseResult ()
- executeStep :: CompilationStep a b -> a -> PhaseResult b
Documentation
algebraPhase :: CoreExpr -> PhaseResult (Qual FType, AlgPlan AlgRes)Source
data FerryError Source
The FerryError datatype represents errors that occur during compilation
Show FerryError | |
Error FerryError | Just to satisfy the Error monad |
handleError :: FerryError -> IO ()Source
Print an error message
The config datatype is used to store program flags given by the user
The compiler can be put in a Mode
that determines what sort of
result the compilation process will result in.
The Input
element is set to specify whether a file should be compiled or
input from the stdin
The debug component is set to switch on debugging mode, debugging mode
results in log information on the stdin and possibly extra compiler artifacts.
The modes that are supported by the compiler. run ferryc -h to see a list of all options
Echo | Echo mode prints the given input to the console |
PrettyAST | Pretty mode parses the given input and pretty prints the result |
PrettyNormalAST | |
PrettyCore | |
DotAST | |
DotCore | |
DotType | |
DotRewrite | |
DotBox | |
DotAlg | |
XML | |
Type |
The input mode determines whether the source program is given through a file or via stdin
The default configuration for the compiler
type ArtefactResult = Reader Config StringSource
The results of artefact generation are all collected in a reader monad The final result is written to disk or screen when compilation has succeeded
type PhaseResult r = ErrorT FerryError (WriterT Log (WriterT [File] (Reader Config))) rSource
Result of a compilation phase. The error monad is used in case something went wrong during compilation The first writer monad is used for logging purposes. The second writer monad is used to store the artefacts generated by the compiler And the reader monad stores the compiler configuration
type File = (Maybe FileName, String)Source
Artefact file, the first element represents the output file, in case of nothing output is given on stdout. The second component is the file content.
data CompilationStep a b Source
Compilationstep datatype. A compilation step is a record containg a description (stageName field), the internal mode name (stageMode field), the actual stage computation (stageStep field) that transforms element of type a into a PhaseResult of type b and stage artefact generators, a list of function generating artefacts (stageArtefacts field).
CompilationStep | |
|
artefactToPhaseResult :: ArtefactResult -> PhaseResult StringSource
Lift the result of generating an artefact into the overall phase result type
getConfig :: PhaseResult ConfigSource
Get the compiler configuration
getLog :: Config -> PhaseResult r -> LogSource
Get the current log from a phaseresult
getFiles :: Config -> PhaseResult r -> [File]Source
Get the artefacts from the phaseresult
runPhase :: Config -> PhaseResult r -> (Either FerryError r, Log, [File])Source
Execute a phaseresult under a given configuration,, resulting in triple of: 1.) An error or the result 2.) The compilation log 3.) The generated artefacts
newError :: FerryError -> PhaseResult rSource
Throw an error
endProcess :: PhaseResult bSource
Final log message when end of compilation is reached
logMsg :: MonadWriter [t] m => t -> m ()Source
Log the message t
addFile :: Maybe FileName -> String -> PhaseResult ()Source
Add the given file with contents to the phaseresult.
backEndPipeline :: CoreExpr -> PhaseResult ()Source
The compiler pipeline. The given Core AST is transformed dependent on the configuration of the Phaseresult monad.
backEndPipeline' :: CoreExpr -> PhaseResult ()Source
The compiler pipeline. Some tools might already provide a typed AST, is the same as the normal backEndPipeline without type inferencing.
executeStep :: CompilationStep a b -> a -> PhaseResult bSource
Apply a compilation step to an expression of type a. The result of type b is returned in a phaseresult monad