From 8d9cb4660ac009a75fa1f73a9e5448f006c942f7 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Wed, 5 Jan 2022 13:56:51 +0100 Subject: [PATCH 01/13] Stack.yaml files for GHC 9.2.1, 9.0.2 and 9.0.1 (updated to nightly) --- source/BNFC.cabal | 2 ++ source/stack-9.0.1.yaml | 58 ++++++++++++++++++++--------------------- source/stack-9.0.2.yaml | 33 +++++++++++++++++++++++ source/stack-9.2.1.yaml | 33 +++++++++++++++++++++++ 4 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 source/stack-9.0.2.yaml create mode 100644 source/stack-9.2.1.yaml diff --git a/source/BNFC.cabal b/source/BNFC.cabal index eb88c428..24cf394d 100644 --- a/source/BNFC.cabal +++ b/source/BNFC.cabal @@ -44,6 +44,8 @@ Extra-source-files: Makefile src/BNFC.cf src/Makefile + stack-9.2.1.yaml + stack-9.0.2.yaml stack-9.0.1.yaml stack-8.10.7.yaml stack-8.10.4.yaml diff --git a/source/stack-9.0.1.yaml b/source/stack-9.0.1.yaml index e4d51bda..1ec886a2 100644 --- a/source/stack-9.0.1.yaml +++ b/source/stack-9.0.1.yaml @@ -1,33 +1,33 @@ -resolver: ghc-9.0.1 +resolver: nightly-2022-01-04 compiler: ghc-9.0.1 # compiler-check: match-exact -extra-deps: -- alex-3.2.6 -- cabal-doctest-1.0.8 -- happy-1.20.0 -- string-qq-0.0.4 +# extra-deps: +# - alex-3.2.6 +# - cabal-doctest-1.0.8 +# - happy-1.20.0 +# - string-qq-0.0.4 -# For --test: -- HUnit-1.6.2.0 -- QuickCheck-2.14.2 -- ansi-terminal-0.11 -- base-compat-0.11.2 -- call-stack-0.4.0 -- clock-0.8.2 -- code-page-0.2.1 -- colour-2.3.5 -- doctest-0.18.1 -- ghc-paths-0.1.0.12@rev:2 -- hspec-2.8.2 -- hspec-core-2.8.2 -- hspec-discover-2.8.2 -- hspec-expectations-0.8.2 -- primitive-0.7.1.0 -- quickcheck-io-0.2.0 -- random-1.2.0 -- setenv-0.1.1.3 -- splitmix-0.1.0.3 -- syb-0.7.2.1 -- temporary-1.3 -- tf-random-0.5 +# # For --test: +# - HUnit-1.6.2.0 +# - QuickCheck-2.14.2 +# - ansi-terminal-0.11 +# - base-compat-0.11.2 +# - call-stack-0.4.0 +# - clock-0.8.2 +# - code-page-0.2.1 +# - colour-2.3.5 +# - doctest-0.18.1 +# - ghc-paths-0.1.0.12@rev:2 +# - hspec-2.8.2 +# - hspec-core-2.8.2 +# - hspec-discover-2.8.2 +# - hspec-expectations-0.8.2 +# - primitive-0.7.1.0 +# - quickcheck-io-0.2.0 +# - random-1.2.0 +# - setenv-0.1.1.3 +# - splitmix-0.1.0.3 +# - syb-0.7.2.1 +# - temporary-1.3 +# - tf-random-0.5 diff --git a/source/stack-9.0.2.yaml b/source/stack-9.0.2.yaml new file mode 100644 index 00000000..47db9e5a --- /dev/null +++ b/source/stack-9.0.2.yaml @@ -0,0 +1,33 @@ +resolver: ghc-9.0.2 +compiler: ghc-9.0.2 +# compiler-check: match-exact + +extra-deps: +- alex-3.2.6 +- cabal-doctest-1.0.8 +- happy-1.20.0 +- string-qq-0.0.4 + +# For --test: +- HUnit-1.6.2.0 +- QuickCheck-2.14.2 +- ansi-terminal-0.11 +- base-compat-0.11.2 +- call-stack-0.4.0 +- clock-0.8.2 +- code-page-0.2.1 +- colour-2.3.5 +- doctest-0.18.1 +- ghc-paths-0.1.0.12@rev:2 +- hspec-2.8.2 +- hspec-core-2.8.2 +- hspec-discover-2.8.2 +- hspec-expectations-0.8.2 +- primitive-0.7.1.0 +- quickcheck-io-0.2.0 +- random-1.2.0 +- setenv-0.1.1.3 +- splitmix-0.1.0.3 +- syb-0.7.2.1 +- temporary-1.3 +- tf-random-0.5 diff --git a/source/stack-9.2.1.yaml b/source/stack-9.2.1.yaml new file mode 100644 index 00000000..7230ff80 --- /dev/null +++ b/source/stack-9.2.1.yaml @@ -0,0 +1,33 @@ +resolver: ghc-9.2.1 +compiler: ghc-9.2.1 +# compiler-check: match-exact + +extra-deps: +- alex-3.2.6 +- cabal-doctest-1.0.9 +- happy-1.20.0 +- string-qq-0.0.4 + +# For --test: +- HUnit-1.6.2.0 +- QuickCheck-2.14.2 +- ansi-terminal-0.11 +- base-compat-0.12.1 +- call-stack-0.4.0 +- clock-0.8.2 +- code-page-0.2.1 +- colour-2.3.6 +- doctest-0.20.0 +- ghc-paths-0.1.0.12@rev:3 +- hspec-2.9.4 +- hspec-core-2.9.4 +- hspec-discover-2.9.4 +- hspec-expectations-0.8.2 +- primitive-0.7.3.0 +- quickcheck-io-0.2.0 +- random-1.2.1 +- setenv-0.1.1.3 +- splitmix-0.1.0.4 +- syb-0.7.2.1 +- temporary-1.3 +- tf-random-0.5 From 156299dcfd5d1e4394b18cbb8d1ff8cc17f704cf Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Mon, 31 Jan 2022 10:22:17 +0100 Subject: [PATCH 02/13] Bump CI from GHC 9.0.1 to 9.0.2 --- .github/workflows/haskell-ci.yml | 14 ++++---- .github/workflows/stack.yml | 10 +++--- cabal.haskell-ci | 8 ++--- source/BNFC.cabal | 2 +- source/stack-9.0.1.yaml | 30 ----------------- source/stack-9.0.2.yaml | 58 ++++++++++++++++---------------- stack-9.0.2.yaml | 7 ++++ testing/bnfc-system-tests.cabal | 3 +- 8 files changed, 52 insertions(+), 80 deletions(-) create mode 100644 stack-9.0.2.yaml diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 2b1cdfa0..01d0bd19 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.13.20211116 +# version: 0.14 # -# REGENDATA ("0.13.20211116",["github","cabal.project"]) +# REGENDATA ("0.14",["github","cabal.project"]) # name: Haskell-CI on: @@ -33,10 +33,10 @@ jobs: compilerVersion: 9.2.1 setup-method: ghcup allow-failure: true - - compiler: ghc-9.0.1 + - compiler: ghc-9.0.2 compilerKind: ghc - compilerVersion: 9.0.1 - setup-method: hvr-ppa + compilerVersion: 9.0.2 + setup-method: ghcup allow-failure: false - compiler: ghc-8.10.7 compilerKind: ghc @@ -121,7 +121,7 @@ jobs: HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))') echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV" - if [ $((HCNUMVER < 90200)) -ne 0 ] ; then echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" ; else echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV" ; fi + echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" if [ $((HCNUMVER > 90201)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" @@ -248,7 +248,7 @@ jobs: $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always - name: tests run: | - if [ $((HCNUMVER < 90200)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct ; fi + $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct - name: cabal check run: | cd ${PKGDIR_BNFC} || false diff --git a/.github/workflows/stack.yml b/.github/workflows/stack.yml index 11ebddaa..62c18979 100644 --- a/.github/workflows/stack.yml +++ b/.github/workflows/stack.yml @@ -17,13 +17,13 @@ jobs: fail-fast: false matrix: # Note: check release logic below when changing the matrix! - ghc: [9.0.1, 8.10.7, 8.8.4, 8.6.5, 8.4.4, 8.2.2, 8.0.2] + ghc: [9.0.2, 8.10.7, 8.8.4, 8.6.5, 8.4.4, 8.2.2, 8.0.2] os: [ubuntu-latest] include: - os: macOS-latest - ghc: 9.0.1 + ghc: 9.0.2 - os: windows-latest - ghc: 9.0.1 + ghc: 9.0.2 # Needed for Windows to make piping (... >> ...) and evaluation ( $(...) ) work. @@ -112,7 +112,7 @@ jobs: # Conditional to ensure this deployment is only run once per action. if: >- startsWith(github.ref, 'refs/tags/v') - && matrix.ghc == '9.0.1' + && matrix.ghc == '9.0.2' run: | export DIST_TGZ=$(cabal sdist source | tail -1) echo "DIST_TGZ=${DIST_TGZ}" >> ${GITHUB_ENV} @@ -120,7 +120,7 @@ jobs: - name: Source tarball release. if: >- startsWith(github.ref, 'refs/tags/v') - && matrix.ghc == '9.0.1' + && matrix.ghc == '9.0.2' uses: softprops/action-gh-release@v1 with: draft: true diff --git a/cabal.haskell-ci b/cabal.haskell-ci index f3574520..b791d550 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -31,12 +31,8 @@ no-tests-no-benchmarks: >= 9.0.1 -- end --------------------------------------------------------------------------- --- on Linux we can use ghcup to setup (some) of jobs --- hvr-ppa latest are 9.0.1 and 8.10.4 -ghcup-jobs: >= 9.2 || > 8.10.4 && < 9.0 - --- Switch of tests for 9.2 (doctest not yet supported) -tests: < 9.2 +-- -- Switch of tests for 9.2 (doctest not yet supported) +-- tests: < 9.2 allow-failures: >= 9.2 diff --git a/source/BNFC.cabal b/source/BNFC.cabal index 24cf394d..28c3f5b6 100644 --- a/source/BNFC.cabal +++ b/source/BNFC.cabal @@ -34,7 +34,7 @@ tested-with: GHC == 8.6.5 GHC == 8.8.4 GHC == 8.10.7 - GHC == 9.0.1 + GHC == 9.0.2 GHC == 9.2.1 Extra-source-files: diff --git a/source/stack-9.0.1.yaml b/source/stack-9.0.1.yaml index 1ec886a2..cc7ecfa5 100644 --- a/source/stack-9.0.1.yaml +++ b/source/stack-9.0.1.yaml @@ -1,33 +1,3 @@ resolver: nightly-2022-01-04 compiler: ghc-9.0.1 # compiler-check: match-exact - -# extra-deps: -# - alex-3.2.6 -# - cabal-doctest-1.0.8 -# - happy-1.20.0 -# - string-qq-0.0.4 - -# # For --test: -# - HUnit-1.6.2.0 -# - QuickCheck-2.14.2 -# - ansi-terminal-0.11 -# - base-compat-0.11.2 -# - call-stack-0.4.0 -# - clock-0.8.2 -# - code-page-0.2.1 -# - colour-2.3.5 -# - doctest-0.18.1 -# - ghc-paths-0.1.0.12@rev:2 -# - hspec-2.8.2 -# - hspec-core-2.8.2 -# - hspec-discover-2.8.2 -# - hspec-expectations-0.8.2 -# - primitive-0.7.1.0 -# - quickcheck-io-0.2.0 -# - random-1.2.0 -# - setenv-0.1.1.3 -# - splitmix-0.1.0.3 -# - syb-0.7.2.1 -# - temporary-1.3 -# - tf-random-0.5 diff --git a/source/stack-9.0.2.yaml b/source/stack-9.0.2.yaml index 47db9e5a..a0984884 100644 --- a/source/stack-9.0.2.yaml +++ b/source/stack-9.0.2.yaml @@ -1,33 +1,33 @@ -resolver: ghc-9.0.2 +resolver: nightly-2022-01-27 compiler: ghc-9.0.2 # compiler-check: match-exact -extra-deps: -- alex-3.2.6 -- cabal-doctest-1.0.8 -- happy-1.20.0 -- string-qq-0.0.4 +# extra-deps: +# - alex-3.2.6 +# - cabal-doctest-1.0.8 +# - happy-1.20.0 +# - string-qq-0.0.4 -# For --test: -- HUnit-1.6.2.0 -- QuickCheck-2.14.2 -- ansi-terminal-0.11 -- base-compat-0.11.2 -- call-stack-0.4.0 -- clock-0.8.2 -- code-page-0.2.1 -- colour-2.3.5 -- doctest-0.18.1 -- ghc-paths-0.1.0.12@rev:2 -- hspec-2.8.2 -- hspec-core-2.8.2 -- hspec-discover-2.8.2 -- hspec-expectations-0.8.2 -- primitive-0.7.1.0 -- quickcheck-io-0.2.0 -- random-1.2.0 -- setenv-0.1.1.3 -- splitmix-0.1.0.3 -- syb-0.7.2.1 -- temporary-1.3 -- tf-random-0.5 +# # For --test: +# - HUnit-1.6.2.0 +# - QuickCheck-2.14.2 +# - ansi-terminal-0.11 +# - base-compat-0.11.2 +# - call-stack-0.4.0 +# - clock-0.8.2 +# - code-page-0.2.1 +# - colour-2.3.5 +# - doctest-0.18.1 +# - ghc-paths-0.1.0.12@rev:2 +# - hspec-2.8.2 +# - hspec-core-2.8.2 +# - hspec-discover-2.8.2 +# - hspec-expectations-0.8.2 +# - primitive-0.7.1.0 +# - quickcheck-io-0.2.0 +# - random-1.2.0 +# - setenv-0.1.1.3 +# - splitmix-0.1.0.3 +# - syb-0.7.2.1 +# - temporary-1.3 +# - tf-random-0.5 diff --git a/stack-9.0.2.yaml b/stack-9.0.2.yaml new file mode 100644 index 00000000..b977affe --- /dev/null +++ b/stack-9.0.2.yaml @@ -0,0 +1,7 @@ +resolver: nightly-2022-01-27 +compiler: ghc-9.0.2 +compiler-check: match-exact + +packages: +- source +- testing diff --git a/testing/bnfc-system-tests.cabal b/testing/bnfc-system-tests.cabal index 9373d8a5..05893e55 100644 --- a/testing/bnfc-system-tests.cabal +++ b/testing/bnfc-system-tests.cabal @@ -54,7 +54,7 @@ tested-with: GHC == 8.2.2 GHC == 8.6.5 GHC == 8.8.4 GHC == 8.10.7 - GHC == 9.0.1 + GHC == 9.0.2 GHC == 9.2.1 executable bnfc-system-tests @@ -89,7 +89,6 @@ executable bnfc-system-tests , HTF >= 0.14.0.5 -- HTF-0.14.0.3 does not build with random-1.2 , random - -- random < 1.2 , string-qq -- Directories containing source files. From 19151603ff5b0fd8fab3b1a6892321246362e76c Mon Sep 17 00:00:00 2001 From: Beatrice Vergani Date: Mon, 1 Nov 2021 19:28:36 +0100 Subject: [PATCH 03/13] Make `closingToken` function pattern matching exhaustive --- source/src/BNFC/Backend/Haskell/CFtoLayout.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs index f336d758..a90557ac 100644 --- a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs +++ b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs @@ -206,6 +206,7 @@ cf2Layout layName lexName cf = unlines $ concat , " closingToken :: Position -> Block -> Token" , " closingToken pos = sToken pos . \\case" , " Implicit (LayoutDelimiters _ _ (Just sy)) _ _ -> sy" + , " _ -> error \"Trying to close a top level block.\"" , "" , "type Position = Posn" , "type Line = Int" From d517995e2a7f2b3b6a4104a1bd0c77cf5200d1fe Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Tue, 8 Feb 2022 16:55:12 +0100 Subject: [PATCH 04/13] Re #399: More uniform layout error reporter. --- source/src/BNFC/Backend/Haskell/CFtoLayout.hs | 42 +++++++++++++------ .../399_TopLayoutBrace/test.cf | 16 +++++++ 2 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 testing/regression-tests/399_TopLayoutBrace/test.cf diff --git a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs index a90557ac..e6620f60 100644 --- a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs +++ b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs @@ -73,9 +73,27 @@ cf2Layout layName lexName cf = unlines $ concat , render $ prettyList 2 "parenOpen =" "[" "]" "," $ map (text . show) parenOpen , render $ prettyList 2 "parenClose =" "[" "]" "," $ map (text . show) parenClose , "" + , "-- | Report an error during layout resolution." + , "layoutError" + , " :: [Token] -- ^ Remaining tokens." + , " -> String -- ^ Error message." + , " -> a" + , "layoutError ts msg" + , " | null ts = error $ concat [ \"Layout error: \", msg, \".\" ]" + , " | otherwise = error $ unlines" + , " [ concat [ \"Layout error at \", tokenPos ts, \": \", msg, \".\" ]" + , " , unwords $ concat" + , " [ [ \"Remaining tokens:\" ]" + , " , map prToken $ take 10 ts" + , " , [ \"...\" | not $ null $ drop 10 ts ]" + , " ]" + , " ]" + , "" , "-- | Replace layout syntax with explicit layout tokens." - , "resolveLayout :: Bool -- ^ Whether to use top-level layout." - , " -> [Token] -> [Token]" + , "resolveLayout" + , " :: Bool -- ^ Whether to use top-level layout." + , " -> [Token] -- ^ Token stream before layout resolution." + , " -> [Token] -- ^ Token stream after layout resolution." ] , caseMaybe topDelim -- No top-level layout @@ -96,7 +114,7 @@ cf2Layout layName lexName cf = unlines $ concat , " -> [Token] -> [Token]" , "" , " -- The stack should never be empty." - , " res _ [] ts = error $ \"Layout error: stack empty. Tokens: \" ++ show ts" + , " res _ [] ts = layoutError ts \"layout stack empty\"" , "" , " -- Handling explicit blocks:" , " res _ st (t0 : ts)" @@ -112,11 +130,11 @@ cf2Layout layName lexName cf = unlines $ concat , " , let (imps, rest) = span isImplicit st" , " , let st' = drop 1 rest" , " = if null st'" - , " then error $ unwords" - , " [ \"Layout error: Found\", prToken t0, \"at\" , tokenPos [t0]" - , " , \"without an explicit layout block.\"" + , " then layoutError ts $ unwords" + , " [ \"found\", prToken t0, \"at\" , tokenPos [t0]" + , " , \"without an explicit layout block\"" , " ]" - , " else map (closingToken (tokenPosn t0)) imps ++ t0 : res (Just t0) st' ts" + , " else map (closingToken ts (tokenPosn t0)) imps ++ t0 : res (Just t0) st' ts" , "" , " -- Ending or confirming implicit layout blocks:" , " res pt (b@(Implicit delim status col) : bs) (t0 : ts)" @@ -127,14 +145,14 @@ cf2Layout layName lexName cf = unlines $ concat , " -- more indented than the current token." , " , let (ebs, st') = span ((column t0 <) . indentation) bs" , " -- Insert block-closers after the previous token." - , " = map (closingToken (afterPrev pt)) (b : ebs) ++ t0 : res (Just t0) st' ts" + , " = map (closingToken ts (afterPrev pt)) (b : ebs) ++ t0 : res (Just t0) st' ts" , "" , " -- End of an implicit layout block by dedentation." , " | newLine pt t0" , " , column t0 < col" , " -- Insert a block closer after the previous token." , " -- Repeat, with the current block removed from the stack." - , " , let c = closingToken (afterPrev pt) b" + , " , let c = closingToken ts (afterPrev pt) b" , " = c : res (Just c) bs (t0 : ts)" , "" , " -- If we are on a newline, confirm the last tentative blocks." @@ -203,10 +221,10 @@ cf2Layout layName lexName cf = unlines $ concat , " -> (sToken (afterPrev pt) sep :)" , " _ -> id" , "" - , " closingToken :: Position -> Block -> Token" - , " closingToken pos = sToken pos . \\case" + , " closingToken :: [Token] -> Position -> Block -> Token" + , " closingToken ts pos = sToken pos . \\case" , " Implicit (LayoutDelimiters _ _ (Just sy)) _ _ -> sy" - , " _ -> error \"Trying to close a top level block.\"" + , " _ -> layoutError ts \"trying to close a top level block\"" , "" , "type Position = Posn" , "type Line = Int" diff --git a/testing/regression-tests/399_TopLayoutBrace/test.cf b/testing/regression-tests/399_TopLayoutBrace/test.cf new file mode 100644 index 00000000..c29bfe5c --- /dev/null +++ b/testing/regression-tests/399_TopLayoutBrace/test.cf @@ -0,0 +1,16 @@ +-- Andreas, 2022-02-08, PR #399 +-- Small reproducer for layout error "trying to close a top level block". + +terminator Exp ";" ; +layout toplevel ; + +Var. Exp ::= Ident; +Let. Exp ::= "let" "{" [Exp] "}" "in" Exp ; + +layout "in" ; +layout stop "let" ; + +comment "--" ; +comment "{-" "-}" ; + +-- Input for #399: `let {} in x`. From 0939190bde8824a5f8247bbed7ac820f0ef0561a Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Tue, 8 Feb 2022 18:25:27 +0100 Subject: [PATCH 05/13] Re #399: do not pop top layout block when encountering layout stop Layout stop words will now do not have any special effect when in the top layout block (column 1). Fixes a problem where they triggered an exception. --- source/CHANGELOG.md | 1 + source/src/BNFC/Backend/Haskell/CFtoLayout.hs | 4 ++++ testing/regression-tests/399_TopLayoutStop/good01.in | 2 ++ .../{399_TopLayoutBrace => 399_TopLayoutStop}/test.cf | 6 +++--- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 testing/regression-tests/399_TopLayoutStop/good01.in rename testing/regression-tests/{399_TopLayoutBrace => 399_TopLayoutStop}/test.cf (73%) diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index b53e6006..001a5921 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -6,6 +6,7 @@ Unreleased * Agda: support position information via `--functor` [#405] * C/C++: use `size_t` and `-Wsign-conversion` [#391] * C++: repair broken `--line-numbers` [#390], regression in 2.9.2 by [#349] +* Haskell: fix a problem with layout stop words and top-level layout [#399] * Ocaml: non-terminals in generated parser are now type-annotated [#407] Contributors: Michał Radwański diff --git a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs index e6620f60..38322e03 100644 --- a/source/src/BNFC/Backend/Haskell/CFtoLayout.hs +++ b/source/src/BNFC/Backend/Haskell/CFtoLayout.hs @@ -138,6 +138,10 @@ cf2Layout layName lexName cf = unlines $ concat , "" , " -- Ending or confirming implicit layout blocks:" , " res pt (b@(Implicit delim status col) : bs) (t0 : ts)" + , " " + , " -- Do not end top-level layout block by layout stop word." + , " | isStop t0, col <= 1" + , " = t0 : res (Just t0) (b : bs) ts" , "" , " -- End of implicit block by a layout stop word." , " | isStop t0" diff --git a/testing/regression-tests/399_TopLayoutStop/good01.in b/testing/regression-tests/399_TopLayoutStop/good01.in new file mode 100644 index 00000000..fbee7926 --- /dev/null +++ b/testing/regression-tests/399_TopLayoutStop/good01.in @@ -0,0 +1,2 @@ +let {} +in x diff --git a/testing/regression-tests/399_TopLayoutBrace/test.cf b/testing/regression-tests/399_TopLayoutStop/test.cf similarity index 73% rename from testing/regression-tests/399_TopLayoutBrace/test.cf rename to testing/regression-tests/399_TopLayoutStop/test.cf index c29bfe5c..50728fd4 100644 --- a/testing/regression-tests/399_TopLayoutBrace/test.cf +++ b/testing/regression-tests/399_TopLayoutStop/test.cf @@ -7,10 +7,10 @@ layout toplevel ; Var. Exp ::= Ident; Let. Exp ::= "let" "{" [Exp] "}" "in" Exp ; -layout "in" ; -layout stop "let" ; +layout "let" ; +layout stop "in" ; comment "--" ; comment "{-" "-}" ; --- Input for #399: `let {} in x`. +-- Input for #399: `let {}\n in x`. From ca69454806c63723c36a24abba866110f42438f1 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 10 Feb 2022 09:30:15 +0100 Subject: [PATCH 06/13] Re #399: add test case to test runner --- testing/src/ParameterizedTests.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/testing/src/ParameterizedTests.hs b/testing/src/ParameterizedTests.hs index cd6e2272..620b94e4 100644 --- a/testing/src/ParameterizedTests.hs +++ b/testing/src/ParameterizedTests.hs @@ -85,7 +85,10 @@ currentRegressionTest = makeTestSuite "Current parameterized test" $ -- | Layout currently only works for Haskell (even Agda) and Haskell/GADT. layoutTest :: Test layoutTest = makeTestSuite "Layout parsing test" $ concat - [ map (`makeTestCase` ("regression-tests" "356_LayoutSnocList")) $ + [ map (`makeTestCase` ("regression-tests" "399_TopLayoutStop")) $ + [ haskellFunctorParameters + ] + , map (`makeTestCase` ("regression-tests" "356_LayoutSnocList")) $ [ haskellParameters ] , map (`makeTestCase` ("regression-tests" "194_layout")) $ @@ -340,6 +343,12 @@ haskellRunTestProg _lang args = do parameters :: [TestParameters] parameters = concat [ [] + -- OCaml/Menhir + , [ ocaml { tpName = "OCaml/Menhir" + , tpBnfcOptions = ["--ocaml", "--menhir"] } + ] + -- OCaml + , [ ocaml ] -- Functor (Haskell & Agda) , [ haskellAgdaFunctorParameters] -- C++ (extras) From 3e122e30cbaa8a1ae4a76842b4c5b4e7c7229025 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 10 Feb 2022 10:03:05 +0100 Subject: [PATCH 07/13] README: advertise some uses of BNFC --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 48f41e01..d0be6648 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -[![Hackage version](https://img.shields.io/hackage/v/BNFC.svg?label=Hackage)](http://hackage.haskell.org/package/BNFC) -[![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/BNFC/badge)](https://matrix.hackage.haskell.org/package/BNFC) +[![Hackage version](https://img.shields.io/hackage/v/BNFC.svg?label=Hackage)](http://hackage.haskell.org/package/BNFC) [![BNFC on Stackage Nightly](https://stackage.org/package/BNFC/badge/nightly)](https://stackage.org/nightly/package/BNFC) [![Stackage LTS version](https://www.stackage.org/package/BNFC/badge/lts?label=Stackage)](https://www.stackage.org/package/BNFC) [![Build status](https://github.com/BNFC/bnfc/workflows/Haskell-CI/badge.svg)](https://github.com/BNFC/bnfc/actions) @@ -12,10 +11,10 @@ What is the BNF Converter? -------------------------- The BNF Converter (bnfc) is a compiler construction tool generating a compiler -front-end from a Labelled BNF grammar. It is currently able to generate Haskell, +front-end from a Labelled BNF (LBNF) grammar. It is currently able to generate Haskell, Agda, C, C++, Java, and OCaml, as well as XML representations. -Given a Labelled BNF grammar the tool produces: +Given a LBNF grammar the tool produces: - an abstract syntax implementation - a case skeleton for the abstract syntax in the same language - an Alex, Ocamllex, JLex, or Flex lexer generator file @@ -150,3 +149,12 @@ The project is licensed under the [BSD 3-clause license](https://raw.githubuserc BNFC versions until 2.8.4 released under the [GNU General Public License](https://www.gnu.org/licenses/gpl-2.0.html). + +Example uses of the BNF Converter +--------------------------------- + +In research: +- NASA's [OGMA](https://github.com/nasa/ogma) tool uses LBNF for its grammars, e.g. for a [subset of C 99](https://github.com/nasa/ogma/blob/49e78e4d6fa7558d09d36a284648087df48714e4/ogma-language-c/grammar/C.cf). + +In teaching: +- Course [Programming Language Technology](http://www.cse.chalmers.se/edu/course/DAT151/) at Chalmers / Gothenburg University. From 1cc3429fefd33406f9054440d33d3ad4e33eab15 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 10 Feb 2022 10:04:34 +0100 Subject: [PATCH 08/13] Finish changelog for 2.9.4 --- source/CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index 001a5921..3243fc34 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -1,15 +1,17 @@ # 2.9.4 -Unreleased +Andreas Abel February 2022 * LBNF: empty tokens types are now forbidden [#388] * Agda: support position information via `--functor` [#405] * C/C++: use `size_t` and `-Wsign-conversion` [#391] * C++: repair broken `--line-numbers` [#390], regression in 2.9.2 by [#349] * Haskell: fix a problem with layout stop words and top-level layout [#399] +* Java: use _L_`.valueOf()` instead of deprecated `new `_L_`()` for literal classes _L_ [#402] * Ocaml: non-terminals in generated parser are now type-annotated [#407] +* Ocaml: sanitize bound variables in `define` -Contributors: Michał Radwański +Contributors: Michał Radwański [#390,#391] # 2.9.3 From a75cce96230f27a453c2d044d66bf61a89083854 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 10 Feb 2022 18:46:17 +0100 Subject: [PATCH 09/13] Fix #414: do not use error token in Menhir backend, rather catch ParXXX.Error The semantics of the error token changed in Menhir-2021-12-30 and is no longer compatible to OcamlYacc. --- examples/Calc/bad01.in | 1 + examples/Calc/good01.in | 1 + source/CHANGELOG.md | 1 + source/src/BNFC/Backend/OCaml.hs | 3 +- .../src/BNFC/Backend/OCaml/CFtoOCamlTest.hs | 22 +++++++-- .../src/BNFC/Backend/OCaml/CFtoOCamlYacc.hs | 45 +++++++++++-------- 6 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 examples/Calc/bad01.in create mode 100644 examples/Calc/good01.in diff --git a/examples/Calc/bad01.in b/examples/Calc/bad01.in new file mode 100644 index 00000000..9b0d14b2 --- /dev/null +++ b/examples/Calc/bad01.in @@ -0,0 +1 @@ +1+2* \ No newline at end of file diff --git a/examples/Calc/good01.in b/examples/Calc/good01.in new file mode 100644 index 00000000..fcc49a64 --- /dev/null +++ b/examples/Calc/good01.in @@ -0,0 +1 @@ +1+2*3 diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index 3243fc34..33ae621e 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -10,6 +10,7 @@ Andreas Abel February 2022 * Java: use _L_`.valueOf()` instead of deprecated `new `_L_`()` for literal classes _L_ [#402] * Ocaml: non-terminals in generated parser are now type-annotated [#407] * Ocaml: sanitize bound variables in `define` +* Ocaml/Menhir: update parse error mechanism to Menhir 2021/12/30 [#414] Contributors: Michał Radwański [#390,#391] diff --git a/source/src/BNFC/Backend/OCaml.hs b/source/src/BNFC/Backend/OCaml.hs index 8d332f81..a1d408fc 100644 --- a/source/src/BNFC/Backend/OCaml.hs +++ b/source/src/BNFC/Backend/OCaml.hs @@ -89,7 +89,8 @@ makeOCaml opts cf = do mkfile (templateFile opts) comment $ cf2Template (templateFileM opts) absMod cf mkfile (printerFile opts) comment $ cf2Printer prMod absMod cf mkfile (showFile opts) comment $ cf2show showMod absMod cf - mkfile (tFile opts) comment $ ocamlTestfile absMod lexMod parMod prMod showMod cf + mkfile (tFile opts) comment $ + ocamlTestfile (ocamlParser opts) absMod lexMod parMod prMod showMod cf mkfile (utilFile opts) comment $ utilM mkMakefile opts $ makefile opts case xml opts of diff --git a/source/src/BNFC/Backend/OCaml/CFtoOCamlTest.hs b/source/src/BNFC/Backend/OCaml/CFtoOCamlTest.hs index 657e82a0..3f6ce347 100644 --- a/source/src/BNFC/Backend/OCaml/CFtoOCamlTest.hs +++ b/source/src/BNFC/Backend/OCaml/CFtoOCamlTest.hs @@ -14,6 +14,7 @@ import Prelude hiding ((<>)) import Text.PrettyPrint import BNFC.CF +import BNFC.Options (OCamlParser(..)) import BNFC.Backend.OCaml.OCamlUtil import BNFC.Backend.OCaml.CFtoOCamlYacc (epName) import BNFC.Backend.OCaml.CFtoOCamlPrinter (prtFun) @@ -26,8 +27,8 @@ comment :: Doc -> Doc comment d = "(*" <+> d <+> "*)" -- | Generate a test program in OCaml -ocamlTestfile :: String -> String -> String -> String -> String -> CF -> Doc -ocamlTestfile absM lexM parM printM showM cf = +ocamlTestfile :: OCamlParser -> String -> String -> String -> String -> String -> CF -> Doc +ocamlTestfile ocamlParser absM lexM parM printM showM cf = let cat = firstEntry cf qualify q x = concat [ q, ".", x ] @@ -40,11 +41,26 @@ ocamlTestfile absM lexM parM printM showM cf = , parens $ text (showsFunQual (qualify showM) cat) <+> "x" ] topType = text (fixTypeQual absM $ normCat cat) + exc = case ocamlParser of + OCamlYacc -> "Parsing.Parse_error" + Menhir -> text $ qualify parM "Error" in vcat [ "open Lexing" , "" , "let parse (c : in_channel) :" <+> topType <+> "=" - , nest 4 (parserName <+> lexerName <+> "(Lexing.from_channel c)") + , nest 4 $ vcat + [ "let lexbuf = Lexing.from_channel c" + , "in" + , "try" + , nest 2 $ hsep [ parserName, lexerName, "lexbuf" ] + , "with" + , nest 2 $ hsep [ exc, "->" ] + , nest 4 $ vcat + [ "let start_pos = Lexing.lexeme_start_p lexbuf" + , "and end_pos = Lexing.lexeme_end_p lexbuf" + , "in raise (BNFC_Util.Parse_error (start_pos, end_pos))" + ] + ] , ";;" , "" , "let showTree (t : " <> topType <> ") : string =" diff --git a/source/src/BNFC/Backend/OCaml/CFtoOCamlYacc.hs b/source/src/BNFC/Backend/OCaml/CFtoOCamlYacc.hs index a5dd028d..b4f2cc2d 100644 --- a/source/src/BNFC/Backend/OCaml/CFtoOCamlYacc.hs +++ b/source/src/BNFC/Backend/OCaml/CFtoOCamlYacc.hs @@ -142,27 +142,34 @@ epName c = "p" ++ mapHead toUpper (nonterminal c) entryPointRules :: OCamlParser -> CF -> [String] entryPointRules ocamlParser cf = - map mkRule $ toList $ allEntryPoints cf + map (unlines . mkRule) $ toList $ allEntryPoints cf where - mkRule :: Cat -> String - mkRule cat = unlines - [ epName cat ++ " : " ++ nonterminal cat ++ " TOK_EOF { $1 }" - , concat - [ " | error { raise (BNFC_Util.Parse_error (" - -- Andreas, 2021-09-16, issue #380 - -- menhir has dedicated macros for position info, - -- the use of the @Parsing@ structure is deprecated - -- (and does not seem to work). - , case ocamlParser of - OCamlYacc -> "Parsing.symbol_start_pos ()" - Menhir -> "$symbolstartpos" - , ", " - , case ocamlParser of - OCamlYacc -> "Parsing.symbol_end_pos ()" - Menhir -> "$endpos" - , ")) };" + mkRule :: Cat -> [String] + mkRule = case ocamlParser of + Menhir -> \ cat -> + [ epRule cat ++ ";" ] + OCamlYacc -> \ cat -> + [ epRule cat + -- Andreas, 2022-02-10, issue 414: + -- We keep the 'error' token rule, throwing BNFC_Util.Parse_error, + -- for API stability. + -- It would be more uniform with the Menhir backend to just drop this rule + -- and let the user catch the Parsing.Parse_error exception. + , " /* Delete this error clause to get a Parsing.Parse_error exception instead: */" + , ocamlYaccErrorCase + , " ;" ] - ] + epRule :: Cat -> String + epRule cat = epName cat ++ " : " ++ nonterminal cat ++ " TOK_EOF { $1 }" + +ocamlYaccErrorCase :: String +ocamlYaccErrorCase = concat + [ " | error { raise (BNFC_Util.Parse_error (" + , "Parsing.symbol_start_pos ()" + , ", " + , "Parsing.symbol_end_pos ()" + , ")) }" + ] rules :: OCamlParser -> CF -> String rules ocamlParser cf = unlines $ concat From 0fa606e3f806fff3504ecfbe168e668ead87954b Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 10 Feb 2022 20:18:24 +0100 Subject: [PATCH 10/13] Finish changelog for 2.9.4 (really) --- source/CHANGELOG.md | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index 33ae621e..24c4dd6d 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -1,22 +1,25 @@ # 2.9.4 -Andreas Abel February 2022 +Andreas Abel , February 2022 * LBNF: empty tokens types are now forbidden [#388] * Agda: support position information via `--functor` [#405] * C/C++: use `size_t` and `-Wsign-conversion` [#391] * C++: repair broken `--line-numbers` [#390], regression in 2.9.2 by [#349] -* Haskell: fix a problem with layout stop words and top-level layout [#399] +* Haskell: fix a problem with layout stop words and top-level layout [#399,#413] +* Haskell: generated test parser can parse several files now [#400] * Java: use _L_`.valueOf()` instead of deprecated `new `_L_`()` for literal classes _L_ [#402] * Ocaml: non-terminals in generated parser are now type-annotated [#407] * Ocaml: sanitize bound variables in `define` * Ocaml/Menhir: update parse error mechanism to Menhir 2021/12/30 [#414] -Contributors: Michał Radwański [#390,#391] +Contributors: +* Michał Radwański [#390,#391] +* Beatrice Vergani [#399,#400] # 2.9.3 -Andreas Abel September 2021 +Andreas Abel , September 2021 * BNFC now uniformly signs generated files with its version number [#373] * C/C++: include `stdio.h` in parser header files [#381] @@ -27,7 +30,7 @@ Andreas Abel September 2021 # 2.9.2 -Andreas Abel June 2021 +Andreas Abel , June 2021 ## Major improvements @@ -58,7 +61,7 @@ Andreas Abel June 2021 # 2.9.1 -Andreas Abel March 2021 +Andreas Abel , March 2021 ## Main new feature @@ -78,7 +81,7 @@ Andreas Abel March 2021 # 2.9.0 -Andreas Abel December 2020 +Andreas Abel , December 2020 ## Major changes @@ -100,7 +103,7 @@ Andreas Abel December 2020 # 2.8.4 -Andreas Abel October 2020 +Andreas Abel , October 2020 * GHC versions 7.10 - 8.10 supported, dropped GHC 7.6 and 7.8 * LBNF: whitespace list separators are now accepted; treated like "" [#70] @@ -123,7 +126,7 @@ Andreas Abel October 2020 # 2.8.3 -Andreas Abel August 2019 +Andreas Abel , August 2019 * GHC 8.8 compatibility * Stack installation supported by provided .yaml files [#198] @@ -143,7 +146,7 @@ Andreas Abel August 2019 # 2.8.2 -Andreas Abel November 2018 +Andreas Abel , November 2018 * GHC 8.4 compatibility [#227,#236] * bnfc now puts current timestamp on all created files, even unchanged ones [#219] @@ -168,14 +171,14 @@ Andreas Abel November 2018 # 2.8.1 -Grégoire Détrez February 2016 +Grégoire Détrez , February 2016 * Fix compatibility with GHC 7.10.2 and Alex 3.14 * Fixed #160 # 2.8 -Grégoire Détrez May 2015 +Grégoire Détrez , May 2015 * Builds with ghc 7.10.1 * Add support for JFlex (java) @@ -186,7 +189,7 @@ Grégoire Détrez May 2015 # 2.7.1 -Grégoire Détrez October 2014 +Grégoire Détrez , October 2014 * Generated haskell code is now warning free * Removed unused terminal in happy @@ -197,7 +200,7 @@ Grégoire Détrez October 2014 # 2.7.0.0 -Grégoire Détrez September 2014 +Grégoire Détrez , September 2014 * Add token support for Ocaml * New option parser @@ -223,12 +226,12 @@ Grégoire Détrez, January 2013 # 2.4.2.1 -Andreas Abel July 2012 +Andreas Abel , July 2012 # 2.4.2.0 -Thomas Hallgren September 2010 +Thomas Hallgren, September 2010 # 2.4.1.1 -Markus Forsberg September 2010 +Markus Forsberg, September 2010 From ca3b1fc146a6c19e9311fe515efd464820517a4f Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 10 Feb 2022 20:41:49 +0100 Subject: [PATCH 11/13] CI stack: permissions needed to make release --- .github/workflows/stack.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/stack.yml b/.github/workflows/stack.yml index 62c18979..f4d1a626 100644 --- a/.github/workflows/stack.yml +++ b/.github/workflows/stack.yml @@ -8,6 +8,12 @@ on: tags: [ 'v*' ] pull_request: types: [ opened, synchronize] + workflow_dispatch: + +# For making a release, we need write permissions. +# TODO: if we split out a release job from the build job, we could make permissions more fine-grained. +permissions: + contents: write jobs: build: @@ -132,6 +138,7 @@ jobs: if: >- startsWith(github.ref, 'refs/tags/v') && runner.os == 'Linux' + && matrix.ghc == '9.0.2' run: | export BNFC_BIN=bnfc-${BNFC_VERSION}-linux.binary cp -p ${BNFC_EXE} ${BNFC_BIN} @@ -142,6 +149,7 @@ jobs: if: >- startsWith(github.ref, 'refs/tags/v') && runner.os == 'Linux' + && matrix.ghc == '9.0.2' uses: softprops/action-gh-release@v1 with: draft: true From 84c965472d4ddac1ce259cb8fe1b27ce38ca8c06 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Thu, 17 Feb 2022 19:13:51 +0100 Subject: [PATCH 12/13] Bump verstion to 2.9.5 --- docs/conf.py | 4 ++-- source/BNFC.cabal | 4 ++-- source/BNFC.spec | 2 +- source/CHANGELOG.md | 6 +++++- testing/bnfc-system-tests.cabal | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 2420c2bd..517e00eb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = '2.9.4' +version = '2.9.5' # The full version, including alpha/beta/rc tags. -release = '2.9.4' +release = '2.9.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/source/BNFC.cabal b/source/BNFC.cabal index 28c3f5b6..f07cf544 100644 --- a/source/BNFC.cabal +++ b/source/BNFC.cabal @@ -1,5 +1,5 @@ Name: BNFC -Version: 2.9.4 +Version: 2.9.5 cabal-version: 2.0 -- >=1.24 for the custom-setup section -- >=2.0 for the build-tools: hspec-discover @@ -70,7 +70,7 @@ Source-repository this type: git location: git://github.com/BNFC/bnfc.git subdir: source - tag: v2.9.4 + tag: v2.9.5 -- Setup using https://github.com/haskellari/cabal-doctest custom-setup diff --git a/source/BNFC.spec b/source/BNFC.spec index f72ac7fb..e1740858 100644 --- a/source/BNFC.spec +++ b/source/BNFC.spec @@ -1,7 +1,7 @@ # https://fedoraproject.org/wiki/Packaging:Haskell Name: BNFC -Version: 2.9.4 +Version: 2.9.5 Release: 1%{?dist} Summary: A compiler front-end generator diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index 24c4dd6d..8cecc996 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -1,8 +1,12 @@ +# 2.9.5 + +Unreleased + # 2.9.4 Andreas Abel , February 2022 -* LBNF: empty tokens types are now forbidden [#388] +* LBNF: empty token types are now forbidden [#388] * Agda: support position information via `--functor` [#405] * C/C++: use `size_t` and `-Wsign-conversion` [#391] * C++: repair broken `--line-numbers` [#390], regression in 2.9.2 by [#349] diff --git a/testing/bnfc-system-tests.cabal b/testing/bnfc-system-tests.cabal index 05893e55..72e77a3c 100644 --- a/testing/bnfc-system-tests.cabal +++ b/testing/bnfc-system-tests.cabal @@ -14,7 +14,7 @@ name: bnfc-system-tests -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 2.9.4.0 +version: 2.9.5.0 -- A short (one-line) description of the package. synopsis: System tests for BNFC From 69e2b3b026e993ff87012f3efb73fd441714185d Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 18 Feb 2022 18:16:15 +0100 Subject: [PATCH 13/13] mtl-2.3-rc3: Backend.Base: import liftIO and forM_ directly Not via Control.Monad.Writer. --- source/BNFC.cabal | 2 ++ source/src/BNFC/Backend/Base.hs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source/BNFC.cabal b/source/BNFC.cabal index f07cf544..f71b2231 100644 --- a/source/BNFC.cabal +++ b/source/BNFC.cabal @@ -118,6 +118,8 @@ library , process , string-qq , time + , transformers + -- for Control.Monad.IO.Class, which is in base >= 4.9 but not below if impl(ghc < 8.0) build-depends: semigroups diff --git a/source/src/BNFC/Backend/Base.hs b/source/src/BNFC/Backend/Base.hs index 2694b6b6..5d15dc09 100644 --- a/source/src/BNFC/Backend/Base.hs +++ b/source/src/BNFC/Backend/Base.hs @@ -16,9 +16,11 @@ module BNFC.Backend.Base ) where import Control.Arrow ( (&&&) ) +import Control.Monad.IO.Class ( liftIO ) import Control.Monad.Writer import Data.Char ( isSpace ) +import Data.Foldable ( forM_ ) import Data.Function ( on ) import qualified Data.List as List