1# Alex: A Lexical Analyser Generator 2 3[![Build Status](https://secure.travis-ci.org/simonmar/alex.png?branch=master)](http://travis-ci.org/simonmar/alex) 4 5Alex is a Lex-like tool for generating Haskell scanners. For complete 6documentation, see the doc directory. 7 8- <https://www.haskell.org/alex/> 9 10- <https://hackage.haskell.org/package/alex> 11 12Alex version 2.0 has changed fairly considerably since version 1.x, 13and the syntax is almost completely different. For a detailed list of 14changes, see the release notes in the documentation. 15 16Alex is now covered by a BSD-Style licence; see the licence file in 17the 'doc' directory for details. 18 19The sources are in the 'src' directory and the documentation in the 'doc' 20directory; various examples are in the 'examples' subdirectory. 21 22The source code in the 'src' and 'examples' directories is intended 23for a Haskell 98 compiler with hierarchical modules. It should work 24with GHC >= 5.04. 25 26## Build Instructions 27 28If you just want to *use* Alex, you can download or install (via 29`cabal install alex`) an 30[Alex release from Hackage](https://hackage.haskell.org/package/alex); also note that 31distributions such as the 32[Haskell Platform](https://www.haskell.org/platform/) and other package 33manager-based distributions provide packages for Alex. Moreover, 34recent versions of `cabal` will automatically install the required 35version of `alex` based on 36[`build-tools`/`build-tool-depends` declarations](http://cabal.readthedocs.io/en/latest/developing-packages.html#pkg-field-build-tool-depends). 37 38Read on if you want to build Alex directly from Git. 39 40Alex is built using GHC & Cabal; so first install 41[GHC](https://www.haskell.org/ghc) and 42[`cabal-install-2.0`](https://www.haskell.org/cabal) (or later). 43 44Since Alex itself is implemented in terms of an Alex scanner, 45bootstrapping Alex is a bit tricky: 46 47You need to have the build-tools `alex` and `happy` manually 48installed; either via your system package manager distribution, the 49Haskell Platform, or e.g. via (run this outside the Git repository!): 50 51 $ cabal install alex happy 52 53which installs them into `${HOME}/.cabal/bin` by default (make sure 54they're in your `$PATH` for the next steps!). 55 56### Variant A 57 58First you need to generate the pre-processed templates via 59 60 $ cabal new-run gen-alex-sdist 61 62(otherwise `cabal install` will complain about 63"`data/AlexTemplate: copyFile: does not exist (No such file or directory)`") 64 65And then you can install `alex` simply by invoking 66 67 $ cabal install 68 69from inside the Git folder. 70 71### Variant B 72 73Alternatively, you can use the `Makefile` which automates the steps of 74producing a self-contained pre-bootstrapped source distribution with 75pre-generated lexer/scanners (and which also performs the `cabal 76new-run gen-alex-sdist` pre-preprocessing step): 77 78 $ make sdist 79 $ cabal install dist/alex-*.tar.gz 80 81For convenience, there's also a `make sdist-test` target which builds the 82source source tarball and runs the test-suite from within the source dist. 83 84## Contributing & Reporting Issues 85 86Please report any bugs or comments at https://github.com/simonmar/alex/issues 87 88Share and enjoy, 89 90Chris Dornan: cdornan@arm.com 91 92Isaac Jones: ijones@syntaxpolice.org 93 94Simon Marlow: simonmar@microsoft.com 95