antlr-haskell: A Haskell implementation of the ANTLR top-down parser generator

[ bsd3, library ] [ Propose Tags ]

Please see the README on Github at https://github.com/cronburg/antlr-haskell#readme and https://www.cronburg.com/2018/antlr-haskell-project/.


[Skip to Readme]
Versions 0.1.0.0
Change log ChangeLog.md
Dependencies base (>=4.11 && <5), containers (==0.6.*), deepseq (==1.4.*), hashable (==1.2.*), haskell-src-meta (==0.8.*), mtl (==2.2.*), template-haskell (==2.14.*), text (==1.2.*), th-lift (>=0.7.11 && <0.8), transformers (==0.5.*), unordered-containers (==0.2.*) [details]
License BSD-3-Clause
Copyright MIT
Author Karl Cronburg & Matthew Ahrens
Maintainer karl@cs.tufts.edu
Category Library
Home page https://github.com/cronburg/antlr-haskell#readme
Bug tracker https://github.com/cronburg/antlr-haskell/issues
Source repo head: git clone https://github.com/cronburg/antlr-haskell
Uploaded by KarlCronburg at Tue Nov 27 18:38:47 UTC 2018
Distributions NixOS:0.1.0.0
Downloads 31 total (31 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-11-27 [all 1 reports]
Hackage Matrix CI

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for antlr-haskell-0.1.0.0

[back to package description]

antlr-haskell

A Haskell implementation of ANTLR.

In implementing ANTLR we referenced the behavior of the original Java version (ANTLR4): The definitive ANTLR4 Reference. However we have taken much liberty in the design of this library compared to the workflow of the original Java version. In particular in implementing ANTLR for Haskell we have followed the following principles:

  • Parsing backends should be interchangeable
    • GLR, LR, SLR, LL, ALL(*)
  • Code should be first class and declarative
    • The implementation of G4 is metacircular
    • Regular expressions are interpreted
  • Implement algorithms from first principles
    • Set notation is used in implementing LL and LR algorithms.
    • Pure functional implementations of parsing algorithms can eventually support embedding of arbitrary (including IO) actions without breaking the predictive parsing abstraction.

Build instructions

The library can be built with:

stack build # stack version 1.9.1.1
stack test antlr-haskell:simpl

Or with cabal-2.4.0.1 like:

cabal configure
cabal install --only-dependencies --enable-tests
cabal build
cabal test sexpression

sample grammar for ALL(*)

S -> Ac | Ad

A -> aA | b

ALL(*) Input/output examples

*Test.AllStarTests> parse ['a', 'b', 'c'] (NT 'S') atnEnv
(Just True, Node 'S' [Node 'A' [Leaf 'a', Node 'A' [Leaf 'b']], Leaf 'c'])
*Test.AllStarTests> parse ['b', 'd'] (NT 'S') atnEnv
(Just True, Node 'S' [Node 'A' [Leaf 'b'], Leaf 'd'])
*Test.AllStarTests> parse ['a', 'a', 'a', 'a', 'b', 'c'] (NT 'S') atnEnv
(Just True, Node 'S' [Node 'A' [Leaf 'a', Node 'A' [Leaf 'a', Node 'A' [Leaf 'a', Node 'A' [Leaf 'a', Node 'A' [Leaf 'b']]]]], Leaf 'c'])