Niranjan Hasabnis
c31acb8fec
Changing API name; Adding unit test and Rust bindings
2021-05-21 01:50:10 +00:00
Niranjan Hasabnis
e2b8130f62
Merge branch 'tree-sitter:master' into nhasabni/ts_node_child_field_name
2021-05-20 16:35:52 -07:00
Markus F.X.J. Oberhumer
cc519b3121
cli: Improve const-correctness of the generated parsers (part 2 of 2).
...
This is a follow-up to my previous commit 1badd131f9 .
I've made this an extra patch as it requires a minor
API change in <tree_sitter/parser.h>.
This commit moves the remaining generated tables into
the read-only segment.
Before:
$ for f in bash c cpp go html java javascript jsdoc json php python ruby rust; do \
gcc -o $f.o -O2 -Ilib/include -c test/fixtures/grammars/$f/src/parser.c; \
done
$ size --totals *.o
text data bss dec hex filename
5353477 24472 0 5377949 520f9d (TOTALS)
After:
$ for f in bash c cpp go html java javascript jsdoc json php python ruby rust; do \
gcc -o $f.o -O2 -Ilib/include -c test/fixtures/grammars/$f/src/parser.c; \
done
$ size --totals *.o
5378147 0 0 5378147 521063 (TOTALS)
2021-05-19 12:49:57 +02:00
Niranjan Hasabnis
dffee22736
Adding API to get field name of a TSNode
...
This PR adds an API to get name of the field of TSNode's child.
It uses same set of arguments as that of ts_node_child, but returns
field name if it is found, otherwise it returns NULL.
This API is useful to implement custom printing of S-expressions such
as following:
"(binary_expression
(binary_expression_left (identifier))
(binary_expression_operator ("+"))
(binary_expression_right (identifier)
)"
Currently, ts_node_string does not allow any customization for printing.
2021-05-15 00:20:18 +00:00
Max Brunsfeld
db6e1d9bdc
Add ts_query_cursor_did_exceed_match_limit API
2021-03-05 15:02:49 -08:00
Max Brunsfeld
592fd8678d
Organize TSLanguage fields
...
Due to the breaking ABI change in #943 , this is our chance
to reorder the fields in a more logical way.
2021-03-01 10:27:22 -08:00
Max Brunsfeld
c1639cc456
Add production_id_count field to Language objects
...
I think this is the last additional field that's needed so
that every array member of TSLanguage has a length that
can be calculated at runtime.
2021-02-25 16:32:05 -08:00
Max Brunsfeld
774ae5e3d5
In parse tables, store production ids as 16 bits
...
Also remove the use of bitfields from the parse table format.
In all cases, bitfields were not necessary to achieve the
current binary sizes. Avoiding them makes the binaries more
portable.
There was no way to make this change backward-compatible,
so we have finally dropped support for parsers generated
with an earlier version of Tree-sitter.
At some point, when Atom adopts this version of Tree-sitter,
this change will affect Atom users who have installed packages
using third-party Tree-sitter parsers. The packages will need
to be updated to use a regenerated version of the parsers.
2021-02-25 16:12:31 -08:00
Hansraj Das
000455ee79
Multiple typo fixes
...
* This is a patch from neovim PR: https://github.com/neovim/neovim/pull/13063
2020-10-11 13:02:40 +05:30
Max Brunsfeld
b5a9adb555
Allow queries to match on supertypes
...
Co-authored-by: Ayman Nadeem <aymannadeem@github.com>
2020-09-21 12:34:48 -07:00
Max Brunsfeld
2eb04094f8
Handle aliased parent nodes in query analysis
2020-08-21 14:12:04 -07:00
Max Brunsfeld
9daec9cb22
Tweak impossible pattern error messages
2020-08-20 13:35:11 -07:00
Max Brunsfeld
4301110c12
query: Indicate specific step that's impossible
2020-08-20 13:06:38 -07:00
Max Brunsfeld
cc37da7457
Query analysis: fix propagation of uncertainty from later siblings
2020-06-26 16:46:12 -07:00
Max Brunsfeld
7f955419a8
Start work on recognizing impossible patterns
2020-06-25 15:06:27 -07:00
Max Brunsfeld
4c2f36a07b
Mark steps as definite on query construction
...
* Add a ts_query_pattern_is_definite API, just for debugging this
* Store state_count on TSLanguage structs, to allow for scanning parse tables
2020-06-25 15:06:27 -07:00
Riccardo Schirone
780e9cecc9
Do not use multiple unnamed structs inside of unions
2020-04-29 20:42:45 +02:00
Max Brunsfeld
7de36a33eb
Remove halt_on_error API
2020-01-27 15:36:09 -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
f3747863df
Add ts_query_disable_pattern API
2020-01-15 17:08:55 -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
ce633a85c6
Improve ts_language_symbol_for_name function
2019-11-15 14:21:13 -08:00
Max Brunsfeld
d68dfa78b2
Add misssing docs to rust binding
2019-11-08 12:29:26 -08:00
Max Brunsfeld
a7824cf59d
Fix docs for ts_node_is_extra
...
Fixes #446
2019-11-05 09:49:16 -08:00
Max Brunsfeld
d765332c61
Don't rely on new eof ABI in parsers unless --next-abi is passed
2019-10-31 14:32:50 -07:00
Max Brunsfeld
d3b7caa565
Add a TSLexer.eof() API, use it in generated parsers
2019-10-31 14:11:52 -07:00
Max Brunsfeld
42dfba29c6
Make ts_tree_get_changed_ranges less confusing
2019-10-28 15:33:41 -07:00
Björn Linse
124ae30138
fix invalid docs for ts_tree_get_changed_ranges
2019-10-25 21:19:33 +02:00
Max Brunsfeld
f490befcde
Add ts_query_disable_capture API
2019-10-14 12:30:22 -07:00
Max Brunsfeld
9872a083b7
rust: Change QueryCursor::captures to expose the full match
2019-10-03 12:45:58 -07:00
Björn Linse
15e3bc7fd2
Fix some compiler warnings regarding function prototypes
2019-09-22 11:49:44 +02:00
Max Brunsfeld
82955759c0
Add an API for getting a pattern's start offset in the source code
2019-09-17 16:19:58 -07:00
Max Brunsfeld
1af85dc3f7
Remove unused APIs, expand docs for predicate API
2019-09-16 15:00:32 -07:00
Max Brunsfeld
096126d039
Allow predicates in queries, to match on nodes' text
2019-09-15 22:06:51 -07:00
Max Brunsfeld
a1fec71b19
Tweak QueryCursor to allow iterating either matches or captures
...
For syntax highlighting, we want to iterate over all of the captures in
order, and don't care about grouping the captures by pattern.
2019-09-13 15:19:04 -07:00
Max Brunsfeld
c71de5bd81
Tweak query interface
...
* Rename TSQueryContext -> TSQueryCursor
* Remove the permanent association between the cursor and its query. The
cursor can now be used again for a different query.
2019-09-11 17:33:48 -07:00
Max Brunsfeld
c8c75782e3
Allow tree queries to execute within a limited range
2019-09-11 16:49:29 -07:00
Max Brunsfeld
fe7c74e7aa
Start work on an API for querying trees
2019-09-10 20:53:57 -07:00
Max Brunsfeld
09a2755399
Store parse states with few lookahead symbols in a more compact way
2019-08-29 15:52:23 -07:00
Max Brunsfeld
e4873191d6
Refactor generated lex function to use fewer instructions per state
2019-06-20 09:57:38 -07:00
Max Brunsfeld
28011b1e60
Add ts_node_is_extra API
2019-06-19 15:58:29 -07:00
Andrey Zaytsev
7f2233ddaf
Ts tree cursor copy ( #363 )
...
* add ts_tree_cursor_copy fn
* indentation
2019-06-16 10:52:37 -07:00
Max Brunsfeld
f30485f9f4
Fix accidentally-removed functions in api.h
2019-03-29 23:05:02 -07:00
Max Brunsfeld
00968db983
Add documentation to api.h
...
Fixes #166
2019-03-29 16:50:05 -07:00
Max Brunsfeld
5035e194ff
Merge branch 'master' into node-fields
2019-03-26 11:58:21 -07:00
Max Brunsfeld
82358d3f2f
Merge pull request #307 from tree-sitter/pointer-sized-cancellation-flag
...
Make the cancellation flag a size_t, not a uint32_t
2019-03-22 12:30:39 -07:00
Max Brunsfeld
5a59f19b69
Use explicit syntax for functions with no parameters
2019-03-21 16:06:06 -07:00
Max Brunsfeld
0ccb910922
Use a size_t instead of a uint32_t for cancellation flag
2019-03-21 11:26:05 -07:00
Max Brunsfeld
0ae304f582
Lib: Rework the API for cancelling a parse
...
Also, use beta on CI until atomic::AtomicU32 lands in stable.
2019-03-18 09:51:21 -07:00
Max Brunsfeld
88e3907cc0
Use QueryPerformanceFrequency as clock on windows
2019-03-14 13:42:31 -07:00