| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
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 :: EitherErrorMsgInterfaceinterfaceResult =interface... main :: IO () main =defaultMaininterfaceResult
Documentation
Actions that can be requested of the program.
Constructors
| SelectInterface String | Sets the interface that will be used for subsequent actions. |
| 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. |
| KeepTempOutputsOnFailure | Instructs the generator to keep on disk any temporary programs or files created, in case of failure. |
| DumpExtNames | Dumps to stdout information about all external names in the current interface. |
| DumpEnums | Dumps to stdout information about all enums in the current interface. |
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. Use defaultMain'
if you want to include multiple interfaces in your generator.
defaultMain' :: [Either String Interface] -> IO () Source #
This is a version of defaultMain that accepts multiple interfaces.
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.--interface <iface>: Sets the interface that will be used for subsequent arguments.--gen-cpp <outdir>: Generates C++ bindings in the given directory.--gen-hs <outdir>: Generates Haskell bindings under the given top-level source directory.