HN Compiler
HNC is buildable by both cabal sandbox
and stack
, on Windows, Linux and MacOS, in 64 or 32 bits.
stack update
stack setup
stack install
$(stack path --local-bin)/spl-hnc -O hn_tests/euler6.hn
cabal update
cabal sandbox init
cabal install
.cabal-sandbox/bin/spl-hnc -O hn_tests/euler6.hn
On Arch you can shorten build time by using prebuilt libraries
from ArchHaskell project.
Add 2 ArchHaskell binary repositories (haskell-core
and haskell-web
) to pacman.conf
. Install
the following prebuilt packages from there to avoid building them. GHC comes
as a dependency.
sudo pacman -S cabal-install haskell-{adjunctions,haskell-src-exts,hunit,logict,parsec,quickcheck,safe}
Proceed to the general compilation steps for Cabal sandbox described above
spl-test-hunit-exe
is the primary suite)dist/build/spl-test-hunit-exe/spl-test-hunit-exe
)hnc
with either -O
or --dump-opt
option to see our first attempts at optimization.cpp
files to a C++ compilerYou’ll need MSVC/GCC, Boost and Boost.Build.
HNC is an open-source cross-platform compiler based on modern technologies: Glasgow Haskell Platform,
UUAGC attribute grammar preprocessor, Parsec parsing library, HOOPL graph optimization library, unification-fd structural unification library. The codebase is tiny: less than 4 KLOC, in the spirit of VPRI Ometa.
Many HN programs can already be compiled into an ugly functional subset of C++ and
then into executables and run (see hn_tests
folder for .hn
sources and .cpp
targets).
A UDP echo server and a few Project Euler problems are the only useful programs so far,
but mostly because we are too lazy to write more examples.
boost
subfolder from the distribution. It’s the folder containing header files for all libraries.Create config.cmd
one level above HNC folder, so it’s not under source control:
@set INCLUDE=folder-containing-boost-subfolder
@call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
VS100COMNTOOLS
is environment variable name set by VC 10.0 installer. Use set | findstr COMN
to find
out which version(s) of Visual C you have installed and change the .cmd
file accordingly.
run testAll.cmd
from hn_tests
folder. You should see tmp-*.cpp
files being generated
from .hn
sources and compiled into .obj
files.
The generated code is not specific to MSVC or Windows, so any other Boost-compatible C++ compiler
and platform should work too. However, the scripts to run test suite are not there yet.
To run deref1.cpp
test manually with GCC, run
gcc -I../cpplib/include test.cpp ../cpplib/lib.cpp -lstdc++ --std=c++0x
from hn_tests
folder if Boost headers are installed globally to /usr/include
, or
gcc -I../cpplib/include -Ifolder-containing-boost-subfolder test.cpp ../cpplib/lib.cpp -lstdc++ --std=c++0x
if Boost headers are manually unpacked locally.
Distributed under GNU Lesser General Public Licence Version 3.