1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00
Commit Graph

281 Commits

Author SHA1 Message Date
joshvera
073dca372d Remove Data.Abstract.Environment 2018-12-05 10:20:35 -05:00
Timothy Clem
343289f1c5 Merge remote-tracking branch 'origin/master' into docstrings-round2 2018-11-06 09:17:49 -08:00
Patrick Thomson
7ea52dbfe3 Give Control.Matching API better ergonomics.
Given that @tclem and I have found the matcher API frustrating, I've
taken a stab at improving its ergonomics, and I've found some success
in separating composition of matchers from predicate-based narrowing
thereof.

The biggest change here is the elimination of the old `match`
combinator, which proved to be clumsy in that it complected narrowing
and composition. Top-down matching combinators are now written with
the `need` combinator and the `>>>` combinator, which is more readable
and more versatile. Here's a matcher that accepts functions with
Python docstrings:

```haskell
docstringMatcher :: ( Decl.Function :< fs
                    , [] :< fs
                    , Lit.TextElement :< fs
                    , term ~ Term (Sum fs) ann
                    ) => Matcher term term
docstringMatcher = target <*
               (need Decl.functionBody
                >>> narrow @[]
                >>> mhead
                >>> narrow @Lit.TextElement
                >>> ensure Lit.isTripleQuoted))
```

Pretty readable, right? Each step of the tree regular expression -
choosing function bodies, ensuring said bodies are lists, examining
the first element, and choosing only TextElements containing
triple-quoted strings - is made implicit. The old way would have
looked something like this:

```haskell
docstringMatcher = target <* match Decl.functionBody
                           $ narrow
                           $ matchM listToMaybe
                           $ target <* ensure Lit.isTripleQuoted
```
which is a good deal more disorganized and less flexible
in the quite-common case of applying functions during a
matching pass. Separating the act of composition from
function application is a big win here.

Further comments are inline.
2018-11-02 19:25:29 -04:00
Timothy Clem
0f56f33f24 Introduce some symbol/tags tests 2018-11-02 13:55:30 -07:00
Patrick Thomson
b9cf8f73c6 Environment and App. 2018-10-31 15:47:30 -04:00
Patrick Thomson
d473b9e1af add Data/Abstract/Name/Spec 2018-10-31 13:19:43 -04:00
Patrick Thomson
b0e6190dbf add Data/Range/Spec 2018-10-31 12:46:52 -04:00
Patrick Thomson
cd05aaa7a5 add Data/Graph/Spec 2018-10-31 12:30:56 -04:00
Patrick Thomson
d1cc400dc0 add spec file 2018-09-14 13:10:22 -04:00
Patrick Thomson
dccea555ed Extremely ad-hoc renderer to Docs 2018-07-31 12:44:20 -04:00
Patrick Thomson
6823fb92b6 better module name 2018-07-31 10:43:46 -04:00
Patrick Thomson
a61fe301c4 Skeleton and initial test case 2018-07-30 16:00:09 -04:00
Patrick Thomson
0ed48c7bbe Simplest test possible. 2018-07-16 11:07:40 -04:00
Rob Rix
7e2f7614f7 Fix up the imports. 2018-07-10 14:17:56 -04:00
Rob Rix
1e6a3f71e2 Use withOptions in the spec. 2018-07-10 14:16:51 -04:00
Rob Rix
40d46e921d Pass the configuration to the analysis specs. 2018-07-10 14:09:22 -04:00
Rob Rix
255a0aa62b Move TaskConfig into Semantic.Util. 2018-07-10 14:09:02 -04:00
Rob Rix
b33daf0ce1 Pass the task config stuff around as a single datum. 2018-07-10 13:49:34 -04:00
Rob Rix
90cb86d027 Pass config & queues to the integration specs. 2018-07-09 14:26:15 -04:00
Patrick Thomson
f9f0dd5e79 Use a hand-written integer parser.
Rather than relying on the `Read` instance for `Integer`, let's make
our assumptions about the format explicit. This was mostly a matter of
extracting internal functions from the `Scientific` parser.
2018-06-25 11:55:32 -04:00
Patrick Thomson
fbff61b247 actually run the specs 2018-06-05 12:51:23 -04:00
Rob Rix
54150552b3 Merge branch 'master' into 🔥-galign 2018-05-29 08:53:37 -04:00
Rob Rix
c427be3670 Stub in a spec for Evaluator. 2018-05-07 14:21:05 -04:00
Timothy Clem
95b7fd5888 Resolve module import paths that walk up directory structure (e.g. ../) 2018-04-17 14:13:01 -07:00
Rob Rix
d863d282b1 🔥 the Mergeable spec. 2018-04-09 16:38:28 -04:00
Patrick Thomson
faf246ff1e Merge remote-tracking branch 'origin/master' into fix-scientific-parsing 2018-04-04 15:40:51 -04:00
Patrick Thomson
c36256e943 Standardize and fix floating-point parsing.
The existence of #1705 showed me that it's time to remove the bandaid
of a fix that was `normalizeFloatString` in #1537. This patch
introduces a proper Attoparsec parser for Scientific values that
handles the vaguaries of cross-language floating-point syntax. We
already depended on Attoparsec indirectly, so adding it as an explicit
dependency is fine.

A unit test is included, with examples taken from the tree-sitter corpora.
2018-04-03 17:02:56 -04:00
Timothy Clem
208d16e131 Disable import-graph specs for now 2018-04-03 10:12:20 -07:00
Patrick Thomson
034bb562d4 Introduce tree-automata DSL for filtering and matching ASTs.
This patch adds the `Matcher` monad, which is capable of filtering any
recursive data structure, bottom-up, yielding a list of (or an
optional) result. These functions are probably going to be used over
`Term` values, so API is provided to wrap common projection functions.

The API was more or less copied directly from that of Clang's AST
matching facilities.

There are a lot of things we can do in the future:
* Binding results yielded in matchers to associated names, for future
  transformation stages to look up and modify.
* Actual transformation stages.
* Optimizations. This is not very fast.

A million thanks to @robrix, whose sage advice managed to turn my
kooky idea for an API into something really special and exciting.
2018-03-27 16:14:30 -04:00
Timothy Clem
7fdc5e2fda Write a small spec for evaluating PHP includes 2018-03-19 14:42:31 -07:00
Timothy Clem
1e276dddef TDD FTW 2018-03-15 11:34:34 -07:00
Timothy Clem
579a447961 Test out go import evaling 2018-03-13 11:14:55 -07:00
Timothy Clem
38b7607fa3 Turn on the TypeScript analysis spec 2018-03-09 16:24:32 -08:00
Timothy Clem
d352c66227 Test out rest of python imports, move to new dir 2018-03-09 15:16:07 -08:00
Timothy Clem
3fc7f644b2 Try my hand at a spec for analysis - test out python imports 2018-03-09 15:01:29 -08:00
Timothy Clem
fb000828ed Test out import-graph output for relevant languages 2018-02-07 12:20:41 -08:00
Rob Rix
67f251e223 Combine the generic Eq1, Ord1, & Show1 implementations into a single module. 2017-11-30 10:24:48 -05:00
Rob Rix
bcb64b3187 Rename the Integration spec. 2017-11-27 14:06:12 -05:00
Rob Rix
59fc8bffc9 Rename the TOC spec. 2017-11-27 14:04:58 -05:00
Rob Rix
69595553d6 Rename the Interpreter spec. 2017-11-27 14:03:45 -05:00
Rob Rix
a442bfeea1 Rename the Term spec. 2017-11-27 14:02:03 -05:00
Rob Rix
a079638c5b Rename the Semantic spec. 2017-11-27 14:00:53 -05:00
Rob Rix
80fce5b41e Rename the Diff spec. 2017-11-27 13:59:44 -05:00
Rob Rix
4b06df7db4 Rename the Stat spec. 2017-11-27 13:58:23 -05:00
Rob Rix
59166b50bb Rename the CLI spec. 2017-11-27 13:57:25 -05:00
Rob Rix
b98375b58f Rename the IO spec. 2017-11-27 13:52:48 -05:00
Rob Rix
8a3d34a1fc Rename the SES spec. 2017-11-27 13:51:05 -05:00
Rob Rix
f4960b0a0d Rename the Source spec. 2017-11-27 13:49:52 -05:00
Rob Rix
266bd1199a Rename the RWS spec. 2017-11-27 13:48:43 -05:00
Rob Rix
a8e8489fcb Rename the assignment spec. 2017-11-27 13:47:04 -05:00