Skip to content

Commit

Permalink
Split happy-core into happy-cli and happy-grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
knothed committed Aug 25, 2021
1 parent f640745 commit 0633fc9
Show file tree
Hide file tree
Showing 35 changed files with 136 additions and 84 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ jobs:
echo "packages: $GITHUB_WORKSPACE/source/packages/tabular" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/backend" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/backend-glr" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/core" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/grammar" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/cli" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/test" >> cabal.project
echo "packages: $GITHUB_WORKSPACE/source/packages/happy" >> cabal.project
cat cabal.project
Expand All @@ -196,8 +197,10 @@ jobs:
echo "PKGDIR_happy_backend=${PKGDIR_happy_backend}" >> "$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_core="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-core-[0-9.]*')"
echo "PKGDIR_happy_core=${PKGDIR_happy_core}" >> "$GITHUB_ENV"
PKGDIR_happy_cli="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-cli-[0-9.]*')"
echo "PKGDIR_happy_cli=${PKGDIR_happy_cli}" >> "$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_test="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-test-[0-9.]*')"
echo "PKGDIR_happy_test=${PKGDIR_happy_test}" >> "$GITHUB_ENV"
PKGDIR_happy="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/happy-[0-9.]*')"
Expand All @@ -209,7 +212,8 @@ jobs:
echo "packages: ${PKGDIR_happy_tabular}" >> cabal.project
echo "packages: ${PKGDIR_happy_backend}" >> cabal.project
echo "packages: ${PKGDIR_happy_backend_glr}" >> cabal.project
echo "packages: ${PKGDIR_happy_core}" >> cabal.project
echo "packages: ${PKGDIR_happy_grammar}" >> cabal.project
echo "packages: ${PKGDIR_happy_cli}" >> cabal.project
echo "packages: ${PKGDIR_happy_test}" >> cabal.project
echo "packages: ${PKGDIR_happy}" >> cabal.project
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-frontend" >> cabal.project ; fi
Expand All @@ -220,15 +224,17 @@ jobs:
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-core" >> 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
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package happy-cli" >> 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-test" >> 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" >> 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: $_ installed\n" unless /^(containers|happy|happy-backend|happy-backend-glr|happy-core|happy-frontend|happy-tabular|happy-test|mtl|transformers)$/; }' >> cabal.project.local
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(containers|happy|happy-backend|happy-backend-glr|happy-grammar|happy-cli|happy-frontend|happy-tabular|happy-test|mtl|transformers)$/; }' >> cabal.project.local
cat cabal.project
cat cabal.project.local
- name: dump install plan
Expand Down Expand Up @@ -272,7 +278,9 @@ jobs:
${CABAL} -vnormal check
cd ${PKGDIR_happy_backend_glr} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_core} || false
cd ${PKGDIR_happy_grammar} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_cli} || false
${CABAL} -vnormal check
cd ${PKGDIR_happy_test} || false
${CABAL} -vnormal check
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ENV = .local.env

EXECUTABLE = "happy"
PACKAGES = ["happy", "happy-core", "happy-frontend", "happy-tabular", "happy-backend", "happy-test"]
PACKAGES = ["happy", "happy-cli", "happy-grammar", "happy-frontend", "happy-tabular", "happy-backend", "happy-test"]
BOOTSTRAPPING = True

sdist-test ::
Expand Down
11 changes: 6 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
packages:
packages/frontend,
packages/tabular,
packages/backend,
packages/backend-glr,
packages/core,
packages/test,
packages/happy
packages/cli,
packages/frontend,
packages/grammar,
packages/happy,
packages/tabular,
packages/test
3 changes: 2 additions & 1 deletion packages/backend-glr/happy-backend-glr.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ library
Happy.Backend.GLR.CLI
build-depends: base < 5,
array,
happy-core == 1.21.0
happy-grammar == 1.21.0,
happy-tabular == 1.21.0

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-glr/src/Happy/Backend/GLR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Happy.Backend.GLR(GLRBackendArgs(..), runGLRBackend) where

import Prelude hiding (filter)
import Happy.Backend.GLR.ProduceCode
import Happy.Core.Grammar
import Happy.Core.Tables
import Happy.Grammar.Grammar
import Happy.Tabular.Tables
import Paths_happy_backend_glr
import Data.Maybe

Expand Down
6 changes: 3 additions & 3 deletions packages/backend-glr/src/Happy/Backend/GLR/ProduceCode.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ This module is designed as an extension to the Haskell parser generator Happy.
> ) where

> import Paths_happy_backend_glr ( version )
> import Happy.Core.GenUtils ( mapDollarDollar, str, char, nl, brack, brack', interleave, maybestr )
> import Happy.Core.Grammar
> import Happy.Core.Tables
> import Happy.Grammar.GenUtils ( mapDollarDollar, str, char, nl, brack, brack', interleave, maybestr )
> import Happy.Grammar.Grammar
> import Happy.Tabular.Tables
> import Data.Array ( Array, (!), array, assocs )
> import Data.Char ( isSpace, isAlphaNum )
> import Data.List ( nub, (\\), sort, find, tails )
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/happy-backend.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ library
Happy.Backend.CLI
build-depends: base < 5,
array,
happy-core == 1.21.0
happy-grammar == 1.21.0,
happy-tabular == 1.21.0

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/Happy/Backend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Happy.Backend(BackendArgs(..), Target(..), runBackend) where

import Happy.Backend.Target
import Happy.Backend.ProduceCode
import Happy.Core.Grammar
import Happy.Core.Tables
import Happy.Grammar.Grammar
import Happy.Tabular.Tables
import Paths_happy_backend
import Data.Char
import Data.Maybe
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/Happy/Backend/CLI.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module Happy.Backend.CLI(Flag(..), options, parseFlags, parseAndRun) where

import Happy.Backend
import Happy.Core.Grammar
import Happy.Core.Tables
import Happy.Core.GenUtils
import Happy.Grammar.Grammar
import Happy.Tabular.Tables
import Happy.Grammar.GenUtils
import System.Console.GetOpt
import Data.Char

Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/Happy/Backend/ProduceCode.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ The code generator.

> import Paths_happy_backend ( version )
> import Happy.Backend.Target ( Target(..) )
> import Happy.Core.Grammar
> import Happy.Core.Tables
> import Happy.Core.GenUtils ( mapDollarDollar, str, char, nl, strspace,
> import Happy.Grammar.Grammar
> import Happy.Grammar.GenUtils ( mapDollarDollar, str, char, nl, strspace,
> interleave, interleave', maybestr,
> brack, brack' )
> import Happy.Tabular.Tables

> import Data.Maybe ( isJust, isNothing, fromMaybe )
> import Data.Char ( ord, chr )
Expand Down
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions packages/cli/happy-cli.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: happy-cli
version: 1.21.0
license: BSD2
license-file: LICENSE
copyright: (c) Andy Gill, Simon Marlow
author: Andy Gill and Simon Marlow
maintainer: Simon Marlow <[email protected]>
bug-reports: https://github.com/simonmar/happy/issues
stability: stable
homepage: https://www.haskell.org/happy/
category: Development
cabal-version: >= 1.10
build-type: Simple
synopsis: Option parsing functionality of happy

Description:
Happy is a parser generator for Haskell.
Happy-CLI provides functionality related to centralised option parsing,
which can be used sensibly from within a happy executable package.

tested-with:
GHC == 7.0.4
GHC == 7.4.2
GHC == 7.6.3
GHC == 7.8.4
GHC == 7.10.3
GHC == 8.0.2
GHC == 8.2.2
GHC == 8.4.4
GHC == 8.6.5
GHC == 8.8.4
GHC == 8.10.4
GHC == 9.0.1

library
hs-source-dirs: src

exposed-modules: Happy.CLI.OptionParsing
build-depends: base < 5

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
ghc-options: -Wall
other-modules:
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE ExplicitForAll #-}

module Happy.Core.OptionParsing(
module Happy.CLI.OptionParsing(
parseOptions, beginOptionsWith, requireUnnamedArgument, OnNone(..), OnMultiple(..),
removeAllOverlaps, removeLongOption, removeLongOverlaps, cleanShortOption, cleanShortOverlaps
) where
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/happy-frontend.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library
containers >= 0.4.2,
transformers >= 0.5.6.2,
mtl >= 2.2.2,
happy-core == 1.21.0
happy-grammar == 1.21.0

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/Happy/Frontend.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Happy.Frontend (parseYFileContents, mangleAbsSyn, runFrontend, ParseResult, FrontendArgs(..), supportsParsingAttributeGrammars) where

import Happy.Core.Grammar
import Happy.Core.GenUtils
import Happy.Grammar.Grammar
import Happy.Grammar.GenUtils
import Happy.Frontend.AbsSyn
import Happy.Frontend.Mangler
import Happy.Frontend.PrettyGrammar
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/Happy/Frontend/AbsSyn.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Here is the abstract syntax of the language we parse.
> Rule(..), Prod(..), Term(..), Prec(..)
> ) where

> import Happy.Core.Grammar (ErrorHandlerType(..))
> import Happy.Grammar.Grammar (ErrorHandlerType(..))

> data AbsSyn
> = AbsSyn
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/Happy/Frontend/CLI.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module Happy.Frontend.CLI(Flag(..), options, parseFlags, parseAndRun, getBaseName) where

import Happy.Frontend
import Happy.Core.Grammar
import Happy.Core.GenUtils
import Happy.Grammar.Grammar
import Happy.Grammar.GenUtils
import System.Console.GetOpt

-------- CLI flags and options --------
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/Happy/Frontend/Mangler.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Mangler converts AbsSyn to Grammar

> module Happy.Frontend.Mangler (mangler) where

> import Happy.Core.Grammar
> import Happy.Core.GenUtils
> import Happy.Grammar.Grammar
> import Happy.Grammar.GenUtils
> import Happy.Frontend.AbsSyn
#ifdef HAPPY_BOOTSTRAP
> import Happy.Frontend.ParseMonad.Class
Expand Down
1 change: 1 addition & 0 deletions packages/grammar/LICENSE
2 changes: 2 additions & 0 deletions packages/grammar/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: happy-core
name: happy-grammar
version: 1.21.0
license: BSD2
license-file: LICENSE
Expand All @@ -11,27 +11,20 @@ homepage: https://www.haskell.org/happy/
category: Development
cabal-version: >= 1.10
build-type: Simple
synopsis: IRs and core functionality of happy
synopsis: happy's Grammar datatype

Description:
Happy is a parser generator for Haskell.
Happy-Core provides cross-packages IRs, like the Grammar
datatype, and other functionality that is fundamental to happy.
New happy packages will probably want to depend on happy-core.
Happy-Grammar exposes the cross-package Grammar datatype,
which represents a grammar as can be parsed and processed by happy.

library
hs-source-dirs: src

exposed-modules: Happy.Core.Grammar,
Happy.Core.Tables,
Happy.Core.GenUtils,
Happy.Core.NameSet,
Happy.Core.OptionParsing
exposed-modules: Happy.Grammar.Grammar,
Happy.Grammar.GenUtils
build-depends: base < 5,
array,
containers >= 0.4.2,
transformers >= 0.5.6.2,
mtl >= 2.2.2
array

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is realy just an extended prelude.
All the code below is understood to be in the public domain.
-----------------------------------------------------------------------------

> module Happy.Core.GenUtils (
> module Happy.Grammar.GenUtils (
> mkClosure,
> combinePairs,
> mapDollarDollar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ The Grammar data type.
(c) 1993-2001 Andy Gill, Simon Marlow
-----------------------------------------------------------------------------

Grammar defines the datatype which is produced by happy-frontend and which is consumed by subsequent steps (tabular & backend).

> module Happy.Core.Grammar (
> module Happy.Grammar.Grammar (
> Name,
>
> Production(..), Grammar(..), ErrorHandlerType(..),
Expand Down
3 changes: 2 additions & 1 deletion packages/happy/happy.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ executable happy
containers >= 0.4.2,
mtl >= 2.2.1,
transformers >= 0.5,
happy-core == 1.21.0,
happy-grammar == 1.21.0,
happy-cli == 1.21.0,
happy-frontend == 1.21.0,
happy-tabular == 1.21.0,
happy-backend == 1.21.0,
Expand Down
4 changes: 2 additions & 2 deletions packages/happy/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import qualified Happy.Backend.CLI as BackendCLI
import qualified Happy.Backend.GLR.CLI as GLRBackendCLI
import qualified Happy.Backend as Backend
import qualified Happy.Backend.GLR as GLRBackend
import Happy.Core.OptionParsing
import Happy.Core.GenUtils
import Happy.CLI.OptionParsing
import Happy.Grammar.GenUtils
import Control.Monad.Except
import System.Console.GetOpt
import System.Environment
Expand Down
6 changes: 4 additions & 2 deletions packages/tabular/happy-tabular.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ library

exposed-modules: Happy.Tabular,
Happy.Tabular.CLI,
Happy.Tabular.First
Happy.Tabular.First,
Happy.Tabular.Tables
build-depends: base < 5,
array,
containers >= 0.4.2,
happy-core == 1.21.0
happy-grammar == 1.21.0

default-language: Haskell98
default-extensions: CPP, MagicHash, FlexibleContexts
Expand All @@ -53,4 +54,5 @@ library
Happy.Tabular.LALR,
Happy.Tabular.FindRedundancies,
Happy.Tabular.Info,
Happy.Tabular.NameSet,
Paths_happy_tabular
8 changes: 4 additions & 4 deletions packages/tabular/src/Happy/Tabular.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Happy.Tabular(
TabularArgs(..), TabularResult, runTabular
) where

import Happy.Core.NameSet (NameSet)
import Happy.Core.Grammar
import Happy.Core.Tables
import Happy.Core.GenUtils
import Happy.Grammar.Grammar
import Happy.Grammar.GenUtils
import Happy.Tabular.NameSet (NameSet)
import Happy.Tabular.Tables
import Happy.Tabular.First
import qualified Happy.Tabular.LALR as LALR
import Happy.Tabular.LALR (Lr0Item, Lr1Item, precalcClosure0, propLookaheads, calcLookaheads, mergeLookaheadInfo)
Expand Down
Loading

0 comments on commit 0633fc9

Please sign in to comment.