Commit graph

350 commits

Author SHA1 Message Date
Max Brunsfeld 360b188644 cli: Handle 'underline' styling when highlighting w/ HTML output 2020-02-20 09:35:46 -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
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 de8e3ee188 query: Allow multiple captures on a single node 2020-02-11 16:02:32 -08:00
Max Brunsfeld 5922064b75 node-types: Fix ambiguity warning on rustc 1.41 2020-02-10 10:26:12 -08:00
Max Brunsfeld e23f518915 highlight: add built-in support for carriage-return highlight 2020-01-28 14:47:21 -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 9f63139a10 Fix error when set_included_ranges is called with an invalid range list 2020-01-17 10:31:28 -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 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
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
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
Max Brunsfeld f0e4d630d5 Reliably avoid duplicate subtypes in node-types.json 2019-12-17 14:55:51 -08:00
Max Brunsfeld 3ac047679c Fix children.required when multiple nodes are aliased as the same 2019-12-16 12:39:57 -08:00
Max Brunsfeld 7c711c5537 Move the private functions in node_types.rs to the end of the file 2019-12-16 12:38:40 -08:00
Max Brunsfeld 5edf97bca9 Remove accidentally-commited garbage line in arg parsing config 2019-12-16 11:59:26 -08:00
Max Brunsfeld 9a0cfa2376 Fix 'required' field when rules with diff fields are aliased to look the same 2019-12-12 11:26:58 -08:00
Max Brunsfeld fc19312913 Fix node-types bugs involving aliases and external tokens 2019-12-12 10:06:18 -08:00
Max Brunsfeld 1b5ae380ce
Don't attempt to extract keywords that don't entirely match word token (#505) 2019-12-11 17:18:15 -08:00
Max Brunsfeld c2e253a4c8 Update unit test to reflect javascript query change 2019-12-10 13:24:36 -08:00
Max Brunsfeld a5a9000e29 generate: Ensure that field_map_slices array is long enough 2019-12-09 11:46:32 -08:00
Steven Kalt 09fb24c03d add encoding to web_ui.html (#504)
addressing #503 .
2019-12-06 19:28:08 -08:00
Max Brunsfeld 0cb2ef1082 Fix code paths that still conflated null characters with EOF 2019-12-06 15:29:03 -08:00
Max Brunsfeld d426f46087 Add unit test for symbols respecting simple aliases 2019-12-06 12:47:27 -08:00
Max Brunsfeld 7032dae4f6 Include alias symbols in unique symbol map 2019-12-06 12:11:09 -08:00
Max Brunsfeld bea6e0e28b cli: Generate parseres with the new ABI by default 2019-12-06 11:51:55 -08:00
Max Brunsfeld bd49fbab12 cli: Allow globs and exclusions (via '!' prefix) as args to parse 2019-12-06 11:41:21 -08:00
Max Brunsfeld 56c620c005 Store a mapping to ensure no two symbols map to the same metadata 2019-12-05 17:21:46 -08:00
Max Brunsfeld d6c7b243a7
Merge pull request #499 from tree-sitter/highlight-test
Add a system for testing syntax highlighting queries
2019-12-05 15:55:24 -08:00
Max Brunsfeld 4b9feccd13 Run syntax highlighting tests as part of the main test command
Also, allow `corpus` to be in the `test/corpus` directory, and expect 
highlighting tests to be in the `test/highlight` directory.
2019-12-05 15:28:16 -08:00
Max Brunsfeld 6dbfbaed07 Start work on a system for testing syntax highlighting 2019-12-05 09:45:54 -08:00
Max Brunsfeld c957a5b8e7 Add test for handling of too many states in query captures 2019-11-22 11:54:32 -08:00
Max Brunsfeld 5a979d1457 node-types: Add test for field merging with aliases
Co-Authored-By: Timothy Clem <timothy.clem@gmail.com>
2019-11-19 14:31:56 -08:00
Max Brunsfeld 1d63434664 Refactor node-type merging 2019-11-19 11:57:21 -08:00
Max Brunsfeld 5489bc4dc5 Fix small issues with merging node types
* Merge the `required` field with an 'and', not an 'or'
* Merge field info in addition to children info
2019-11-19 11:55:21 -08:00
Timothy Clem e2325102d1 No printing 2019-11-19 09:03:35 -08:00
Timothy Clem c346ce4a5e Try not to loose existing children 2019-11-18 14:48:24 -08:00
Timothy Clem 5c72642634 A test demonstrating the issue with named aliases 2019-11-18 14:47:48 -08:00
Max Brunsfeld 660efd8c0f Fix handling of token rules directly inside of alias, prec, or field.
Fixes #483
2019-11-15 10:53:17 -08:00
Max Brunsfeld d45b98c7d9 node-types - Fix duplicate when a terminal is aliased with the same name as a non-terminal 2019-11-14 09:31:25 -08:00
Max Brunsfeld 5767bbc806 Avoid generating C char literals with control characters
Fixes #487
2019-11-13 10:54:34 -08:00
Max Brunsfeld a2bbc7391b node-types: Fix handling of simple aliased inlined rules 2019-11-13 10:38:47 -08:00