freec

Safe HaskellNone
LanguageHaskell2010

Main

Description

This is the main module for the compiler's command line interface.

Synopsis

Documentation

main :: IO () Source #

The main function of the compiler.

Runs the compiler application and prints all reported messages to stderr.

compiler :: Application () Source #

Parses and handles the command line options of the application.

Prints the help message if the --help option or no input file was specified. Otherwise all input files are processed (see convertInputModuleWith). If a fatal message is reported while processing any input file, the compiler will exit. All reported messages will be printed to stderr.

selectFrontend :: Application Frontend Source #

Selects the correct frontend or throws an error if such a frontend does not exist.

selectBackend :: Application Backend Source #

Selects the correct backend or throws an error if such a backend does not exist.

parseInputFileWith :: FrontendParser decls -> FilePath -> Application (ModuleOf decls) Source #

Parses the given input file with the given parsing function.

sortInputModules :: [ModuleOf decls] -> Application [ModuleOf decls] Source #

Sorts the given modules based on their dependencies.

If the module dependencies form a cycle, a fatal error is reported.

convertInputModuleWith :: FrontendSimplifier decls -> BackendConverter -> ModuleOf decls -> Application (ModName, String) Source #

Converts the given module with the given simplification and conversion functions.

The resulting string is written to the console or output file.

writeOutputModule :: Backend -> ModName -> String -> Application () Source #

Output a module that has been generated by the given backend from an IR module with the given name.

If the --output command line option was specified, the output module is written to a file whose name is based on the module name and whose extension depends on the given back end. Otherwise, the output module is printed to the console.

loadRequiredModules :: ModuleOf decls -> Application () Source #

Loads the environments of modules imported by the given modules from their environment file.

loadImport :: ImportDecl -> Application () Source #

Loads the environment of the module imported by the given declaration.

loadModule :: SrcSpan -> ModName -> Application () Source #

Loads the interface of the module with the given name from the configured import path or base library.

The given source span is used in error messages if the module could not be found. Modules from the base library always take precedence. Allowed file extensions for module interface files are .json (for generated module interfaces) and .toml (for manually maintained module interface files).

loadPrelude :: Application () Source #

Loads the Prelude module from the base library.

This is the only module that we have to load explicitly, because the import of Prelude can be omitted.