FerryCore-0.4.5.1: Ferry Core Components

Database.Ferry.Compiler

Description

The compiler interface

Synopsis

Documentation

handleError :: FerryError -> IO ()Source

Print an error message

data Config Source

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.

Constructors

Config 

Instances

data Mode Source

The modes that are supported by the compiler. run ferryc -h to see a list of all options

Constructors

Read 
Parse

Parse mode will stop the compiler after the parsing phase

Normalise 
Transform 
TypeInfer 
OpRewrite 
Boxing 
Algebra 
AlgebraXML 

Instances

data Artefact Source

Constructors

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 

Instances

data Input Source

The input mode determines whether the source program is given through a file or via stdin

Constructors

File String

File mode, the program is read from a file

Arg

Argument mode, the program is given as input directly

Instances

defaultConfig :: ConfigSource

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 FileName = StringSource

Name of an artefact file

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).

type Name = StringSource

Type synonym for a stage name type

type Stage = IntSource

Every stage has a stage number

type Log = [String]Source

The compilation log is just a string

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

line :: StringSource

Seperator line for logging

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