Skip to content

Commit 4aac5f8

Browse files
committed
🔥 semantic-core.
1 parent b92de8f commit 4aac5f8

30 files changed

+20
-250
lines changed

build/common.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def semantic_language_library(language, name, srcs, ts_package = "", nodetypes =
119119
"//:text",
120120
"//semantic-analysis",
121121
"//semantic-ast",
122-
"//semantic-core",
123122
"//semantic-proto",
124123
"//semantic-scope-graph",
125124
"//semantic-source",

cabal.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ packages: semantic
55
semantic-analysis
66
semantic-ast
77
semantic-codeql
8-
semantic-core
98
semantic-go
109
semantic-java
1110
semantic-json

cabal.project.ci

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ packages: semantic
55
semantic-analysis
66
semantic-ast
77
semantic-codeql
8-
semantic-core
98
semantic-go
109
semantic-java
1110
semantic-json
@@ -34,9 +33,6 @@ package semantic-ast
3433
package semantic-codeql
3534
ghc-options: -Werror
3635

37-
package semantic-core
38-
ghc-options: -Werror
39-
4036
package semantic-go
4137
ghc-options: -Werror
4238

docs/adding-new-languages.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Note that we recently transitioned the system to auto-generate strongly-typed AS
88

99
1. **Find or write a [tree-sitter](https://tree-sitter.github.io) parser for your language.** The tree-sitter [organization page](https://github.com/tree-sitter) has a number of parsers beyond those we currently support in Semantic; look there first to make sure you're not duplicating work. The tree-sitter [documentation on creating parsers](http://tree-sitter.github.io/tree-sitter/creating-parsers) provides an exhaustive look at the process of developing and debugging tree-sitter parsers. Though we do not support grammars written with other toolkits such as [ANTLR](https://www.antlr.org), translating an ANTLR or other BNF-style grammar into a tree-sitter grammar is usually straightforward.
1010
2. **Create a Haskell library providing an interface to that C source.** The [`haskell-tree-sitter`](https://github.com/tree-sitter/haskell-tree-sitter) repository provides a Cabal package for each supported language. You can find an example of a pull request to add such a package [here](https://github.com/tree-sitter/haskell-tree-sitter/pull/276/files), and a file providing:
11-
- A bridged (via the FFI) reference to the toplevel parser in the generated file must be provided ([example](https://github.com/tree-sitter/haskell-tree-sitter/blob/master/tree-sitter-json/TreeSitter/JSON.hs#L11)).
12-
- A way to retrieve [`tree-sitter` data](https://github.com/tree-sitter/haskell-tree-sitter/blob/master/tree-sitter-json/TreeSitter/JSON.hs#L13-L14) used to auto-generate syntax datatypes using the following steps. During parser generation, tree-sitter produces a `node-types.json` file that captures the structure of a language's grammar. The autogeneration described below in Step 4 derives datatypes based on this structural representation. The `node-types.json` is a data file in `haskell-tree-sitter` that gets installed with the package. The function `getNodeTypesPath :: IO FilePath` is defined to access in the contents of this file, using `getDataFileName :: FilePath -> IO FilePath`, which is defined in the autogenerated `Paths_` module.
11+
- A bridged (via the FFI) reference to the toplevel parser in the generated file must be provided ([example](https://github.com/tree-sitter/haskell-tree-sitter/blob/master/tree-sitter-json/TreeSitter/JSON.hs#L11)).
12+
- A way to retrieve [`tree-sitter` data](https://github.com/tree-sitter/haskell-tree-sitter/blob/master/tree-sitter-json/TreeSitter/JSON.hs#L13-L14) used to auto-generate syntax datatypes using the following steps. During parser generation, tree-sitter produces a `node-types.json` file that captures the structure of a language's grammar. The autogeneration described below in Step 4 derives datatypes based on this structural representation. The `node-types.json` is a data file in `haskell-tree-sitter` that gets installed with the package. The function `getNodeTypesPath :: IO FilePath` is defined to access in the contents of this file, using `getDataFileName :: FilePath -> IO FilePath`, which is defined in the autogenerated `Paths_` module.
1313
3. **Create a Haskell library in Semantic to auto-generate precise ASTs.** Create a `semantic-[LANGUAGE]` package. This is an example of [`semantic-python`](https://github.com/github/semantic/tree/master/semantic-python)). Each package needs to provide the following API surfaces:
1414
- `Language.[LANGUAGE].AST` - Derives Haskell datatypes from a language and its `node-types.json` file ([example](https://github.com/github/semantic/blob/master/semantic-python/src/Language/Python/AST.hs)).
1515
- `Language.[LANGUAGE].Grammar` - Provides statically-known rules corresponding to symbols in the grammar for each syntax node, generated with the `mkStaticallyKnownRuleGrammarData` Template Haskell splice ([example](https://github.com/github/semantic/blob/master/semantic-python/src/Language/Python/Grammar.hs)).
1616
- `Language.[LANGUAGE]` - Semantic functionality for programs in a language ([example](https://github.com/github/semantic/blob/master/semantic-python/src/Language/Python.hs)).
1717
- `Language.[LANGUAGE].Tags` - Computes tags for code nav definitions and references found in source ([example](https://github.com/github/semantic/blob/master/semantic-python/src/Language/Python/Tags.hs)).
18-
5. **Add tests for precise ASTs, tagging and graphing, and evaluating code written in that language.** Because tree-sitter grammars often change, we require extensive testing so as to avoid the unhappy situation of bitrotted languages that break as soon as a new grammar comes down the line. Here are examples of tests for [precise ASTs](https://github.com/github/semantic/blob/master/semantic-python/test/PreciseTest.hs), [tagging](https://github.com/github/semantic/blob/master/test/Tags/Spec.hs), and [graphing](https://github.com/github/semantic/blob/master/semantic-python/test-graphing/GraphTest.hs).
18+
5. **Add tests for precise ASTs, tagging and graphing, and evaluating code written in that language.** Because tree-sitter grammars often change, we require extensive testing so as to avoid the unhappy situation of bitrotted languages that break as soon as a new grammar comes down the line. Here are examples of tests for [precise ASTs](https://github.com/github/semantic/blob/master/semantic-python/test/PreciseTest.hs), [tagging](https://github.com/github/semantic/blob/master/test/Tags/Spec.hs), and [graphing](https://github.com/github/semantic/blob/master/semantic-python/test-graphing/GraphTest.hs).
1919

2020
To summarize, each interaction made possible by the Semantic CLI corresponds to one (or more) of the above steps:
2121

@@ -30,4 +30,4 @@ To summarize, each interaction made possible by the Semantic CLI corresponds to
3030

3131
**This sounds hard.** You're right! It is currently a lot of work: just because the Semantic architecture is extensible in the expression-problem manner does not mean that adding new support is trivial.
3232

33-
**What recent changes have been made?** The Semantic authors have introduced a new architecture for language support and parsing, one that dispenses with the [assignment](https://github.com/github/semantic/blob/master/docs/assignment.md) step altogether. The `semantic-ast` package generates Haskell data types from tree-sitter grammars; these types are then translated into the [Semantic core language](https://github.com/github/semantic/blob/master/semantic-core/src/Data/Core.hs); all evaluators will then be written in terms of the Core language. As compared with the [historic process]() used to add new languages, these changes entire obviate the process of 1) assigning types into an open-union of syntax functors, and 2) implementing `Evaluatable` instances and adding value effects to describe the control flow of your language.
33+
**What recent changes have been made?** The Semantic authors have introduced a new architecture for language support and parsing, one that dispenses with the [assignment](https://github.com/github/semantic/blob/master/docs/assignment.md) step altogether. The `semantic-ast` package generates Haskell data types from tree-sitter grammars. As compared with the [historic process]() used to add new languages, these changes entire obviate the process of 1) assigning types into an open-union of syntax functors, and 2) implementing `Evaluatable` instances and adding value effects to describe the control flow of your language.

script/ghci-flags

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ function flags {
5858
echo "-isemantic-ast/src"
5959
echo "-isemantic-codeql/src"
6060
echo "-isemantic-codeql/test"
61-
echo "-isemantic-core/src"
6261
echo "-isemantic-go/src"
6362
echo "-isemantic-java/src"
6463
echo "-isemantic-json/src"

script/ghci-flags-dependencies

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ echo "cabal.project"
1010
echo "semantic.cabal"
1111
echo "semantic-analysis/semantic-analysis.cabal"
1212
echo "semantic-ast/semantic-ast.cabal"
13-
echo "semantic-core/semantic-core.cabal"
1413
echo "semantic-tags/semantic-tags.cabal"
1514
echo "semantic-go/semantic-go.cabal"
1615
echo "semantic-java/semantic-java.cabal"

semantic-codeql/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Semantic support for CodeQL
22

3-
This package implements `semantic` support for CodeQL using the `semantic-core` intermediate language.
3+
This package implements `semantic` support for CodeQL.

semantic-codeql/semantic-codeql.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: 2.4
33
name: semantic-codeql
44
version: 0.0.0.0
55
synopsis: Semantic support for CodeQL.
6-
description: Semantic support for CodeQL using the semantic-core intermediate language.
6+
description: Semantic support for CodeQL.
77
homepage: https://github.com/github/semantic/tree/master/semantic-codeql#readme
88
bug-reports: https://github.com/github/semantic/issues
99
license: MIT

semantic-core/BUILD.bazel

Lines changed: 0 additions & 30 deletions
This file was deleted.

semantic-core/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

semantic-core/README.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

semantic-core/Setup.hs

Lines changed: 0 additions & 2 deletions
This file was deleted.

semantic-core/semantic-core.cabal

Lines changed: 0 additions & 54 deletions
This file was deleted.

semantic-core/src/Core/Eval.hs

Lines changed: 0 additions & 42 deletions
This file was deleted.

semantic-core/src/Core/Expr.hs

Lines changed: 0 additions & 51 deletions
This file was deleted.

semantic-go/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Semantic support for Go
22

3-
This package implements `semantic` support for Go using the `semantic-core` intermediate language.
3+
This package implements `semantic` support for Go.

semantic-go/semantic-go.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: 2.4
33
name: semantic-go
44
version: 0.0.0.0
55
synopsis: Semantic support for Go.
6-
description: Semantic support for Go using the semantic-core intermediate language.
6+
description: Semantic support for Go.
77
homepage: https://github.com/github/semantic/tree/master/semantic-go#readme
88
bug-reports: https://github.com/github/semantic/issues
99
license: MIT

semantic-php/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Semantic support for PHP
22

3-
This package implements `semantic` support for PHP using the `semantic-core` intermediate language.
3+
This package implements `semantic` support for PHP.

semantic-php/semantic-php.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: 2.4
33
name: semantic-php
44
version: 0.0.0.0
55
synopsis: Semantic support for PHP.
6-
description: Semantic support for PHP using the semantic-core intermediate language.
6+
description: Semantic support for PHP.
77
homepage: https://github.com/github/semantic/tree/master/semantic-php#readme
88
bug-reports: https://github.com/github/semantic/issues
99
license: MIT

semantic-python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Semantic support for Python
22

3-
This package implements `semantic` support for Python using the `semantic-core` intermediate language.
3+
This package implements `semantic` support for Python.

semantic-python/semantic-python.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: 2.4
33
name: semantic-python
44
version: 0.0.0.0
55
synopsis: Semantic support for Python.
6-
description: Semantic support for Python using the semantic-core intermediate language.
6+
description: Semantic support for Python.
77
homepage: https://github.com/github/semantic/tree/master/semantic-python#readme
88
bug-reports: https://github.com/github/semantic/issues
99
license: MIT

semantic-python/test/Instances.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
module Instances () where
1111

12-
-- Testing code depends on certain instances that we don't want to
13-
-- expose in semantic-core proper, yet are important enough that
14-
-- we should keep track of them in a dedicated file.
15-
1612
import Analysis.File
1713
import Data.Aeson
1814
import Data.Text (pack)

semantic-ruby/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Semantic support for Ruby
22

3-
This package implements `semantic` support for Ruby using the `semantic-core` intermediate language.
3+
This package implements `semantic` support for Ruby.

semantic-ruby/semantic-ruby.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: 2.4
33
name: semantic-ruby
44
version: 0.0.0.0
55
synopsis: Semantic support for Ruby.
6-
description: Semantic support for Ruby using the semantic-core intermediate language.
6+
description: Semantic support for Ruby.
77
homepage: https://github.com/github/semantic/tree/master/semantic-ruby#readme
88
bug-reports: https://github.com/github/semantic/issues
99
license: MIT

semantic-rust/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Semantic support for Rust
22

3-
This package implements `semantic` support for [Rust](https://www.rust-lang.org/) using the `semantic-core` intermediate language.
3+
This package implements `semantic` support for [Rust](https://www.rust-lang.org/).
44

55
## Generating AST
66

semantic-tags/semantic-tags.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: semantic-tags
44
version: 0.0.0.0
55
synopsis: Tags computation
66
description: Tags computation for ASTs derived from tree-sitter grammars.
7-
homepage: https://github.com/github/semantic/tree/master/semantic-core#readme
7+
homepage: https://github.com/github/semantic/tree/master/semantic-tags#readme
88
bug-reports: https://github.com/github/semantic/issues
99
license: MIT
1010
license-file: LICENSE

0 commit comments

Comments
 (0)