alex: Alex is a tool for generating lexical analysers in Haskell

[ bsd3, development, program ] [ Propose Tags ]

Alex is a tool for generating lexical analysers in Haskell. It takes a description of tokens based on regular expressions and generates a Haskell module containing code for scanning text efficiently. It is similar to the tool lex or flex for C/C++.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
small_base

Choose the new smaller, split-up base package.

Enabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 2.1.0, 2.2, 2.3, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 3.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7, 3.2.7.1, 3.2.7.2, 3.2.7.3, 3.2.7.4, 3.3.0.0, 3.4.0.0, 3.4.0.1, 3.5.0.0, 3.5.1.0 (info)
Change log CHANGELOG.md
Dependencies array, base (>=1.0 && <4.15.0.0), containers, directory [details]
License BSD-3-Clause
Copyright (c) Chis Dornan, Simon Marlow
Author Chris Dornan and Simon Marlow
Maintainer Simon Marlow <marlowsd@gmail.com>
Revised Revision 1 made by JohnEricson at 2021-03-19T01:06:37Z
Category Development
Home page http://www.haskell.org/alex/
Bug tracker https://github.com/simonmar/alex/issues
Source repo head: git clone https://github.com/simonmar/alex.git
Uploaded by SimonMarlow at 2019-11-04T08:27:45Z
Distributions Arch:3.2.7.4, Debian:3.2.5, Fedora:3.3.0.0, FreeBSD:3.1.4, LTSHaskell:3.4.0.1, NixOS:3.4.0.1, Stackage:3.5.1.0, openSUSE:3.5.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Executables alex
Downloads 167617 total (522 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2019-11-04 [all 2 reports]

Readme for alex-3.2.5

[back to package description]

Alex: A Lexical Analyser Generator

Build Status

Alex is a Lex-like tool for generating Haskell scanners. For complete documentation, see the doc directory.

Alex version 2.0 has changed fairly considerably since version 1.x, and the syntax is almost completely different. For a detailed list of changes, see the release notes in the documentation.

Alex is now covered by a BSD-Style licence; see the licence file in the 'doc' directory for details.

The sources are in the 'src' directory and the documentation in the 'doc' directory; various examples are in the 'examples' subdirectory.

The source code in the 'src' and 'examples' directories is intended for a Haskell 98 compiler with hierarchical modules. It should work with GHC >= 5.04.

Build Instructions

If you just want to use Alex, you can download or install (via cabal install alex) an Alex release from Hackage; also note that distributions such as the Haskell Platform and other package manager-based distributions provide packages for Alex. Moreover, recent versions of cabal will automatically install the required version of alex based on build-tools/build-tool-depends declarations.

Read on if you want to build Alex directly from Git.

Alex is built using GHC & Cabal; so first install GHC and cabal-install-2.0 (or later).

Since Alex itself is implemented in terms of an Alex scanner, bootstrapping Alex is a bit tricky:

You need to have the build-tools alex and happy manually installed; either via your system package manager distribution, the Haskell Platform, or e.g. via (run this outside the Git repository!):

$ cabal install alex happy

which installs them into ${HOME}/.cabal/bin by default (make sure they're in your $PATH for the next steps!).

Variant A

First you need to generate the pre-processed templates via

$ cabal new-run gen-alex-sdist

(otherwise cabal install will complain about "data/AlexTemplate: copyFile: does not exist (No such file or directory)")

And then you can install alex simply by invoking

$ cabal install

from inside the Git folder.

Variant B

Alternatively, you can use the Makefile which automates the steps of producing a self-contained pre-bootstrapped source distribution with pre-generated lexer/scanners (and which also performs the cabal new-run gen-alex-sdist pre-preprocessing step):

$ make sdist
$ cabal install dist/alex-*.tar.gz

For convenience, there's also a make sdist-test target which builds the source source tarball and runs the test-suite from within the source dist.

Contributing & Reporting Issues

Please report any bugs or comments at https://github.com/simonmar/alex/issues

Share and enjoy,

Chris Dornan: cdornan@arm.com

Isaac Jones: ijones@syntaxpolice.org

Simon Marlow: simonmar@microsoft.com