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 42fada1
Show file tree
Hide file tree
Showing 51 changed files with 230 additions and 71 deletions.
50 changes: 9 additions & 41 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,8 @@ jobs:
- name: initial cabal.project for sdist
run: |
touch cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/tabular" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/frontend" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/backend-lalr" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/backend-glr" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/grammar" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/lib" >> cabal.project
cat cabal.project
- name: sdist
run: |
Expand All @@ -196,42 +192,22 @@ jobs:
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
- name: generate cabal.project
run: |
PKGDIR_happy_tabular="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-tabular-[0-9.]*')"
echo "PKGDIR_happy_tabular=${PKGDIR_happy_tabular}" >> "$GITHUB_ENV"
PKGDIR_happy_frontend="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-frontend-[0-9.]*')"
echo "PKGDIR_happy_frontend=${PKGDIR_happy_frontend}" >> "$GITHUB_ENV"
PKGDIR_happy_backend_lalr="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-backend-lalr-[0-9.]*')"
echo "PKGDIR_happy_backend_lalr=${PKGDIR_happy_backend_lalr}" >> "$GITHUB_ENV"
PKGDIR_happy_backend_glr="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-backend-glr-[0-9.]*')"
echo "PKGDIR_happy_backend_glr=${PKGDIR_happy_backend_glr}" >> "$GITHUB_ENV"
PKGDIR_happy_grammar="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-grammar-[0-9.]*')"
echo "PKGDIR_happy_grammar=${PKGDIR_happy_grammar}" >> "$GITHUB_ENV"
PKGDIR_happy="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-[0-9.]*')"
echo "PKGDIR_happy=${PKGDIR_happy}" >> "$GITHUB_ENV"
PKGDIR_happy_lib="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-lib-[0-9.]*')"
echo "PKGDIR_happy_lib=${PKGDIR_happy_lib}" >> "$GITHUB_ENV"
rm -f cabal.project cabal.project.local
touch cabal.project
touch cabal.project.local
echo "packages: ${PKGDIR_happy_tabular}" >> cabal.project
echo "packages: ${PKGDIR_happy_frontend}" >> cabal.project
echo "packages: ${PKGDIR_happy_backend_lalr}" >> cabal.project
echo "packages: ${PKGDIR_happy_backend_glr}" >> cabal.project
echo "packages: ${PKGDIR_happy_grammar}" >> cabal.project
echo "packages: ${PKGDIR_happy}" >> cabal.project
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-tabular" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-frontend" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-backend-lalr" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-backend-glr" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-grammar" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
echo "packages: ${PKGDIR_happy_lib}" >> cabal.project
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-lib" >> cabal.project ; fi
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
cat >> cabal.project <<EOF
EOF
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(containers|happy|happy-backend-glr|happy-backend-lalr|happy-frontend|happy-grammar|happy-tabular|mtl|transformers)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(containers|happy|happy-lib|mtl|transformers)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
Expand Down Expand Up @@ -259,18 +235,10 @@ jobs:
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: cabal check
run: |
cd ${PKGDIR_happy_tabular} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_frontend} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_backend_lalr} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_backend_glr} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_grammar} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_lib} || false
${CABAL} -vnormal check
- name: haddock
run: |
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
Expand Down
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.
Loading

0 comments on commit 42fada1

Please sign in to comment.