hoppy-generator-0.3.1: 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 be:

import Foreign.Hoppy.Generator.Main (run)
import Foreign.Hoppy.Generator.Spec (ErrorMsg, Interface, interface, interfaceResult)
import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (hPutStrLn, stderr)

iface :: Either ErrorMsg Interface
iface = interface ...

main :: IO ()
main = case interfaceResult of
  Left errorMsg -> do
    hPutStrLn stderr $ "Error initializing interface: " ++ errorMsg
    exitFailure
  Right iface -> do
    args <- getArgs
    _ <- run [iface] args
    return ()

Synopsis

Documentation

data Action Source #

Actions that can be requested of the program.

Constructors

ListInterfaces

Lists the interfaces compiled into the generator.

GenCpp FilePath

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

GenHaskell FilePath

Generates Haskell bindings for an interface in the given location.

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.