Skip to content

Commit

Permalink
New package happy-lib; make previous happy-* packages sublibraries (
Browse files Browse the repository at this point in the history
#288)

This is one design design discussed in #288.

Fixes #288.
  • Loading branch information
sgraf812 committed Sep 14, 2024
1 parent 48d3480 commit c5e3f6c
Show file tree
Hide file tree
Showing 50 changed files with 219 additions and 30 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
packages/*/happy-*.cabal
./
happy.cabal
lib/happy-lib.cabal
13 changes: 2 additions & 11 deletions happy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ tested-with:
GHC == 8.4.4
GHC == 8.2.2
GHC == 8.0.2
-- GHC == 7.10.3
-- GHC == 7.8.4
-- GHC == 7.6.3
-- GHC == 7.4.2
-- GHC == 7.0.4

extra-source-files:
ChangeLog.md
Expand Down Expand Up @@ -137,18 +132,14 @@ source-repository head
location: https://github.com/haskell/happy.git

executable happy
hs-source-dirs: src
hs-source-dirs: app
main-is: Main.lhs

build-depends: base >= 4.9 && < 5,
array,
containers >= 0.4.2,
mtl >= 2.2.1,
happy-grammar == 2.0,
happy-tabular == 2.0,
happy-frontend == 2.0,
happy-backend-lalr == 2.0,
happy-backend-glr == 2.0
happy-lib == 2.0

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts, NamedFieldPuns
Expand Down
1 change: 1 addition & 0 deletions lib/ChangeLog.md
1 change: 1 addition & 0 deletions lib/README.md
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ synopsis: A GLR backend for happy

Description:
Happy is a parser generator for Haskell.
Happy-Backend-GLR is a backend which creates
GLR-based Haskell code.
This library translates the LR action and goto tables computed from a grammar
description into table-driven GLR parsing code in Haskell.
Ambiguous parses produce multiple parse trees.

The library happy-grammar defines the 'Grammar' AST type for grammar files.
The library happy-frontend provides a parser for happy grammar files (.y) to
produce a 'Grammar'.
The library happy-tabular computes the LR action and goto tables for the
given 'Grammar' and defines the data types representing said tables.

tested-with:
GHC == 9.10.1
Expand Down Expand Up @@ -57,4 +63,4 @@ library
default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall -Wincomplete-uni-patterns
other-modules: Paths_happy_backend_glr
other-modules: Paths_happy_lib
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Happy.Backend.GLR where

import Paths_happy_backend_glr
import Paths_happy_lib

glrBackendDataDir :: IO String
glrBackendDataDir = getDataDir
glrBackendDataDir = getDataDir
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This module is designed as an extension to the Haskell parser generator Happy.
> , Options
> ) where

> import Paths_happy_backend_glr ( version )
> import Paths_happy_lib ( version )
> import Happy.Grammar
> import Happy.Tabular.LALR
> import Data.Array ( Array, (!), array, assocs )
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ synopsis: A table-based backend for happy

Description:
Happy is a parser generator for Haskell.
Happy-Backend-LALR is responsible for code-generation:
It converts action and goto tables into LALR Haskell code.
This library translates LR action and goto tables computed from a grammar
description into table-driven deterministic parsing code in Haskell.
(Any shift/reduce conflicts are resolved in favour of shifting,
while any reduce/reduce conflicts are resolved in favour of the rule with the
lower number.)

The library happy-grammar defines the 'Grammar' AST type for grammar files.
The library happy-frontend provides a parser for happy grammar files (.y) to
produce a 'Grammar'.
The library happy-tabular computes the LR action and goto tables for the
given 'Grammar' and defines the data types representing said tables.

tested-with:
GHC == 9.10.1
Expand Down Expand Up @@ -56,4 +64,4 @@ library
default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall -Wincomplete-uni-patterns
other-modules: Paths_happy_backend_lalr
other-modules: Paths_happy_lib
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Happy.Backend.LALR where

import Paths_happy_backend_lalr
import Paths_happy_lib
import Data.Char

lalrBackendDataDir :: IO String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The code generator.

> module Happy.Backend.LALR.ProduceCode (produceParser) where

> import Paths_happy_backend_lalr ( version )
> import Paths_happy_lib ( version )
> import Data.Version ( showVersion )
> import Happy.Grammar
> import Happy.Tabular.LALR
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ synopsis: A yacc-like frontend for happy

Description:
Happy is a parser generator for Haskell.
Happy-Frontend is responsible for parsing .y- and .ly-files
and mangling them into a Grammar datatype.
This library provides a parser for happy grammar files (.y/.ly) to produce a
'Grammar' AST type.
These .y- and .ly-files work similar to yacc's .y-files, but
have some Haskell-specific features.

The library happy-grammar defines the 'Grammar' AST type for grammar files.
The library happy-tabular computes the LR action and goto tables for the
given 'Grammar'.
The library happy-backend-lalr defines functions to produce Haskell code
for the LR action and goto tables.

tested-with:
GHC == 9.10.1
GHC == 9.8.2
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ synopsis: happy's Grammar datatype

Description:
Happy is a parser generator for Haskell.
Happy-Grammar exposes the cross-package Grammar datatype,
This library exposes the cross-package Grammar datatype,
which represents a grammar as can be parsed and processed by happy.

The package happy-frontend provides a parser for happy grammar files (.y) to
produce a 'Grammar'.

tested-with:
GHC == 9.10.1
GHC == 9.8.2
Expand Down
File renamed without changes.
166 changes: 166 additions & 0 deletions lib/happy-lib.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
cabal-version: 3.0
name: happy-lib
version: 2.0
license: BSD-2-Clause
copyright: (c) Andy Gill, Simon Marlow
author: Andy Gill and Simon Marlow
maintainer: https://github.com/haskell/happy
bug-reports: https://github.com/haskell/happy/issues
stability: stable
homepage: https://www.haskell.org/happy/
synopsis: Happy is a parser generator for Haskell implemented using this library
category: Development
build-type: Simple

Description:
Happy is a parser generator for Haskell. Given a grammar
specification in BNF, Happy generates Haskell code to parse the
grammar. Happy works in a similar way to the @yacc@ tool for C.

This library provides the following functionality:

* Data type definitions for the Grammar AST type, capturing the information in .y-files (Happy.Grammar)

* A parser for happy grammar files (.y) to produce a Grammar (Happy.Frontend.*)

* Implementations of the text book algorithms that compute the LR action and
goto tables for the given 'Grammar' (Happy.Tabular.*)

* An LALR code generator to produce table-driven, deterministic parsing code
in Haskell (Happy.Backend.LALR.*)

* A (less maintained) GLR code generator to produce table-driven,
non-deterministic parsing code in Haskell, where ambiguous parses produce
multiple parse trees (Happy.Backend.GLR.*)

tested-with:
GHC == 9.10.1
GHC == 9.8.2
GHC == 9.6.5
GHC == 9.4.8
GHC == 9.2.8
GHC == 9.0.2
GHC == 8.10.7
GHC == 8.8.4
GHC == 8.6.5
GHC == 8.4.4
GHC == 8.2.2
GHC == 8.0.2

extra-source-files:
ChangeLog.md
README.md
frontend/bootstrap.sh
frontend/boot-src/Parser.ly
frontend/boot-src/AttrGrammarParser.ly

data-dir: data

data-files:
HappyTemplate.hs
GLR_Base.hs
GLR_Lib.hs

source-repository head
type: git
location: https://github.com/haskell/happy.git

library grammar
hs-source-dirs: grammar/src

exposed-modules: Happy.Grammar
build-depends: base, array

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall
other-modules:

library frontend
hs-source-dirs: frontend/src
exposed-modules: Happy.Frontend,
Happy.Frontend.AbsSyn,
Happy.Frontend.Mangler,
Happy.Frontend.PrettyGrammar

build-depends: base, array, transformers, containers, mtl, happy-lib:grammar

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall -Wno-incomplete-uni-patterns
other-modules:
Happy.Frontend.ParseMonad
Happy.Frontend.ParseMonad.Class
Happy.Frontend.Mangler.Monad
Happy.Frontend.Parser
Happy.Frontend.Lexer
Happy.Frontend.ParamRules
Happy.Frontend.AttrGrammar
Happy.Frontend.AttrGrammar.Parser
Happy.Frontend.AttrGrammar.Mangler

library tabular
hs-source-dirs: tabular/src

exposed-modules: Happy.Tabular,
Happy.Tabular.First,
Happy.Tabular.Info,
Happy.Tabular.LALR,
Happy.Tabular.NameSet
build-depends: base, array, containers, happy-lib:grammar

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts, NamedFieldPuns
ghc-options: -Wall

library backend-lalr
hs-source-dirs: backend-lalr/src

exposed-modules: Happy.Backend.LALR,
Happy.Backend.LALR.ProduceCode
build-depends: base, array, happy-lib:grammar, happy-lib:tabular

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall -Wno-incomplete-uni-patterns
other-modules: Paths_happy_lib

library backend-glr
hs-source-dirs: backend-glr/src

exposed-modules: Happy.Backend.GLR,
Happy.Backend.GLR.ProduceCode
build-depends: base, array, happy-lib:grammar, happy-lib:tabular

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall -Wno-incomplete-uni-patterns
other-modules: Paths_happy_lib

library
reexported-modules: Happy.Grammar,
Happy.Frontend,
Happy.Frontend.AbsSyn,
Happy.Frontend.Mangler,
Happy.Frontend.PrettyGrammar,
Happy.Tabular,
Happy.Tabular.First,
Happy.Tabular.Info,
Happy.Tabular.LALR,
Happy.Tabular.NameSet,
Happy.Backend.LALR,
Happy.Backend.LALR.ProduceCode,
Happy.Backend.GLR,
Happy.Backend.GLR.ProduceCode

build-depends: base >= 4.9 && < 5,
array,
containers >= 0.4.2,
transformers >= 0.5.6.2,
mtl >= 2.2.1,
happy-lib:grammar,
happy-lib:tabular,
happy-lib:frontend,
happy-lib:backend-lalr,
happy-lib:backend-glr
default-language: Haskell98
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ synopsis: Action and goto tables for happy

Description:
Happy is a parser generator for Haskell.
Happy-Tabular converts `Grammar`s, coming from
a frontend, into LALR action and goto tables,
which are further processed by a backend.
For a given description of a happy grammar file (.y),
this library implements the text book computation of the LALR automaton and
generates the final LR action and goto tables, which are further processed by
a backend.

The library happy-grammar defines the 'Grammar' AST type for grammar files.
The library happy-frontend provides a parser for happy grammar files (.y) to
produce a 'Grammar'.
The library happy-backend-lalr defines functions to produce Haskell code
for the LR action and goto tables.

tested-with:
GHC == 9.10.1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c5e3f6c

Please sign in to comment.