Commit graph

6118 commits

Author SHA1 Message Date
Patrick Thomson
f41e13f5da Spacing and word choice. 2022-02-11 15:41:53 -05:00
Patrick Thomson
88822bd3fc Move this to its own page. 2022-02-11 15:25:50 -05:00
Patrick Thomson
302c8b5305 Move this inside the query section. 2022-02-11 11:25:11 -05:00
Patrick Thomson
8dfed40466 Describe naming conventions for syntax captures. 2022-02-11 11:17:18 -05:00
fengT-T
149bae5774
Fix: Set https proxy for npm cli install script 2022-02-06 22:11:53 +08:00
Max Brunsfeld
5ef4ef4e2e lib: 0.20.4 2022-02-04 13:13:21 -08:00
Max Brunsfeld
84c1c6a271
Merge pull request #1640 from tree-sitter/goto-to-first-child-for-byte-gte
Change cursor `goto_first_child_for_{byte,point}` methods to treat nodes' ranges inclusively
2022-02-04 13:12:14 -08:00
Max Brunsfeld
cb4317ba8e Change goto_first_child_for_{byte,point} to compare nodes' ranges inclusively
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2022-02-04 12:38:33 -08:00
Max Brunsfeld
714bfd47a7 0.20.4 2022-01-23 10:46:04 -08:00
Max Brunsfeld
994cb61f2c Always generate parser.h, regardless of chosen ABI version
For some ABI changes, we may need to make changes to the parser.h in order
to restore a previous binary format, but for the current range of supported
ABI versions (13 + 14), the current parser.h is fine.

Refs #1599
2022-01-23 10:29:52 -08:00
Amin Yahyaabadi
94ffcdadf3 Mark stack__iter as static
Fixes
```
warning: In file included from src\lib.c:14:
warning: src/./stack.c:311:9: warning: static function 'ts_stack__add_slice' is used in an inline function with external linkage [-Wstatic-in-inline]
warning:         ts_stack__add_slice(
warning:         ^
warning: src/./stack.c:274:1: note: use 'static' to give inline function 'stack__iter' internal linkage
warning: inline StackSliceArray stack__iter(Stack *self, StackVersion version,
warning: ^
warning: static
warning: src/./stack.c:15:16: note: expanded from macro 'inline'
warning: #define inline __forceinline
warning:                ^
warning: src/./stack.c:258:13: note: 'ts_stack__add_slice' declared here
warning: static void ts_stack__add_slice(Stack *self, StackVersion original_version,
warning:             ^
warning: 1 warning generated.
    Finished dev [unoptimized + debuginfo] target(s) in 2.01s
```
2022-01-21 22:39:38 -08:00
Amin Yahyaabadi
6e0c49305e Use ISO C and C++ conformant name: _fdopen on windows
Fixes
```
warning: In file included from src\lib.c:12:
warning: src/./parser.c:1781:28: warning: 'fdopen' is deprecated: The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _fdopen. See online help for details. [-Wdeprecated-declarations]
warning:     self->dot_graph_file = fdopen(fd, "a");
warning:                            ^
warning: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\stdio.h:2431:28: note: 'fdopen' has been explicitly marked deprecated here
warning:         _Check_return_     _CRT_NONSTDC_DEPRECATE(_fdopen)    _ACRTIMP FILE* __cdecl fdopen(_In_ int _FileHandle, _In_z_ char const* _Format);
warning:                            ^
warning: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt.h:414:50: note: expanded from macro '_CRT_NONSTDC_DEPRECATE'
warning:         #define _CRT_NONSTDC_DEPRECATE(_NewName) _CRT_DEPRECATE_TEXT(             \
warning:                                                  ^
warning: C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.29.30133\include\vcruntime.h:310:47: note: expanded from macro '_CRT_DEPRECATE_TEXT'
warning: #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
```
2022-01-21 22:39:24 -08:00
Max Brunsfeld
3ff5c19403 0.20.3 2022-01-21 16:36:45 -08:00
Max Brunsfeld
fab8540508 libs: 0.20.3 2022-01-21 16:35:37 -08:00
Max Brunsfeld
82ceebc10d 🎨 Use base struct syntax to clean up grammar expectations 2022-01-20 17:17:46 -08:00
Max Brunsfeld
584b55df8d Delete unused code, tweak whitespace 2022-01-19 16:54:57 -08:00
Max Brunsfeld
fce23d63b3
Merge pull request #1602 from the-mikedavis/md-ignore-future-matches-for-non-local-patterns
prevent future captures for `#is-not? local` matches
2022-01-19 16:40:30 -08:00
Michael Davis
02abc2a063
add test for removals in eager query matches 2022-01-18 20:54:55 -06:00
Michael Davis
a3609aa07e
remove non-local query matches for locals 2022-01-18 17:04:00 -06:00
Michael Davis
716ef24578
remove unfinished queries from 'ts_query_cursor_remove_match' 2022-01-18 17:01:07 -06:00
Michael Davis
51354ef776
use just an i32 to ignore match IDs 2022-01-17 22:20:05 -06:00
Michael Davis
83ef0aea12
prevent future matches for '#is-not? local' patterns 2022-01-17 22:03:09 -06:00
Max Brunsfeld
2346570901
Merge pull request #1601 from alex-pinkus/fix-abi-14-struct-ordering
Fix ABI 14 back compat by moving primary_field_ids to the end
2022-01-17 18:02:35 -08:00
Alex Pinkus
858ea5782b Fix back compat by moving primary_field_ids to the end
Due to an oversight in #1589, I added `primary_field_ids` into the
`TSLanguage` struct in a place that wasn't the end. This is not actually
backwards compatible and causes downstream failures :(
2022-01-17 17:23:02 -08:00
Max Brunsfeld
691469c783
Merge pull request #1599 from tree-sitter/abi-version-flag
Add `--abi` flag to the generate command, generate version 13 by default
2022-01-17 15:41:28 -08:00
Max Brunsfeld
516fd6f6de Add --abi flag to generate command, generate version 13 by default 2022-01-17 14:50:47 -08:00
Max Brunsfeld
aaf4572727
Merge pull request #1589 from alex-pinkus/deduplicate-core-ids
Ignore duplicate states when initializing subgraphs in `ts_query__analyze_patterns`
2022-01-17 13:54:31 -08:00
Alex Pinkus
eaf9b170f1 Don't start with duplicate states in ts_query__analyze_patterns
This change exposes a new `primary_state_ids` field on the `TSLanguage`
struct, and populates it by tracking the first encountered state with a
given `core_id`. (For posterity: the initial change just exposed
`core_id` and deduplicated within `ts_analyze_query`).

With this `primary_state_ids` field in place, the
`ts_query__analyze_patterns` function only needs to populate its
subgraphs with starting states that are _primary_, since non-primary
states behave identically to primary ones. This leads to large savings
across the board, since most states are not primary.
2022-01-16 11:17:47 -08:00
Max Brunsfeld
e96ee19901
Merge pull request #1504 from hendrikvanantwerpen/expose-capture-suffixes
Expose capture suffixes in queries
2022-01-14 12:11:25 -08:00
Max Brunsfeld
9df064c9fe
Merge pull request #1581 from tlaplus-community/get-codepoint-column
`get_column` now counts codepoints instead of bytes
2022-01-12 10:49:44 -08:00
Andrew Helwer
e1ee261181 Changed decimal unicode codepoint to hex 2022-01-11 19:15:36 -05:00
Hendrik van Antwerpen
9dace8f9fe Add explicit breaks to prevent fall through errors 2022-01-11 19:08:32 +01:00
Hendrik van Antwerpen
c76d8ee076 Represent quantifiers using bytes instead of ints 2022-01-11 18:41:33 +01:00
Hendrik van Antwerpen
70aee901ac Reduce error handling logic 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
acd3d32c36 Remove reference to strings from quantifier-only function 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
99e74fa0f5 Move quantifier addition out of loop and drop conditional 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
93db863729 Remove obsolete FIXMEs 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
ec9b00e5c6 Handle multiple top-level alternations correctly 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
8b28f3a8c4 Shorten quantifier operations by using early returns 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
e338726cde Prefix globally visible TSquantifier values 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
36f2440369 Complete comment 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
ae2ac3c0db Initialize variable to silence compiler warnings 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
a1a241b013 Expose quantifiers per pattern, instead of merging for all patterns in a query 2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
1d513bcf67 Rewrite quantifier oeprations
- Simplify control flow by having a single return at the end of the function.
- Follow enum order for case order.
2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
1f1a449c76 Improve capture quantifier computation
Compute quantifiers in a bottom-up manner, which allows more precise
results for alternations, where the quantifiers are now precisly joined.
2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
9bac066330 Deal with quantifiers appearing on capture's enclosing patterns
- Use a proper enum type for quantifiers.
- Drop quantifiers from `TSQueryStep`, which was not used.
- Keep track of the captures introduced during a pattern parse, and
  apply the quantifier for the pattern to the captures that were
  introduced by the pattern or any sub patterns.
- Use 'quantifier' instead of 'suffix'.
2022-01-11 18:33:36 +01:00
Hendrik van Antwerpen
ae7869d1a6 Expose capture suffixes in queries 2022-01-11 18:33:36 +01:00
Andrew Helwer
69ff091a87 Added includes for macos 2022-01-11 12:31:41 -05:00
Max Brunsfeld
bf210f0c9e
Merge pull request #1578 from alex-pinkus/analysis-state-set-pointers
Improve `ts_query_new` performance using pointer indirection
2022-01-11 09:13:36 -08:00
Andrew Helwer
5a6530a413 Added tests 2022-01-11 12:05:37 -05:00