1
1
mirror of https://github.com/github/semantic.git synced 2024-11-23 08:27:56 +03:00

Add a semantic-json package.

This commit is contained in:
Rob Rix 2019-10-07 10:27:52 -04:00
parent 1ec330fbe4
commit 938be8f0d0
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
6 changed files with 95 additions and 0 deletions

View File

@ -1,6 +1,7 @@
packages: .
semantic-core
semantic-java
semantic-json
semantic-python
semantic-source
semantic-tags

21
semantic-json/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.

18
semantic-json/README.md Normal file
View File

@ -0,0 +1,18 @@
# semantic-json
Semantic support for JSON.
## Development
This project consists of a Haskell package named `semantic-json`. The librarys sources are in [`src`][].
Development of `semantic-json` 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-json/src

2
semantic-json/Setup.hs Normal file
View File

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

View File

@ -0,0 +1,41 @@
cabal-version: 2.4
name: semantic-json
version: 0.0.0.0
synopsis: Semantic support for JSON
description: Semantic support for JSON.
homepage: https://github.com/github/semantic/tree/master/semantic-json#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
library
exposed-modules:
Language.JSON
build-depends:
base >= 4.12 && < 5
, tree-sitter ^>= 0.4
, tree-sitter-json ^>= 0.3
hs-source-dirs: src
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

View File

@ -0,0 +1,12 @@
-- | Semantic functionality for JSON programs.
module Language.JSON
( Term(..)
) where
import qualified TreeSitter.JSON.AST as JSON
import qualified TreeSitter.Unmarshal as TS
newtype Term a = Term { getTerm :: JSON.Document a }
instance TS.Unmarshal Term where
unmarshalNode node = Term <$> TS.unmarshalNode node