cabal-version:       3.0
build-type:          Custom

name:                tlex
version:             0.2.0.0
license:             Apache-2.0 OR MPL-2.0
license-file:        LICENSE
copyright:           (c) 2020 Mizunashi Mana
author:              Mizunashi Mana
maintainer:          mizunashi-mana@noreply.git

category:            Parsing
homepage:            https://github.com/mizunashi-mana/tlex
bug-reports:         https://github.com/mizunashi-mana/tlex/issues
synopsis:            A lexer generator
description:
    Tlex is haskell libraries and toolchains for generating lexical analyzer.

extra-source-files:
    README.md
    CHANGELOG.md

source-repository head
  type:     git
  location: https://github.com/mizunashi-mana/tlex.git

flag develop
    default:     False
    manual:      True
    description: Turn on some options for development

common general
    default-language:
        Haskell2010
    default-extensions:
        NoImplicitPrelude
        BangPatterns
        BinaryLiterals
        BlockArguments
        ConstraintKinds
        DataKinds
        DefaultSignatures
        DeriveFoldable
        DeriveFunctor
        DeriveGeneric
        DeriveLift
        DeriveTraversable
        DerivingVia
        DuplicateRecordFields
        EmptyCase
        FlexibleContexts
        FlexibleInstances
        FunctionalDependencies
        GADTs
        InstanceSigs
        LambdaCase
        MagicHash
        MultiParamTypeClasses
        MultiWayIf
        NamedFieldPuns
        NegativeLiterals
        NumericUnderscores
        OverloadedLabels
        PackageImports
        PatternSynonyms
        PolyKinds
        RankNTypes
        ScopedTypeVariables
        StandaloneDeriving
        Strict
        TypeApplications
        TypeFamilies
        TypeOperators
        UnboxedSums
        UnboxedTuples

    if flag(develop)
        ghc-options:
            -Wall
            -Wcompat
            -Wincomplete-uni-patterns
            -Wmonomorphism-restriction
            -Wpartial-fields

            -fprint-explicit-foralls
            -frefinement-level-hole-fits=1

            -dcore-lint

    build-depends:
        base                 >= 4.12.0 && < 4.15,

        -- project depends
        tlex-core            >= 0.1.0 && < 0.3,
        containers           >= 0.6.0 && < 0.7,

    autogen-modules:
        Paths_tlex
    other-modules:
        Paths_tlex

custom-setup
    setup-depends:
        base,
        Cabal,
        cabal-doctest,

library
    import:
        general,
    hs-source-dirs:
        src
    exposed-modules:
        Language.Lexer.Tlex
        Language.Lexer.Tlex.Syntax
        Language.Lexer.Tlex.Runner
        Language.Lexer.Tlex.Pipeline.Scanner2Nfa
        Language.Lexer.Tlex.Pipeline.Dfa2Runner
        Language.Lexer.Tlex.Data.InputString
    reexported-modules:
        tlex-core:Language.Lexer.Tlex.Data.EnumSet,
        tlex-core:Language.Lexer.Tlex.Data.SymEnumSet

test-suite doctest
    import:
        general,
    type:
        exitcode-stdio-1.0
    hs-source-dirs:
        test/doctest
    main-is:
        Doctest.hs
    build-depends:
        doctest,
        QuickCheck,
    autogen-modules:
        Build_doctests
    other-modules:
        Build_doctests

test-suite spec
    import:
        general,
    type:
        exitcode-stdio-1.0
    hs-source-dirs:
        test/spec
    main-is:
        HSpecDriver.hs
    ghc-options:
        -Wno-missing-home-modules
    build-tool-depends:
        hspec-discover:hspec-discover,
    build-depends:
        tlex,

        hspec,
        QuickCheck,