Commit graph

196 commits

Author SHA1 Message Date
Amaan Qureshi
2c192fa038
feat!: introduce parser introspection via the repo's Semantic Version baked in 2024-02-12 02:27:17 -05:00
dundargoc
ff367ebf4c build: enable -pedantic
Co-authored-by: Patrick Thomson <patrickt@github.com>
2024-02-08 16:12:54 +01:00
dundargoc
df1fe842eb docs: various fixes
Closes https://github.com/tree-sitter/tree-sitter/issues/1317.
Closes https://github.com/tree-sitter/tree-sitter/issues/1752.
Closes https://github.com/tree-sitter/tree-sitter/issues/2439.

Co-authored-by: Simon Hengel <sol@typeful.net>
Co-authored-by: Akash Yadav <itsaky01@gmail.com>
Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
Co-authored-by: Laytan Laats <laytanlaats@hotmail.com>
2024-02-08 00:08:59 +01:00
Max Brunsfeld
3c66dd2d6c Add missing language return in ts_query_new
Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Joseph <joseph@zed.dev>
2024-01-25 11:06:54 -08:00
Max Brunsfeld
4a8e4b1963 Allow wasm languages to be deleted 2023-12-27 15:00:16 -08:00
Andrew Hlynskyi
0d26309c41
Revert "chore(lib): fix fields naming in QueryPattern to singular" 2023-11-28 02:30:01 +02:00
MrPrezident
3c4957e940 fix "test_point_range_captures not working"
Fix for https://github.com/tree-sitter/py-tree-sitter/issues/105
2023-11-12 20:58:51 -06:00
Andrew Hlynskyi
055c329a69 chore(lib): fix fields naming in QueryPattern to singular 2023-09-02 21:08:54 +03:00
Amaan Qureshi
5c7098dd56
fix(query): debug print uses wrong variable 2023-08-22 19:22:31 -04:00
Andrew Hlynskyi
26c3ae7b98 Rename: ts_lookahead_iterator_advance -> ts_lookahead_iterator_next 2023-08-09 14:40:29 +03:00
Samuel Moelius
41ec8b4166 Partially revert d4d5e29 2023-08-03 11:41:50 +03:00
Amaan Qureshi
13f6ec2b0c
fix: rename shadowed variables from -Wshadow warnings and apply some useful clang-tidy warnings 2023-07-19 18:12:26 -04:00
Amaan Qureshi
8f73fb502f
Merge pull request #2408 from amaanq/codeql-bugs
fix(lib): explicitly cast numbers to the same size in potential spots for infinite loops
2023-07-19 16:11:43 -04:00
Amaan Qureshi
753fa1c3ff
fix(lib): explicitly cast numbers to the same size in potential spots for infinite loops 2023-07-19 03:49:14 -04:00
Samuel Moelius
a07cdb59f3
Handle edge cases involving consecutive "zero or" modifiers 2023-07-19 03:27:43 -04:00
Max Brunsfeld
40f7b2ec97 Fix parsing of queries that start with repetitions followed by alternatives 2023-07-18 17:57:52 -07:00
Amaan Qureshi
c16a8c71ce
fix: pass a value_id the same size of predicate_capture_ids's elements to avoid big-endian integer narrowing
This solves a bug on big-endian architectures where the value would be later passed by reference as an elements "view" before being inserted. The issue is it is casted as a void pointer, and when writing uint16_t's of size 1, only 2 of the 4 bytes are written. This is okay for little-endian systems, but not big-endian
2023-07-18 05:40:38 -04:00
Max Brunsfeld
356f68293a Fix false positive query match bug, introduced in #2085 2023-07-10 16:12:59 -04:00
Philipp Mildenberger
55a8db10cc fix: bug with first child group anchor (anchor had no effect) 2023-05-13 19:40:49 +03:00
Andrew Hlynskyi
4f4b86a40b lib: make query step init depend from MAX_STEP_CAPTURE_COUNT decl 2023-04-19 09:37:46 +03:00
Andrew Hlynskyi
d4d5e29c91 feat(lib): ts_query_cursor_set_max_start_depth - use 0 to reset 2023-04-17 11:16:04 +03:00
Lewis Russell
1e81a1b67f feat(lib): add ts_query_cursor_set_max_start_depth query API
This allows configuring cursors from traversing too deep into a tree.
2023-04-17 11:15:13 +03:00
Andrew Hlynskyi
4c2a36302b lib: fix OOB in query engine reported in #2162 2023-04-06 03:59:55 +03:00
Matt
65c16bfb17 query casts 2023-04-04 17:43:27 +03:00
Max Brunsfeld
837899e456 Add API for checking if a pattern in a query is non-local 2023-02-16 11:59:34 -08:00
Max Brunsfeld
40703f110c Fix bug in maintenance of query cursor's tree depth 2023-02-16 11:59:34 -08:00
Max Brunsfeld
fa869cf3ed Restructure query_cursor_advance to explicitly control which hidden nodes it descends into 2023-02-16 11:59:34 -08:00
Max Brunsfeld
189cf6d59d Group analysis state sets into QueryAnalysis struct 2023-02-16 11:59:34 -08:00
Max Brunsfeld
32ce1fccd0 Precompute the set of repetition symbols that can match rootless patterns 2023-02-16 11:59:34 -08:00
Matt
8751fa0853
Add explicit casting for array capacities 2022-09-21 15:52:44 -04:00
Max Brunsfeld
6b87326470
Merge pull request #1787 from kianmeng/fix-typos
Fix typos
2022-08-25 10:25:39 -07:00
Sebastian Lackner
2174288e30 query: Use uint16_t for production_id in AnalysisSubgraphNode struct 2022-07-26 21:50:38 +02:00
Max Brunsfeld
79eaa68793 Don't match nested wildcard patterns against error nodes 2022-07-07 18:11:52 -07:00
Max Brunsfeld
548c12fb88 Fix bug where patterns with top-level alternatives were not considered 'rooted' 2022-07-07 17:53:54 -07:00
Max Brunsfeld
1401767689 query: Don't attempt to match top-level sibling patterns directly in ERROR nodes
Co-authored-by: Keith Simmons <keith@zed.dev>
2022-07-07 15:27:00 -07:00
Kian-Meng Ang
b8552ec6c4 Fix typos 2022-06-28 19:57:42 +08:00
Max Brunsfeld
58b719541b Fix failure to match queries with wildcard at root with range restrictions 2022-06-22 15:54:06 -07: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
716ef24578
remove unfinished queries from 'ts_query_cursor_remove_match' 2022-01-18 17:01:07 -06: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
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
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