Programatica Tools

Directory tools/base/parse2

The README file is displayed below the directory index.

See also the HTML version of the source code for the Lexer for Haskell in Haskell.

NameLast modifiedSize
Parent Directory  -
HuMakefile2003-09-30 19:11 79
LexUtil.hs2001-11-16 23:35 1.4K
Lexer/2009-01-04 11:20 -
LexerGen/2009-01-04 11:21 -
LexerNotes.html2003-05-08 20:37 3.1K
LexerSpec/2009-01-04 11:34 -
Makefile2009-01-04 11:18 940
NumberNames.hs2001-12-08 02:18 216
ParseMonad.hs2006-06-09 22:39 2.1K
ParsedSyntax.hs2001-12-08 01:03 127
Parser/2005-06-01 23:00 -
ParserOptions.hs2005-10-11 01:09 969
PosName.hs2004-04-02 23:34 238
SourceNames.hs2009-01-04 11:18 2.4K
lexgen2001-11-30 01:55 145
pfe.cgi2018-03-29 23:19 6.3K
Extensible Haskell front-end for the Programatica project - directory base/parse2

Extensible Haskell front-end for the Programatica project

What is in this directory (base/parse2)

This directory contains a new version of the base language lexer and parser. There are two main differences from the old version.

Changes to the parser

The new parser produces a variant av the abstract syntax where every identifier is paired with its position in the source file. This variant of the syntax is defined in module PosSyntax. It reuses the names of all types from the plain abstract syntax, to minimize the number of changes required in the grammar file. The type used for identifiers with source position is called SN and defined in module SourceNames.

Changes to the lexer

(See also the slides from the talk A Lexer for Haskell in Haskell).

Instead of being handwritten in Haskell, the new lexer is generated from a lexical syntax specification. The advantages with this approach are that

The specification is expressed in Haskell, using simple regular expression combinators, and then compiled to a DFA using standard text book algorithms. The regular expression compiler is implemented in Haskell, and the DFAs it generates are output in the form of Haskell source code.

Two pieces of handwritten code accompany the automatically generated code:

Subdirectories

Lexer
Handwritten and automatically generated code for the lexer.
LexerGen
The regular expression compiler.
LexerSpec
The lexical syntax specification for Haskell 98 (based on appendix B.2).
Parser
The Happy parser for the context free grammar (based on appendix B.4).