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

Safe HaskellNone
LanguageHaskell2010

Foreign.Hoppy.Generator.Main

Description

A driver for a command-line interface to a generator.

A simple Main.hs for a generator can simply be:

import Foreign.Hoppy.Generator.Main (defaultMain)
import Foreign.Hoppy.Generator.Spec (ErrorMsg, Interface, interface)

interfaceResult :: Either ErrorMsg Interface
interfaceResult = interface ...

main :: IO ()
main = defaultMain interfaceResult

Synopsis

Documentation

data Action Source #

Actions that can be requested of the program.

Constructors

ListInterfaces

Lists the interfaces compiled into the generator.

ListCppFiles

Lists the generated files in C++ bindings.

ListHsFiles

Lists the generated files in Haskell bindings.

GenCpp FilePath

Generates C++ wrappers for an interface in the given location.

GenHaskell FilePath

Generates Haskell bindings for an interface in the given location.

defaultMain :: Either String Interface -> IO () Source #

This provides a simple main function for a generator. Define your main as:

main = defaultMain $ interface ...

Refer to run for how to use the command-line interface.

run :: [Interface] -> [String] -> IO [Action] Source #

run interfaces args runs the driver with the command-line arguments from args against the listed interfaces, and returns the list of actions performed.

The recognized arguments are listed below. The exact forms shown are required; the --long-arg=value style is not supported.

  • --help: Displays a menu listing the valid commands.
  • --list-interfaces: Lists the interfaces compiled into the generator.
  • --gen-cpp <outdir>: Generates C++ bindings in the given directory.
  • --gen-hs <outdir>: Generates Haskell bindings under the given top-level source directory.