1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 01:42:43 +03:00

Merge pull request #335 from github/semantic-analysis

Semantic analysis
This commit is contained in:
Rob Rix 2019-10-11 17:31:57 -04:00 committed by GitHub
commit 3309d9ef49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 125 additions and 63 deletions

View File

@ -37,7 +37,6 @@ script:
- cabal new-build
- cabal new-run semantic:test
- cabal new-run semantic-core:test
- cabal new-run semantic-core:doctest
- cabal new-run semantic-python:test
- cabal new-run semantic-source:test
- cabal new-run semantic-source:doctest

View File

@ -1,4 +1,5 @@
packages: .
semantic-analysis
semantic-core
semantic-java
semantic-json
@ -11,6 +12,9 @@ jobs: $ncpus
package semantic
ghc-options: -Werror
package semantic-analysis
ghc-options: -Werror
package semantic-core
ghc-options: -Werror

21
semantic-analysis/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,18 @@
# semantic-analysis
Program analysis by abstract definitional interpretation.
## Development
This project consists of a Haskell package named `semantic-analysis`. The librarys sources are in [`src`][].
Development of `semantic-analysis` is typically done using `cabal v2-build`:
```shell
cabal v2-build # build the library
cabal v2-repl # load the package into ghci
cabal v2-test # build and run the doctests
```
[`src`]: https://github.com/github/semantic/tree/master/semantic-analysis/src

View File

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

View File

@ -0,0 +1,67 @@
cabal-version: 2.4
name: semantic-analysis
version: 0.0.0.0
synopsis: Program analysis by abstract definitional interpretation.
description: Program analysis abstractions and implementations by abstract definitional interpretation.
homepage: https://github.com/github/semantic/tree/master/semantic-analysis#readme
bug-reports: https://github.com/github/semantic/issues
license: MIT
license-file: LICENSE
author: The Semantic authors
maintainer: opensource+semantic@github.com
copyright: (c) 2019 GitHub, Inc.
category: Language
build-type: Simple
stability: alpha
extra-source-files: README.md
tested-with:
GHC == 8.6.5
common common
default-language: Haskell2010
ghc-options:
-Weverything
-Wno-missing-local-signatures
-Wno-missing-import-lists
-Wno-implicit-prelude
-Wno-safe
-Wno-unsafe
-Wno-name-shadowing
-Wno-monomorphism-restriction
-Wno-missed-specialisations
-Wno-all-missed-specialisations
-Wno-star-is-type
if (impl(ghc >= 8.8))
ghc-options: -Wno-missing-deriving-strategies
library
import: common
hs-source-dirs: src
exposed-modules:
Analysis.Analysis
Analysis.Concrete
Analysis.File
Analysis.FlowInsensitive
Analysis.ImportGraph
Analysis.ScopeGraph
Analysis.Typecheck
Control.Carrier.Fail.WithLoc
Control.Carrier.Readline.Haskeline
Control.Effect.Readline
build-depends:
algebraic-graphs ^>= 0.3
, base >= 4.12 && < 5
, containers ^>= 0.6
, directory ^>= 1.3
, filepath ^>= 1.4
, fused-effects ^>= 0.5
, fused-syntax
, haskeline ^>= 0.7.5
, pathtype ^>= 0.8.1
, prettyprinter ^>= 1.2.1
, prettyprinter-ansi-terminal ^>= 1.1.1
, semantic-source ^>= 0
, terminal-size ^>= 0.3
, text ^>= 1.2.3.1

View File

@ -65,10 +65,6 @@ data Edge = Lexical | Import
deriving (Eq, Ord, Show)
-- | Concrete evaluation of a term to a value.
--
-- >>> map fileBody (snd (concrete eval [File (Path.absRel "bool") (Span (Pos 1 1) (Pos 1 5)) (Core.bool True)]))
-- [Right (Bool True)]
concrete
:: ( Foldable term
, IsString name
@ -230,10 +226,3 @@ data EdgeType term name
| Slot name
| Value (Concrete term name)
deriving (Eq, Ord, Show)
-- $setup
-- >>> :seti -XFlexibleContexts
-- >>> :seti -XOverloadedStrings
-- >>> import Core.Eval (eval)
-- >>> import qualified Core.Core as Core

View File

@ -40,53 +40,25 @@ library
import: common
hs-source-dirs: src
exposed-modules:
Analysis.Analysis
Analysis.Concrete
Analysis.File
Analysis.FlowInsensitive
Analysis.ImportGraph
Analysis.ScopeGraph
Analysis.Typecheck
Control.Carrier.Fail.WithLoc
Control.Carrier.Readline.Haskeline
Control.Effect.Readline
Core.Core
Core.Core.Parser
Core.Core.Pretty
Core.Parser
Core.Pretty
Core.Eval
Core.Name
build-depends:
algebraic-graphs ^>= 0.3
, base >= 4.12 && < 5
, containers ^>= 0.6
, directory ^>= 1.3
, filepath ^>= 1.4
base >= 4.12 && < 5
, fused-effects ^>= 0.5
, fused-syntax
, haskeline ^>= 0.7.5
, parsers ^>= 0.12.10
, pathtype ^>= 0.8.1
, prettyprinter ^>= 1.2.1
, prettyprinter-ansi-terminal ^>= 1.1.1
, semantic-analysis ^>= 0
, semantic-source ^>= 0
, semigroupoids ^>= 5.3
, terminal-size ^>= 0.3
, text ^>= 1.2.3.1
, transformers ^>= 0.5.6
, trifecta ^>= 2
, unordered-containers ^>= 0.2.10
test-suite doctest
import: common
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Doctest.hs
build-depends:
base >=4.9 && <4.13
, doctest >=0.7 && <1.0
, QuickCheck
, semantic-core
test-suite test
import: common
type: exitcode-stdio-1.0
@ -95,6 +67,7 @@ test-suite test
other-modules: Generators
build-depends:
base
, semantic-analysis
, semantic-core
, semantic-source ^>= 0
, fused-effects

View File

@ -1,5 +1,5 @@
{-# LANGUAGE FlexibleContexts, TypeOperators #-}
module Core.Core.Parser
module Core.Parser
( core
, lit
, expr

View File

@ -1,6 +1,6 @@
{-# LANGUAGE FlexibleContexts, LambdaCase, OverloadedStrings, TypeApplications #-}
module Core.Core.Pretty
module Core.Pretty
( showCore
, printCore
, showFile

View File

@ -1,12 +0,0 @@
module Main
( main
) where
import System.Environment
import Test.DocTest
main :: IO ()
main = do
args <- getArgs
autogen <- fmap (<> "/build/doctest/autogen") <$> lookupEnv "HASKELL_DIST_DIR"
doctest (maybe id ((:) . ("-i" <>)) autogen ("-isemantic-code/src" : "--fast" : if null args then ["semantic-core/src"] else args))

View File

@ -10,8 +10,8 @@ import Test.Tasty.HUnit
import Analysis.File
import Core.Core
import Core.Core.Pretty
import Core.Core.Parser as Parse
import Core.Pretty
import Core.Parser as Parse
import qualified Core.Eval as Eval
import Core.Name
import qualified Generators as Gen

View File

@ -74,6 +74,7 @@ test-suite test
, pretty-show ^>= 1.9.5
, process ^>= 1.6.5
, resourcet ^>= 1.2.2
, semantic-analysis ^>= 0
, streaming ^>= 0.2.2
, streaming-process ^>= 0.1
, streaming-bytestring ^>= 0.1.6

View File

@ -7,8 +7,8 @@ module Directive ( Directive (..)
import Control.Applicative
import Control.Monad
import Core.Core (Core)
import qualified Core.Core.Parser as Core.Parser
import qualified Core.Core.Pretty as Core.Pretty
import qualified Core.Parser as Core.Parser
import qualified Core.Pretty as Core.Pretty
import Core.Name (Name)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as ByteString

View File

@ -12,7 +12,7 @@ import Control.Monad.Catch
import Control.Monad.IO.Class
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
import Core.Core
import Core.Core.Pretty
import Core.Pretty
import qualified Core.Eval as Eval
import Core.Name
import qualified Data.Aeson as Aeson