1
1
mirror of https://github.com/github/semantic.git synced 2024-12-18 12:21:57 +03:00
Commit Graph

286 Commits

Author SHA1 Message Date
Rob Rix
4083829e12 Bind a different variable for the subrange. 2015-12-14 13:04:21 -05:00
Rob Rix
c115262f7f Share a single computation of the substring for each case. 2015-12-14 13:01:17 -05:00
Rob Rix
718399c7d9 Compute the substring once and only once. 2015-12-14 12:59:47 -05:00
Rob Rix
bf9aa915a3 Move rangesOfWordsFrom into Range.hs. 2015-12-14 12:44:48 -05:00
Rob Rix
8acc962ad2 Offset leaves’ ranges to get the substrings. 2015-12-14 12:40:08 -05:00
Rob Rix
bac6b696a5 Make leaves within the parent’s substring. 2015-12-14 12:39:56 -05:00
Rob Rix
dbce74368f Pass the start index to makeLeaf. 2015-12-14 12:39:09 -05:00
Rob Rix
41032f0399 We don’t need a $ here. 2015-12-14 12:37:23 -05:00
Rob Rix
6fc7632e93 Only pass the start index around. 2015-12-14 12:37:07 -05:00
Rob Rix
774f731ab1 Pass the source to makeLeaf. 2015-12-14 12:35:16 -05:00
Rob Rix
4dd9907130 Try negating the offset. 2015-12-14 12:34:18 -05:00
Rob Rix
4cd2b2db7a Parentheses are not required here. 2015-12-14 12:25:09 -05:00
Rob Rix
a239384831 Work within recursively smaller and smaller substrings.
This resolves the O(n²) behaviour we were seeing.
2015-12-14 12:24:55 -05:00
Rob Rix
79e4860c62 Pass the source & root to recursive invocations. 2015-12-14 12:18:58 -05:00
Rob Rix
039e5849ca Revert "Shadow the outer function’s name."
This reverts commit 4cb7c975334d540b9ef08d59724536d2bbd8fda0.
2015-12-14 12:17:35 -05:00
Rob Rix
c004eb739e Revert "Push the inner function out and operate within substrings."
This reverts commit 435ba7a2e35d9a4bb61413b91895b88bf3cb2be9.
2015-12-14 12:17:30 -05:00
Rob Rix
b08bb04767 Push the inner function out and operate within substrings. 2015-12-14 12:16:44 -05:00
Rob Rix
1c3db7ae47 Shadow the outer function’s name. 2015-12-14 12:15:55 -05:00
Rob Rix
ae047f3012 Reorder the parameters for partial application. 2015-12-14 12:15:28 -05:00
Rob Rix
6dbaf9f53a Replace wordy leaves in both terms. 2015-12-14 12:13:18 -05:00
Rob Rix
36747be406 Add a function replacing wordy leaves in a term with branches of per-word leaves. 2015-12-14 12:09:21 -05:00
Rob Rix
0944591fab Add a function computing the ranges of non-whitespace substrings within a string. 2015-12-14 12:08:33 -05:00
Rob Rix
9e8a6f8456 Default to the line by line parser. 2015-12-09 10:36:37 -05:00
Rob Rix
a75c1b0482 No need to reinvent fmap. 2015-12-09 10:18:52 -05:00
Rob Rix
da3634c59a parserForType returns a Parser.
This change moves the languages out of IO. I believe this to be correct
(as they should be referentially transparent) but we may wish to review
that carefully.
2015-12-09 10:11:30 -05:00
Rob Rix
d7f415da04 Move all of the tree-sitter stuff into its own module. 2015-12-09 09:58:15 -05:00
Rob Rix
dcbf7bafb7 Use the Parser type. 2015-12-09 09:50:55 -05:00
Rob Rix
49910d1d1e Render HTML to Html. 2015-12-07 14:34:58 -05:00
Rob Rix
a5e7341322 Push the let bindings out a bit. 2015-12-07 14:23:32 -05:00
joshvera
395cfde9aa takeExtension returns extensions with dots 2015-12-04 16:25:01 -05:00
joshvera
d7089ec506 Remove unused parser type 2015-12-03 15:54:41 -05:00
joshvera
395eee7f7c Merge remote-tracking branch 'origin/split-diffs-in-haskell' into select-grammar 2015-12-03 15:50:26 -05:00
joshvera
d43ced80f5 we just say ts_language_javascript 2015-12-03 15:34:41 -05:00
joshvera
79f2f94c2c Add ts_language_js as a language 2015-12-03 15:21:34 -05:00
joshvera
c20ea6ee78 Switch parsers on mediaType 2015-12-03 15:10:49 -05:00
joshvera
370fbe4819 remove duplicate imports 2015-12-03 14:03:10 -05:00
joshvera
2a063d3277 Move Range to a module 2015-12-02 21:40:34 -05:00
joshvera
1dd8d93ce1 use fromIntegral 2015-12-02 14:29:19 -05:00
Rob Rix
25b1756419 Populate the line range. 2015-12-01 15:04:23 -05:00
Rob Rix
1b5f6b848d stub line ranges in Info 2015-12-01 14:51:21 -05:00
Rob Rix
8600d7d71b Stub in split diff rendering. 2015-12-01 11:33:16 -05:00
Rob Rix
226dc1e966 Hide Data.Set.split. 2015-12-01 11:33:10 -05:00
Rob Rix
5512f48ee5 Add a --split option. 2015-12-01 11:32:52 -05:00
Rob Rix
f655c414f7 Bind the diff outside the output. 2015-12-01 11:26:46 -05:00
Rob Rix
bfb982f69e Only format unified diffs when --unified is used. 2015-12-01 11:24:33 -05:00
Rob Rix
e8609ba886 Remove files. 2015-12-01 11:22:28 -05:00
Rob Rix
0dbfbba869 Use the parsed arguments. 2015-12-01 11:22:26 -05:00
Rob Rix
250f52e01a Parse the args with our parser. 2015-12-01 11:19:40 -05:00
Rob Rix
2976bb1f18 Add a parser for our arguments. 2015-12-01 11:15:13 -05:00
Rob Rix
b98839393d Split the sources up into fields. 2015-12-01 11:15:05 -05:00
Rob Rix
3c1c4e6911 Add the model for our arguments. 2015-12-01 11:08:04 -05:00
Rob Rix
a2f190fb14 Export substring. 2015-11-27 12:49:46 -05:00
Rob Rix
4aa89bd919 Print out the unified diff. 2015-11-27 12:42:00 -05:00
Rob Rix
070e60f149 Alphabetical order. 2015-11-27 12:41:38 -05:00
Rob Rix
acfb27ba9b Diff things. 2015-11-27 12:22:05 -05:00
Rob Rix
908d6b9de0 Ingest Keyed nodes. 2015-11-27 09:19:40 -05:00
Rob Rix
1ecad15128 Import Data.Map again. 2015-11-27 09:19:09 -05:00
Rob Rix
854e2f7013 withNamedChildren returns name/child pairs. 2015-11-27 09:19:02 -05:00
Rob Rix
2353cf3798 Rename the parameter. 2015-11-26 16:28:17 -05:00
Rob Rix
0e68767028 Close over the function. 2015-11-26 16:27:57 -05:00
Rob Rix
fdc2942411 Just return the result directly. 2015-11-26 16:27:22 -05:00
Rob Rix
3b24a3cd34 Parsing returns a Term. 2015-11-26 16:25:55 -05:00
Rob Rix
ae7235eb69 Use withCString instead of copying and freeing. 2015-11-26 16:24:57 -05:00
Rob Rix
4fd4c66f08 Rename parse to documentToTerm. 2015-11-26 16:22:27 -05:00
Rob Rix
253c461b12 Handle the alloca in parse. 2015-11-26 16:22:01 -05:00
Rob Rix
f27f35c683 Better error messages. 2015-11-26 16:21:54 -05:00
Rob Rix
ac470d3fbb We no longer require a Storable instance for TSLength. 2015-11-26 16:17:25 -05:00
Rob Rix
8a2fac6816 Construct a singleton set. 2015-11-26 16:15:56 -05:00
Rob Rix
4505c0f7e3 Don’t qualify member and fromList. 2015-11-26 16:15:39 -05:00
Rob Rix
f6f4ea05ed Don’t import Data.Map. 2015-11-26 16:14:34 -05:00
Rob Rix
54e931eabe Handle the allocation within parseTreeSitterFile. 2015-11-26 16:09:16 -05:00
Rob Rix
be6dc5e627 Once more remove withAlloc. 2015-11-26 16:07:25 -05:00
Rob Rix
ab7fa792ed Use alloca instead of withAlloc. 2015-11-26 16:07:21 -05:00
Rob Rix
018f4dcbd5 Operate strictly recursively.
This means we’re ensured of using allocations solely within the scopes
in which they are valid.
2015-11-26 16:07:04 -05:00
Rob Rix
19818231f5 We can safely alloca the root. 2015-11-26 15:37:57 -05:00
Rob Rix
49133ad240 Don’t import Generic. 2015-11-26 14:03:57 -05:00
Rob Rix
aaf4164e92 Don’t derive Generic. 2015-11-26 14:03:53 -05:00
Rob Rix
4d314d6729 Don’t import GHC.Prim. 2015-11-26 14:02:33 -05:00
Rob Rix
755cae0ae4 Don’t import CStorable. 2015-11-26 14:01:46 -05:00
Rob Rix
f15af07f2e Don’t bother deriving CStorable. 2015-11-26 14:01:42 -05:00
Rob Rix
1e8c4b54ac Just cheer when we’re done. 2015-11-26 14:01:16 -05:00
Rob Rix
1df3b71e2c Rename the variable. 2015-11-25 18:42:21 -05:00
Rob Rix
5162128c40 What if malloc?
It no longer crashes, so, that’s cool.
2015-11-25 18:32:48 -05:00
Rob Rix
1eac4a8ab3 Fake out the storable instances. 2015-11-25 18:32:17 -05:00
Rob Rix
bf3fac3d53 What if these were records? 2015-11-25 18:32:05 -05:00
Rob Rix
b4bcc9ef47 Tidy up toTerm. 2015-11-25 18:31:54 -05:00
Rob Rix
d4d6210a19 Restore withAlloc. 2015-11-25 18:30:55 -05:00
Rob Rix
88e78d00d8 Fetch the node’s name once per node. 2015-11-25 17:11:43 -05:00
Rob Rix
7039beceea Return fast on empty children lists. 2015-11-25 17:09:42 -05:00
Rob Rix
caf06cef5e Don’t import the Haskell parser stuff. 2015-11-25 16:41:06 -05:00
Rob Rix
5158e28349 Up to but not including the count. 2015-11-25 15:22:18 -05:00
Rob Rix
4aadaae7b6 Convert name to a Haskell string. 2015-11-25 15:17:51 -05:00
Rob Rix
2fef254244 Disambiguate which member we mean. 2015-11-25 15:17:40 -05:00
Rob Rix
854225666b Produce Fixed nodes. 2015-11-25 15:10:49 -05:00
Rob Rix
3f97be8df8 Remove withAlloc. 2015-11-25 15:05:24 -05:00
Rob Rix
ac6173fd8a Just use alloca. 2015-11-25 15:05:10 -05:00
Rob Rix
debae6d3d4 Everything else is Indexed (for now). 2015-11-25 15:02:42 -05:00
Rob Rix
aa4de17445 Only use leaves for empty nodes. 2015-11-25 15:02:30 -05:00
Rob Rix
d6860a8934 Unpack the node and category another layer deep. 2015-11-25 15:02:11 -05:00
Rob Rix
855a8bc51b Annotate terms with ranges. 2015-11-25 12:56:22 -05:00
Rob Rix
3f5ce3806d Populate leaves with the substring for the node. 2015-11-25 12:54:42 -05:00
Rob Rix
8bc51c2f86 Compute a substring from a range. 2015-11-25 12:53:56 -05:00
Rob Rix
40a0bc0b91 Pass the contents of the file to toTerm. 2015-11-25 12:53:48 -05:00
Rob Rix
ba3e2d8256 Compute the range of a given node. 2015-11-25 12:51:11 -05:00
Rob Rix
c57dd1ef8f Return the position & size directly.
Copying into TSLengths ended up being worst of both worlds.
2015-11-25 12:50:22 -05:00
Rob Rix
93e05435e5 Import position/size functions. 2015-11-25 12:25:06 -05:00
Rob Rix
5667f4d687 That is not where these live. 2015-11-25 12:24:07 -05:00
Rob Rix
1bb38abd71 Generalize withNode to withAlloc. 2015-11-25 12:19:39 -05:00
Rob Rix
2d60fea921 Remove the Kliesli import as we don’t actually use it. 2015-11-25 12:08:30 -05:00
Rob Rix
0f059a4299 Retrieve the named children of a node. 2015-11-25 12:06:21 -05:00
Rob Rix
b39bc3e33e Produce a list of named children of a node. 2015-11-25 12:05:25 -05:00
Rob Rix
e87459d608 Import left-to-right Kliesli composition. 2015-11-25 12:05:05 -05:00
Rob Rix
17078ad865 Import the named child function. 2015-11-25 11:47:24 -05:00
Rob Rix
6c1688f7ef Retrieve the named child count. 2015-11-25 11:43:36 -05:00
Rob Rix
9b35bd7f24 Import the named child count. 2015-11-25 11:43:31 -05:00
Rob Rix
3744714c59 Move the productions into toTerm. 2015-11-25 11:12:16 -05:00
Rob Rix
333bba93c5 Flesh out toTerm. 2015-11-25 10:52:48 -05:00
Rob Rix
b1a419e6ee Pull toTerm out into global scope and parameterize by document. 2015-11-25 10:41:37 -05:00
Rob Rix
56ad4b9b9c Retrieve the node’s name. 2015-11-25 10:39:13 -05:00
Rob Rix
3460632ab9 Import ts_node_p_name. 2015-11-25 10:09:05 -05:00
Rob Rix
277971ba16 Just Ptr, not Foreign.Ptr. 2015-11-25 10:06:14 -05:00
Rob Rix
cc7041f0e8 Match any category in the definition of toTerm. 2015-11-25 10:01:07 -05:00
Rob Rix
12e6c223b0 Add sets of keyed/fixed productions. 2015-11-25 10:00:52 -05:00
Rob Rix
5aa7306b78 Unambiguous unfolding. 2015-11-25 09:56:26 -05:00
Rob Rix
c95d2099b6 Hide unfoldM. 2015-11-25 09:56:14 -05:00
Rob Rix
a147cffe11 Use withNode for the root. 2015-11-25 09:38:28 -05:00
Rob Rix
048b1cb98f Add a withNode function abstracting allocation & casting. 2015-11-25 09:37:44 -05:00
Rob Rix
ea490a3871 Rearrange the where clause &c. 2015-11-25 09:37:19 -05:00
Rob Rix
73c2ec7d33 Start unfolding a term. 2015-11-24 17:14:44 -05:00
Rob Rix
76784bf7e4 Extract parsing files. 2015-11-24 16:51:53 -05:00
Rob Rix
de65176a0a Use withForeignPtr to clean up the root node. 2015-11-24 16:46:42 -05:00
Rob Rix
8c0496fb95 Just leak the root node already. 2015-11-24 16:42:10 -05:00
Rob Rix
0effaae938 Allocate a root node I guess. 2015-11-24 16:40:47 -05:00
Rob Rix
eaf365f4f6 Import the bridged TSNode thing. 2015-11-24 16:39:42 -05:00
Rob Rix
76e086cf8c Implement Storable for TSLength. 2015-11-24 16:39:31 -05:00
Rob Rix
7879dccb63 TSNode’s fields are strict. 2015-11-24 14:35:56 -05:00
Rob Rix
2c5f17228b TSLength’s fields are strict. 2015-11-24 14:35:40 -05:00
Rob Rix
cc3fd398b9 Extra space. 2015-11-24 14:32:12 -05:00
Rob Rix
31de4ca26b Don’t use record syntax for TSNode. 2015-11-24 14:32:02 -05:00
Rob Rix
20b5fe1604 Don’t use record syntax for TSLength. 2015-11-24 14:31:41 -05:00
Rob Rix
778208b3b7 Nodes are product types. 2015-11-24 14:17:04 -05:00
Rob Rix
d60398f115 Include a node directly. 2015-11-24 14:16:56 -05:00
Rob Rix
ff5797fde5 TSLength is many things. 2015-11-24 14:13:41 -05:00
Rob Rix
3bc87b03aa Add a TSLength type. 2015-11-24 14:13:15 -05:00
Rob Rix
9b47c6af58 Fetch the root node.
This crashes; `TSNode` is not an opaque pointer to a struct, it’s
actually a product type.
2015-11-24 14:08:29 -05:00
Rob Rix
a97dc752d8 Try importing the root node getter. 2015-11-24 14:08:08 -05:00
Rob Rix
13bc8afef6 In fact, free the document first. 2015-11-24 13:53:42 -05:00
Rob Rix
86bf87b6a8 Free the document at the end too I guess. 2015-11-24 13:53:35 -05:00
Rob Rix
7ab0b76abf Import ts_document_free. 2015-11-24 13:53:13 -05:00
Rob Rix
c2cc953e9c Parse the document. 2015-11-24 13:52:45 -05:00