hoppy-generator-0.7.0: C++ FFI generator - Code generator

Safe HaskellNone
LanguageHaskell2010

Foreign.Hoppy.Generator.Compiler

Contents

Description

Data types for compilers and functions for invoking them.

Synopsis

Typeclass

class Show a => Compiler a where Source #

A compiler that exists on the system for compiling C++ code.

Methods

compileProgram :: a -> FilePath -> FilePath -> IO Bool Source #

compileProgram compiler infile outfile invokes the given compiler in the input file, to produce the output file. If the compiler fails or can't be called for whatever reason, then an error message is printed to standard error, and false is returned.

data SomeCompiler Source #

An existential data type for Compilers.

Constructors

Compiler a => SomeCompiler a 

Data types

data SimpleCompiler Source #

A compiler that can compile a source file into a binary with a single program invocation.

Within the strings in this data type, including the program path, all occurences of {in} and {out} are expanded to the input and desired output files, respectively.

Constructors

SimpleCompiler 

Fields

  • scProgram :: FilePath

    The name of the compiler program to call. Lookup is subject to the regular search path rules of your operating system.

  • scArguments :: [String]

    Arguments to pass to the compiler. Each string is passed as a separate argument. No further word splitting is done.

prependArguments :: [String] -> SimpleCompiler -> SimpleCompiler Source #

Adds arguments to the start of a compiler's argument list.

appendArguments :: [String] -> SimpleCompiler -> SimpleCompiler Source #

Adds arguments to the end of a compiler's argument list.

overrideCompilerFromEnvironment :: SimpleCompiler -> IO SimpleCompiler Source #

Modifies a SimpleCompiler based on environment variables.

If CXX is set and non-empty, it will override the compiler's scProgram.

If CXXFLAGS is set and non-empty, it will be split into words and each word will be prepended as an argument to scArguments. Quoting is not supported.

data CustomCompiler Source #

A Compiler that allows plugging arbitary logic into the compilation process.

Constructors

CustomCompiler 

Fields

  • ccLabel :: String

    A label to display when the compiler is shown. The string is "<CustomCompiler " ++ label ++ ">".

  • ccCompile :: FilePath -> FilePath -> IO Bool

    Given a source file path and an output path, compiles the source file, producing a binary at the output path. Returns true on success. Logs to standard error and returns false on failure.

Standard compilers

defaultCompiler :: SimpleCompiler Source #

The default compiler, used by an Interface that doesn't specify its own. This is:

unsafePerformIO $ overrideCompilerFromEnvironment gppCompiler

gppCompiler :: SimpleCompiler Source #

The GNU C++ compiler, invoked as g++ -o {out} {in}.