Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New package happy-lib; make previous happy-* packages sublibraries (#288) #297

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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
@@ -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.
File renamed without changes.
168 changes: 168 additions & 0 deletions lib/happy-lib.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
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 < 5, 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 < 5, 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the relation between this library tabular subsection and lib/tabular/happy-tabular.cabal? I didn't expect to see the latter.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just remove the others?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I forgot to remove the .cabal files. The main thing about this approach :)

Should be done now.

hs-source-dirs: tabular/src

exposed-modules: Happy.Tabular,
Happy.Tabular.First,
Happy.Tabular.Info,
Happy.Tabular.LALR,
Happy.Tabular.NameSet
build-depends: base < 5, 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 < 5, 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
autogen-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 < 5, 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
autogen-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 >= 0.5,
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.
60 changes: 0 additions & 60 deletions packages/backend-glr/happy-backend-glr.cabal

This file was deleted.

Loading