Commit graph

2901 commits

Author SHA1 Message Date
Max Brunsfeld
33492ca9df query: Add not-eq? predicate in rust & wasm binding 2020-02-19 21:36:30 -08:00
Max Brunsfeld
f67c0526fd
Merge pull request #549 from tree-sitter/query-dot-operator
Add an 'immediate child' operator in queries
2020-02-19 13:24:25 -08:00
Max Brunsfeld
570b83e2b2 query: Add immediate child operator 2020-02-19 11:47:52 -08:00
Max Brunsfeld
950a89a525 query: Differentiate between wildcard '*' and named wildcard '(*)' 2020-02-19 09:42:29 -08:00
Max Brunsfeld
1d6ea51b63 query: Make * operator only match named nodes 2020-02-18 21:32:52 -08:00
Max Brunsfeld
55edafa946
Merge pull request #548 from alyssaverkade/add-explicit-language-linkage-to-parsers
Add a language linkage declaration to parsers
2020-02-18 21:24:53 -08:00
Alyssa Verkade
0e689657b7 Add a language linkage declaration to parsers
Previously, in order to compile a `tree-sitter` grammar that contained
c++ source in the parser (ie the `scanner.cc` file), you would have to
compile the `parser.c` file separately from the c++ files. For example,
in rust this would result in a `build.rs` close to the following:
```
extern crate cc;

fn main() {
  let dir: PathBuf = ["tree-sitter-ruby", "src"].iter().collect();

  cc::Build::new()
    .include(&dir)
    .cpp(true)
    .file(dir.join("scanner.cc"))
    // NOTE: must have a name that differs from the c static lib
    .compile("tree-sitter-ruby-scanner");

  cc::Build::new()
    .include(&dir)
    .file(dir.join("parser.c"))
    // NOTE: must have a name that differs from the c++ static lib
    .compile("tree-sitter-ruby-parser");
}
```

This was necessary at the time for the following grammars: `ruby`,
`php`, `python`, `embedded-template`, `html`, `cpp`, `ocaml`,
`bash`, `agda`, and `haskell`.

To solve this, we specify an `extern "C"` language linkage declaration
to the functions that must be linked against to compile a parser with the
scanner, making parsers linkable against c++ source.
On all major compilers (gcc, clang, and msvc) this should be the only
change needed due to the combination of clang and gcc both supporting
designated initialization for years and msvc 2019 adopting designated
initializers as a part of the C++20 conformance push.

Subsequently, for rust projects, the necessary `build.rs` would become
(which also brings these parsers into sync with the current docs):
```
extern crate cc;

fn main() {
  let dir: PathBuf = ["tree-sitter-ruby", "src"].iter().collect();

  cc::Build::new()
    .include(&dir)
    .cpp(true)
    .file(dir.join("scanner.cc"))
    .file(dir.join("parser.c"))
    .compile("tree-sitter-ruby");
}
```
2020-02-18 19:46:59 -08:00
Max Brunsfeld
1217f58b8d rust: 0.6.2 2020-02-17 22:37:12 -08:00
Max Brunsfeld
b2e79f6438 rust: In queries, allow set! w/ capture and constant 2020-02-14 20:50:07 -08:00
Max Brunsfeld
56e52c76f9 rust: Add Hash for Point, Range and Node 2020-02-13 16:03:02 -08:00
Max Brunsfeld
ca73cba5f0 Make underline-on-hover work for spans within links
Refs #535
2020-02-12 16:06:50 -08:00
Max Brunsfeld
1f53b7aba8
Merge pull request #536 from kramred/docs/external_link_icon_CC0
Modify styles to show icon for external links
2020-02-12 11:59:29 -08:00
Max Brunsfeld
f4132c90ec
Merge pull request #535 from kramred/docs/github_link
Add hyperlink to github repo in docs; below img of tree
2020-02-12 11:57:36 -08:00
Mark Schmitz
23b88b6ac4 Modify styles to show icon for external links
Icon is CC0, copyright by https://github.com/kramred
2020-02-12 19:40:43 +00:00
Mark Schmitz
3dafb373a8 Add hyperlink to github repo below img of tree
in sidebar, as suggested in https://github.com/tree-sitter/tree-sitter/issues/508
2020-02-12 16:20:03 +00:00
Max Brunsfeld
de8e3ee188 query: Allow multiple captures on a single node 2020-02-11 16:02:32 -08:00
Max Brunsfeld
631710bada Implement Default for Point, Eq for Node 2020-02-11 15:58:35 -08:00
Max Brunsfeld
d8c3f472d2 Fix fallout from ts_language_next_state fix 2020-02-10 12:00:58 -08:00
Max Brunsfeld
5922064b75 node-types: Fix ambiguity warning on rustc 1.41 2020-02-10 10:26:12 -08:00
Max Brunsfeld
096014cb3e Clean up ts_language_next_state 2020-02-07 14:06:14 -08:00
Max Brunsfeld
a1c3de1b99 rust: Add Language::node_kind_is_visible API 2020-01-31 12:04:18 -08:00
Max Brunsfeld
ee7c29346a Small cleanup 2020-01-29 16:48:36 -08:00
Max Brunsfeld
64996976f4 rust: Add Language::id_for_node_kind method 2020-01-29 16:48:08 -08:00
Max Brunsfeld
fcc6c70d5e
Merge pull request #531 from tree-sitter/highlight-carriage-returns
highlight: add built-in support for carriage-return highlight
2020-01-28 16:46:34 -08:00
Max Brunsfeld
e23f518915 highlight: add built-in support for carriage-return highlight 2020-01-28 14:47:21 -08:00
Max Brunsfeld
f049ba350f 0.16.4 2020-01-28 10:09:26 -08:00
Max Brunsfeld
2bc7e457df lib: 0.6.1 2020-01-28 09:27:10 -08:00
Max Brunsfeld
3814babfa8 Update error recovery test to reflect JS grammar changes 2020-01-28 09:16:36 -08:00
Max Brunsfeld
e232ed04d1 Fix lifetimes on QueryCursor methods
Closes #530
2020-01-28 09:14:09 -08:00
Max Brunsfeld
7de36a33eb Remove halt_on_error API 2020-01-27 15:36:09 -08:00
Max Brunsfeld
d06407aca2 Update highlight test for JSDoc grammar changes 2020-01-27 13:08:30 -08:00
Max Brunsfeld
3f109a3cb5 highlight: Fix logic for handling empty injections with no highlights 2020-01-27 12:32:37 -08:00
Max Brunsfeld
8dd68c360a Fix logic for generating unique symbol map
Previously, this didn't correctly handle the case where *multiple* 
symbols were all simply-aliased to the same *other* symbol.

Refs #500
2020-01-27 12:06:48 -08:00
Max Brunsfeld
9ffcb16392 Fix tree-balancing logic
Remove incorrect condition that would prevent balancing of repeating 
structures containing only tokens (nodes w/ no children).

Co-Authored-By: Rob Rix <robrix@github.com>
Co-Authored-By: Patrick Thomson <patrickt@users.noreply.github.com>
2020-01-23 10:26:53 -08:00
Max Brunsfeld
70e2a2c025 Add PHP parser to web playground 2020-01-17 13:30:02 -08:00
Max Brunsfeld
9f63139a10 Fix error when set_included_ranges is called with an invalid range list 2020-01-17 10:31:28 -08:00
Max Brunsfeld
de8877db35 0.16.3 2020-01-16 16:18:25 -08:00
Max Brunsfeld
7421836ee4 Improve cli error message on invalid glob 2020-01-16 16:17:33 -08:00
Max Brunsfeld
9d460e6d01
Merge pull request #525 from SKalt/add-field-rule-to-grammar-json-schema
added field-rule to grammar-schema.json
2020-01-16 16:06:48 -08:00
Max Brunsfeld
42407b5ea4
Merge pull request #526 from tree-sitter/change-highlight-injection-api
Tweak the query API for specifying *combined injections* for syntax highlighting
2020-01-16 14:47:19 -08:00
Max Brunsfeld
cf5a6c0b9f Test against branches of language repos w/ new injection queries 2020-01-16 12:49:00 -08:00
Max Brunsfeld
9dfd03e79a highlight: Sipmlify injection API w/ new injection.combined property 2020-01-16 12:43:31 -08:00
Max Brunsfeld
f3747863df Add ts_query_disable_pattern API 2020-01-15 17:08:55 -08:00
Max Brunsfeld
58617cfa0c Improve output format for query subcommand 2020-01-15 17:08:31 -08:00
Max Brunsfeld
3c4a24752b Tweak naming of TSQuery's pattern map variables 2020-01-15 17:08:07 -08:00
Steven Kalt
619d7cd65a
added field-rule to grammar-schema.json 2020-01-12 19:40:21 -05:00
Steven Kalt
e69430ae7d removed duplicate key (#521)
The key "required" was duplicated on "symbol-rule". I removed the more permissive copy.
2020-01-09 17:34:07 -08:00
Patrick Thomson
39bfcdf595 Fix build with MinGW tooling. (#514)
Courtesy of @Eli-Zaretskii, these fixes should unblock people from
building tree-sitter with MinGW.

I don't think this is an unreasonable maintenance burden, especially
given the Emacs project's interest in using tree-sitter, but
@maxbrunsfeld gets the final call.
2020-01-06 09:21:40 -08:00
Max Brunsfeld
9a73277389 web-ui: Load static files from disk if TREE_SITTER_BASE_DIR var is set 2019-12-19 11:23:14 -08:00
Max Brunsfeld
f53e7377dc Allow highlight to command to take glob patterns 2019-12-17 15:49:05 -08:00