diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eefe2f69..2dbd228e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,42 +11,6 @@ on: - synchronize jobs: - cabal: - runs-on: ubuntu-latest - strategy: - matrix: - ghc: ['8.4', '8.6', '8.8', '8.10', '9.0', '9.2'] - fail-fast: false - env: - CABAL_ARGS: --enable-tests --enable-benchmarks - - steps: - - uses: actions/checkout@v2 - - uses: haskell/actions/setup@v1 - id: setup-haskell-cabal - with: - ghc-version: ${{ matrix.ghc }} - - - run: cabal v2-update - - run: cabal v2-freeze $CABAL_ARGS - - - uses: actions/cache@v2 - with: - path: | - ${{ steps.setup-haskell-cabal.outputs.cabal-store }} - dist-newstyle - key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') - }} - restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}- - - - name: Install dependencies - run: cabal v2-build $CABAL_ARGS --only-dependencies - - run: cabal v2-build $CABAL_ARGS all - - run: cabal v2-test $CABAL_ARGS - - run: cabal v2-haddock $CABAL_ARGS all - - run: cabal v2-sdist all - nix: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml new file mode 100644 index 00000000..56e84796 --- /dev/null +++ b/.github/workflows/haskell-ci.yml @@ -0,0 +1,265 @@ +# This GitHub workflow config has been generated by a script via +# +# haskell-ci 'github' 'language-c.cabal' +# +# To regenerate the script (for example after adjusting tested-with) run +# +# haskell-ci regenerate +# +# For more information, see https://github.com/haskell-CI/haskell-ci +# +# version: 0.17.20240109 +# +# REGENDATA ("0.17.20240109",["github","language-c.cabal"]) +# +name: Haskell-CI +on: + - push + - pull_request +jobs: + linux: + name: Haskell-CI - Linux - ${{ matrix.compiler }} + runs-on: ubuntu-20.04 + timeout-minutes: + 60 + container: + image: buildpack-deps:bionic + continue-on-error: ${{ matrix.allow-failure }} + strategy: + matrix: + include: + - compiler: ghc-9.8.1 + compilerKind: ghc + compilerVersion: 9.8.1 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.6.4 + compilerKind: ghc + compilerVersion: 9.6.4 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.4.8 + compilerKind: ghc + compilerVersion: 9.4.8 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.2.8 + compilerKind: ghc + compilerVersion: 9.2.8 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.0.2 + compilerKind: ghc + compilerVersion: 9.0.2 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.10.7 + compilerKind: ghc + compilerVersion: 8.10.7 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.8.4 + compilerKind: ghc + compilerVersion: 8.8.4 + setup-method: hvr-ppa + allow-failure: false + - compiler: ghc-8.6.5 + compilerKind: ghc + compilerVersion: 8.6.5 + setup-method: hvr-ppa + allow-failure: false + - compiler: ghc-8.4.4 + compilerKind: ghc + compilerVersion: 8.4.4 + setup-method: hvr-ppa + allow-failure: false + - compiler: ghc-8.2.2 + compilerKind: ghc + compilerVersion: 8.2.2 + setup-method: hvr-ppa + allow-failure: false + - compiler: ghc-8.0.2 + compilerKind: ghc + compilerVersion: 8.0.2 + setup-method: hvr-ppa + allow-failure: false + - compiler: ghc-7.10.3 + compilerKind: ghc + compilerVersion: 7.10.3 + setup-method: hvr-ppa + allow-failure: false + fail-fast: false + steps: + - name: apt + run: | + apt-get update + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + if [ "${{ matrix.setup-method }}" = ghcup ]; then + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + "$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false) + else + apt-add-repository -y 'ppa:hvr/ghc' + apt-get update + apt-get install -y "$HCNAME" + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + "$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false) + fi + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: Set PATH and environment variables + run: | + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + echo "LANG=C.UTF-8" >> "$GITHUB_ENV" + echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" + echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" + HCDIR=/opt/$HCKIND/$HCVER + if [ "${{ matrix.setup-method }}" = ghcup ]; then + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" + else + HC=$HCDIR/bin/$HCKIND + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV" + echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" + fi + + 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" + echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" + echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" + echo "HEADHACKAGE=false" >> "$GITHUB_ENV" + echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" + echo "GHCJSARITH=0" >> "$GITHUB_ENV" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: env + run: | + env + - name: write cabal config + run: | + mkdir -p $CABAL_DIR + cat >> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz + echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c - + xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan + rm -f cabal-plan.xz + chmod a+x $HOME/.cabal/bin/cabal-plan + cabal-plan --version + - name: checkout + uses: actions/checkout@v3 + with: + path: source + - name: initial cabal.project for sdist + run: | + touch cabal.project + echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project + cat cabal.project + - name: sdist + run: | + mkdir -p sdist + $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist + - name: unpack + run: | + mkdir -p unpacked + find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; + - name: generate cabal.project + run: | + PKGDIR_language_c="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/language-c-[0-9.]*')" + echo "PKGDIR_language_c=${PKGDIR_language_c}" >> "$GITHUB_ENV" + rm -f cabal.project cabal.project.local + touch cabal.project + touch cabal.project.local + echo "packages: ${PKGDIR_language_c}" >> cabal.project + if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package language-c" >> cabal.project ; fi + if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi + cat >> cabal.project <> cabal.project.local + cat cabal.project + cat cabal.project.local + - name: dump install plan + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all + cabal-plan + - name: restore cache + uses: actions/cache/restore@v3 + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store + restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- + - name: install dependencies + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all + - name: build w/o tests + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: build + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always + - name: tests + run: | + $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct + - name: cabal check + run: | + cd ${PKGDIR_language_c} || false + ${CABAL} -vnormal check + - name: haddock + run: | + $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all + - name: unconstrained build + run: | + rm -f cabal.project.local + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: save cache + uses: actions/cache/save@v3 + if: always() + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store diff --git a/ChangeLog b/ChangeLog.md similarity index 56% rename from ChangeLog rename to ChangeLog.md index c4022765..f16a7632 100644 --- a/ChangeLog +++ b/ChangeLog.md @@ -1,6 +1,9 @@ # Changelog -## WIP +## 0.9.3 + +- Add support for `__builtin_bit_cast` to support clang toolchain, + enabling builds with GHC 9.4+ on Windows. ## 0.9.2 @@ -8,138 +11,156 @@ ## 0.9.1 - - Support parsing an empty list of clobbers after a colon in `asm` statements +- Support parsing an empty list of clobbers after a colon in `asm` statements ## 0.9.0.2 - - Correct lower bound on GHC +- Correct lower bound on GHC ## 0.9.0.1 - - Scrap dependency on syb +- Scrap dependency on syb Thanks to @vmchale ## 0.9 - - Make `Trav` a monad transformer - - Add `runTravTWithTravState` - - Tests now use Cabal-3 - - Implement alignment calculation and correct size calculation - - Add `Show` instance for `Type` - - Add machine descriptions for x86_64 and armv7l - - Small correction in output of prettyprinter - - Allow zeros as line numbers in preprocessed directives + +- Make `Trav` a monad transformer +- Add `runTravTWithTravState` +- Tests now use Cabal-3 +- Implement alignment calculation and correct size calculation +- Add `Show` instance for `Type` +- Add machine descriptions for x86_64 and armv7l +- Small correction in output of prettyprinter +- Allow zeros as line numbers in preprocessed directives Thanks to @aweinstock314, @ersran9, @expipiplus1, @jkoppel, @trofi and @visq -Changes since 0.7.0 -========================================================================== +## Changes since 0.7.0 Wed May 23 07:08:02 2018 +0200 - Support IEC 60559 types and literals. Closes #52. + * Support IEC 60559 types and literals. Closes #52. Wed May 16 07:08:15 2018 +0200 - introduce flag for optional IEC 60559 type support (see #43) + * introduce flag for optional IEC 60559 type support (see #43) Wed May 16 06:36:04 2018 +0200 - WIP: towards a complete Export (#51) + * WIP: towards a complete Export (#51) Thu Feb 22 13:22:50 2018 -0500 - [syntax] GHC.Generics.Generic and Control.DeepSeq.NFData instances (#49) + * [syntax] GHC.Generics.Generic and Control.DeepSeq.NFData instances (#49) (.cabal) drop splitBase flag Tue Feb 20 08:34:39 2018 +0300 - Selectively hide Prelude.<>: GHC 8.4 compat (#45) + * Selectively hide Prelude.<>: GHC 8.4 compat (#45) Tue Feb 20 00:09:16 2018 -0500 - (Analysis) Minimal support for __float128 (#47) + * (Analysis) Minimal support for `__float128` (#47) Sat Nov 25 08:59:59 2017 +0100 - Consider builtin_convertvector from #34 for pretty printing + * Consider builtin_convertvector from #34 for pretty printing Sat Nov 25 00:46:33 2017 -0600 - add support for _Float128 (#41) + * add support for `_Float128` (#41) + +## Changes since 0.6.0 -Changes since 0.6.0 -========================================================================== Mon Jul 31 2017 - Improve TypeCheck output (#31) + * Improve TypeCheck output (#31) Sun Jul 30 2017 - * Add `__float128` (fixes #33) + * Add `__float128` (fixes #33) Mon Maz 22 2017 - * Support clang’s __builtin_convertvector (Fixes #34) + * Support clang’s `__builtin_convertvector` (Fixes #34) Wed Mar 8 2017 - * Move file and parent information to new datatype FilePosition for performance reasons + * Move file and parent information to new datatype FilePosition for performance reasons + +## Changes since 0.5.0 -Changes since 0.5.0 -========================================================================== Thu Feb 23 2017 * Make gccParseCPPArgs grab the arg to -MF -MT and -MQ + Wed Feb 15 2017 * In enums, allow multiple attribute specifiers per enumerator + Tue Feb 21 2017 * Allow typedef redefinition if it denotes the same type + Tue Feb 21 2017 * Change TypeDefRef to store Type, not Maybe Type + Tue Feb 14 2017 * Parse (and ignore) Clang __attribute__((availability(id=major.minor.rev))) + Sun Sep 11 2016 - * Add __builtin_bswap32/64. + * Add `__builtin_bswap32/64`. + Wed Jun 22 2016 - * Add '_Alignof' to Lexer.x (fixes #7) + * Add `_Alignof` to Lexer.x (fixes #7) + Mon Jun 27 2016 * Updates for C11 (part 1) - * _Nullable and _Nonnull support as well as Warnings/lint fixes provided by Anthony Cowley (https://github.com/acowley) + * `_Nullable` and `_Nonnull` support as well as Warnings/lint fixes provided by Anthony Cowley (https://github.com/acowley) + Wed Mar 16 2016 * Consider storage specifier "ThreadSpec" for global and local declarations + Tue Mar 15 2016 - * Support C11 _NoReturn, genearlize is_inline to FunSpecs (Syntax) / FunAttrs (SemRep) + * Support C11 `_NoReturn`, genearlize is_inline to FunSpecs (Syntax) / FunAttrs (SemRep) + +## Changes since 0.4.3 -Changes since 0.4.3 -========================================================================== Wed Mar 2 2016 - * Add direct base type BaseInt128 (complements previous __int128 patch) + * Add direct base type BaseInt128 (complements previous `__int128` patch) ryan.gl.scott@gmail.com + Sun Feb 28 2016 - * Parse gcc-specific __int128 type + * Parse gcc-specific `__int128` type + Thu Dec 4 2014 * Scott Kovach : added derived Eq,Ord instances to NodeInfo -Changes since 0.4.2 -========================================================================== +## Changes since 0.4.2 + Sat Jan 11 2014 * Allow unicode characters in string/char literals and filenames + Mon Oct 27 2014 * macos-attributes + Tue Aug 13 2013 * Do not derive Error instances for newtypes (type parameter has non-parametric role) + Mon Aug 12 2013 * Fix bug caused by applying posFile to nopos (reported by Mikhail Sosonkin) -Changes since 0.4.1 -========================================================================== +## Changes since 0.4.1 + Tue Mar 19 2013 * TypeCheck: Return Left str instead of fail str (do not rely on MonadError instance of Either) * Improve printing of SUERefs and Ident + Thu Feb 28 2013 * Fix parsing and printing of octal character escapes. + Tue Jun 12 2012 * Export Annotated type class from AST module + Wed Aug 24 2012 * Patch for alex-3.0 -Changes 0.3.1 - 0.4.1 -========================================================================== +## Changes 0.3.1 - 0.4.1 + Tue Aug 16 2011: * Port to ghc-7.2 -Fr April 15 2011: Alexander Bernauer + +Fri Apr 15 2011: Alexander Bernauer * Show instances (popular request) for AST types, DumpAst demo -Changes 0.3 - 0.3.1 -========================================================================== +## Changes 0.3 - 0.3.1 + Thu Aug 21 benedikt.huber@gmail.com * add aliases for exposed parsers, in order to document them @@ -158,9 +179,7 @@ Thu Aug 14 17:13:29 CEST 2008 iavor.diatchki@gmail.com Wed Aug 13 12:00:57 CEST 2008 benedikt.huber@gmail.com * add Data.Position: internalIdentAt - -Old Changes -========================================================================== +## Old Changes Mon Jun 9 23:12:46 CEST 2008 benedikt.huber@gmail.com * License switched to 3-clause BSD diff --git a/README b/README deleted file mode 100644 index 1d50717d..00000000 --- a/README +++ /dev/null @@ -1,66 +0,0 @@ -= Language.C = - -Language.C is a parser and pretty-printer framework for C11 and the extensions of gcc. - -See http://visq.github.io/language-c/ - -== Build and Install == - -cabal install - --- or -- - -runhaskell Setup.hs configure FLAGS -runhaskell Setup.hs build -runhaskell Setup.hs install - -Provide the set of flags passing - --flags="" -to configure. - -== Compatibility == - -Tested with GHC 8.0, 8.2, 8.4, 8.6, 8.8 and 8.10 - -It is recommended to use the most recent platform release: http://hackage.haskell.org/platform/. - -== C Language Compatibility == - -Currently unsupported C11 constructs: - - static assertion 6.7.10 (_Static_assert) - - generic selection 6.5.1.1 (_Generic) - - _Atomic, _Alignas, _Thread_local - - Universal character names - -Currently unsupported GNU C extensions: - - __auto_type - - __builtin_offsetof - char a[__builtin_offsetof (struct S, sa->f) - - _Decimal32 - - Extended assembler - __asm__ __volatile__ ("" : : : ); - __asm__ goto ("" : : : : label); - - __attribute__((packed)): types featuring this attribute may have an - incorrect size or alignment calculated. - -IEC 60559: - Since language-c-0.8, extended floating point types are supported (gcc 7 feature). Package maintainers may decide to disable these types (flag iecFpExtension) to work around the fact that the _Float128 type is redefined by glibc >= 2.26 if gcc < 7 is used for preprocessing: - /* The type _Float128 exists only since GCC 7.0. */ - # if !__GNUC_PREREQ (7, 0) || defined __cplusplus - typedef __float128 _Float128; - # endif - -== Sources == - -see src/README - -== Examples == - -A couple of small examples are available in /examples - -== Testing == - -A couple of regression tests can be run via -> cd test/harness; make - -For more tests, see test/README. diff --git a/README.md b/README.md new file mode 100644 index 00000000..eb8b6ca5 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Language.C + +Language.C is a parser and pretty-printer framework for C11 and the extensions of gcc. + +See http://visq.github.io/language-c/ + +## C Language Compatibility + +Currently unsupported C11 constructs: + - static assertion 6.7.10 (`_Static_assert`) + - generic selection 6.5.1.1 (`_Generic`) + - `_Atomic`, `_Alignas`, `_Thread_local` + - Universal character names + +Currently unsupported GNU C extensions: + - `__auto_type` + - `__builtin_offsetof` + `char a[__builtin_offsetof (struct S, sa->f)` + - `_Decimal32` + - Extended assembler + `__asm__ __volatile__ ("" : : : )`; + `__asm__ goto ("" : : : : label)`; + - `__attribute__((packed))`: types featuring this attribute may have an + incorrect size or alignment calculated. + +### IEC 60559: + +Since `language-c-0.8`, extended floating point types are supported (gcc 7 feature). Package maintainers may decide to disable these types (flag `iecFpExtension`) to work around the fact that the `_Float128` type is redefined by glibc >= 2.26 if gcc < 7 is used for preprocessing: + +``` + /* The type _Float128 exists only since GCC 7.0. */ + # if !__GNUC_PREREQ (7, 0) || defined __cplusplus + typedef __float128 _Float128; + # endif +``` + +## Examples + +A couple of small examples are available in `examples`. + +## Testing + +See `test/README`. diff --git a/language-c.cabal b/language-c.cabal index 5bf0c231..2ba2cc81 100644 --- a/language-c.cabal +++ b/language-c.cabal @@ -1,123 +1,132 @@ -Name: language-c -Version: 0.9.2 -Cabal-Version: >= 1.10 -Build-Type: Simple -License: BSD3 -License-File: LICENSE -Copyright: LICENSE -Author: AUTHORS -Maintainer: language.c@monoid.al -Stability: experimental -Homepage: http://visq.github.io/language-c/ -Bug-reports: https://github.com/visq/language-c/issues/ - -Synopsis: Analysis and generation of C code -Description: Language C is a haskell library for the analysis and generation of C code. - It features a complete, well tested parser and pretty printer for all of C99 and a large - set of C11 and clang/GNU extensions. -Category: Language -Tested-With: GHC == 8.4.*, GHC == 8.6.*, GHC == 8.8.*, GHC == 8.10.*, GHC == 9.0.*, GHC == 9.2.* - -Extra-Source-Files: AUTHORS AUTHORS.c2hs ChangeLog README - src/Language/C/Parser/Lexer.x - src/Language/C/Parser/Parser.y - -Source-Repository head - type: git - location: https://github.com/visq/language-c.git - -Flag useByteStrings - Description: Use ByteString as InputStream datatype - Default: True -Flag allWarnings - Description: Turn on all warnings for building (development) - Default: False -Flag iecFpExtension - Description: Support IEC 60559 floating point extension (defines _Float128) - Default: True -Library - default-extensions: CPP, DeriveDataTypeable, DeriveGeneric, PatternGuards, BangPatterns, ExistentialQuantification, GeneralizedNewtypeDeriving, ScopedTypeVariables - Build-Depends: base >= 4.8 && < 5, - array, - containers >= 0.3, - deepseq >= 1.4.0.0 && < 1.6, - directory, - filepath, - mtl, - pretty < 1.2.0, - process - if flag(allWarnings) - if impl(ghc >= 8.0) - ghc-options: -Wall -Wno-redundant-constraints +cabal-version: 2.2 +name: language-c +version: 0.9.3 +license: BSD-3-Clause +license-file: LICENSE +copyright: LICENSE +maintainer: language.c@monoid.al +author: AUTHORS +tested-with: + ghc ==9.8.1 ghc ==9.6.4 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 ghc ==7.10.3 + +homepage: https://visq.github.io/language-c/ +bug-reports: https://github.com/visq/language-c/issues/ +synopsis: Analysis and generation of C code +description: + Language C is a haskell library for the analysis and generation of C code. + It features a complete, well tested parser and pretty printer for all of C99 and a large + set of C11 and clang/GNU extensions. + +category: Language +build-type: Simple +extra-doc-files: + ChangeLog.md + README.md + AUTHORS + AUTHORS.c2hs + +source-repository head + type: git + location: https://github.com/visq/language-c.git + +flag usebytestrings + description: Use ByteString as InputStream datatype + +flag allwarnings + description: Turn on all warnings for building (development) + default: False + +flag iecfpextension + description: + Support IEC 60559 floating point extension (defines _Float128) + +library + exposed-modules: + Language.C + Language.C.Data + Language.C.Data.Position + Language.C.Data.Ident + Language.C.Data.Error + Language.C.Data.Name + Language.C.Data.Node + Language.C.Data.InputStream + Language.C.Syntax + Language.C.Syntax.AST + Language.C.Syntax.Constants + Language.C.Syntax.Ops + Language.C.Syntax.Utils + Language.C.Parser + Language.C.Pretty + Language.C.System.Preprocess + Language.C.System.GCC + Language.C.Analysis + Language.C.Analysis.ConstEval + Language.C.Analysis.Builtins + Language.C.Analysis.SemError + Language.C.Analysis.SemRep + Language.C.Analysis.DefTable + Language.C.Analysis.TravMonad + Language.C.Analysis.AstAnalysis + Language.C.Analysis.DeclAnalysis + Language.C.Analysis.Debug + Language.C.Analysis.TypeCheck + Language.C.Analysis.TypeConversions + Language.C.Analysis.TypeUtils + Language.C.Analysis.NameSpaceMap + Language.C.Analysis.MachineDescs + Language.C.Analysis.Export + + build-tool-depends: happy:happy, alex:alex + hs-source-dirs: src + other-modules: + Language.C.Data.RList + Language.C.Parser.Builtin + Language.C.Parser.Lexer + Language.C.Parser.ParserMonad + Language.C.Parser.Tokens + Language.C.Parser.Parser + + default-language: Haskell2010 + default-extensions: + CPP DeriveDataTypeable DeriveGeneric PatternGuards BangPatterns + ExistentialQuantification GeneralizedNewtypeDeriving + ScopedTypeVariables + + build-depends: + base >=4.8 && <5, + array <0.6, + containers >=0.3 && <0.8, + deepseq >=1.4.0.0 && <1.6, + directory <1.4, + filepath <1.6, + mtl <2.4, + pretty <1.2.0, + process <1.7 + + if flag(allwarnings) + if impl(ghc >=8.0) + ghc-options: -Wall -Wno-redundant-constraints + else - ghc-options: -Wall + ghc-options: -Wall + + if flag(usebytestrings) + build-depends: bytestring >=0.9.0 && <0.13 - if flag(useByteStrings) - Build-Depends: bytestring >= 0.9.0 else cpp-options: -DNO_BYTESTRING - if flag(iecFpExtension) + if flag(iecfpextension) cpp-options: -DIEC_60559_TYPES_EXT - Build-Tools: happy, alex - - Hs-Source-Dirs: src - Exposed-Modules: - -- top-level - Language.C - -- data - Language.C.Data - Language.C.Data.Position - Language.C.Data.Ident - Language.C.Data.Error - Language.C.Data.Name - Language.C.Data.Node - Language.C.Data.InputStream - -- syntax - Language.C.Syntax - Language.C.Syntax.AST - Language.C.Syntax.Constants - Language.C.Syntax.Ops - Language.C.Syntax.Utils - -- parser - Language.C.Parser - -- pretty printer - Language.C.Pretty - -- system - Language.C.System.Preprocess - Language.C.System.GCC - -- analysis [experimental] - Language.C.Analysis - Language.C.Analysis.ConstEval - Language.C.Analysis.Builtins - Language.C.Analysis.SemError - Language.C.Analysis.SemRep - Language.C.Analysis.DefTable - Language.C.Analysis.TravMonad - Language.C.Analysis.AstAnalysis - Language.C.Analysis.DeclAnalysis - Language.C.Analysis.Debug - Language.C.Analysis.TypeCheck - Language.C.Analysis.TypeConversions - Language.C.Analysis.TypeUtils - Language.C.Analysis.NameSpaceMap - Language.C.Analysis.MachineDescs - -- semrep -> code [alpha] - Language.C.Analysis.Export - Other-Modules: - Language.C.Data.RList - -- parser implementation - Language.C.Parser.Builtin - Language.C.Parser.Lexer - Language.C.Parser.ParserMonad - Language.C.Parser.Tokens - Language.C.Parser.Parser - default-language: Haskell2010 - --- test description -Test-Suite language-c-harness - type: exitcode-stdio-1.0 - main-is: test/harness/run-harness.hs - build-depends: base, directory, process, filepath +test-suite language-c-harness + type: exitcode-stdio-1.0 + main-is: test/harness/run-harness.hs default-language: Haskell2010 + build-depends: + base <5, + directory, + process, + filepath diff --git a/test/src/Language/C/Test/ParseTests.hs b/test/src/Language/C/Test/ParseTests.hs index 8e833f8d..46efe48c 100644 --- a/test/src/Language/C/Test/ParseTests.hs +++ b/test/src/Language/C/Test/ParseTests.hs @@ -22,10 +22,11 @@ equivTestTemplate,runEquivTest, compileTestTemplate, runCompileTest, ) where import Control.Exception -import Control.Monad.State +import Control.Monad +import Control.Monad.IO.Class (liftIO) +import Control.Monad.State (modify) import Data.List -import System.Process import System.Directory import System.Exit import System.FilePath (takeBaseName, takeExtension) diff --git a/test/src/Language/C/Test/TestMonad.hs b/test/src/Language/C/Test/TestMonad.hs index 7351f98a..a8976b21 100644 --- a/test/src/Language/C/Test/TestMonad.hs +++ b/test/src/Language/C/Test/TestMonad.hs @@ -24,9 +24,11 @@ defaultMain, where import Control.Applicative (Applicative (..)) import Control.Exception (catch) -import Control.Monad.Cont -import Control.Monad.Reader -import Control.Monad.State +import Control.Monad +import Control.Monad.Cont (MonadCont, ContT, runContT, callCC) +import Control.Monad.IO.Class (MonadIO, liftIO) +import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, local, ask) +import Control.Monad.State (MonadState, StateT, execStateT, put, get, modify, gets) import Data.Map (elems) import System.CPUTime import System.Directory