Alex User Guide

Chris Dornan

Isaac Jones

Simon Marlow

Abstract

Alex is a tool for generating lexical analysers in Haskell, given a description of the tokens to be recognised in the form of regular expressions. It is similar to the tool lex or flex for C/C++.


Table of Contents

1. About Alex
1.1. Release Notes for version 3.0
1.2. Release Notes for version 2.2
1.3. Release Notes for version 2.1.0
1.4. Release Notes for version 2.0
1.4.1. Syntax changes
1.4.2. Changes in the form of an Alex file
1.4.3. Usage changes
1.4.4. Implementation changes
1.5. Reporting bugs in Alex
1.6. License
2. Introduction
3. Alex Files
3.1. Lexical syntax
3.2. Syntax of Alex files
3.2.1. Macro definitions
3.2.2. Rules
3.2.2.1. Contexts
3.2.2.2. Start codes
4. Regular Expression
4.1. Syntax of regular expressions
4.2. Syntax of character sets
5. The Interface to an Alex-generated lexer
5.1. Unicode and UTF-8
5.2. Basic interface
5.3. Wrappers
5.3.1. The "basic" wrapper
5.3.2. The "posn" wrapper
5.3.3. The "monad" wrapper
5.3.4. The "monadUserState" wrapper
5.3.5. The "gscan" wrapper
5.3.6. The bytestring wrappers
5.3.6.1. The "basic-bytestring" wrapper
5.3.6.2. The "posn-bytestring" wrapper
5.3.6.3. The "monad-bytestring" wrapper
5.3.6.4. The "monadUserState-bytestring" wrapper
6. Invoking Alex

List of Figures

2.1. A simple Alex specification.