Rizin
unix-like reverse engineering framework and cli tools
|
#include "tree_sitter/api.h"
#include "./alloc.h"
#include "./array.h"
#include "./language.h"
#include "./point.h"
#include "./tree_cursor.h"
#include "./unicode.h"
#include <wctype.h>
Go to the source code of this file.
Classes | |
struct | Stream |
struct | QueryStep |
struct | Slice |
struct | SymbolTable |
struct | QueryPattern |
struct | StepOffset |
struct | QueryState |
struct | AnalysisStateEntry |
struct | AnalysisState |
struct | AnalysisSubgraph |
struct | StatePredecessorMap |
struct | TSQuery |
struct | TSQueryCursor |
Macros | |
#define | MAX_STEP_CAPTURE_COUNT 3 |
#define | MAX_NEGATED_FIELD_COUNT 8 |
#define | MAX_STATE_PREDECESSOR_COUNT 256 |
#define | MAX_ANALYSIS_STATE_DEPTH 8 |
#define | MAX_ANALYSIS_ITERATION_COUNT 256 |
#define | LOG(...) |
Variables | |
PatternEntry | |
CaptureListPool | |
AnalysisSubgraphNode | |
static const TSQueryError | PARENT_DONE = -1 |
static const uint16_t | PATTERN_DONE_MARKER = UINT16_MAX |
static const uint16_t | NONE = UINT16_MAX |
static const TSSymbol | WILDCARD_SYMBOL = 0 |
|
inlinestatic |
Definition at line 937 of file query.c.
References ts_malloc.
Referenced by analysis_state_pool__clone_or_reuse().
|
inlinestatic |
Definition at line 909 of file query.c.
References analysis_state__compare_position(), and i.
Referenced by analysis_state_set__insert_sorted_by_clone().
|
inlinestatic |
Definition at line 894 of file query.c.
References i.
Referenced by analysis_state__compare(), and ts_query__analyze_patterns().
|
inlinestatic |
|
static |
|
inlinestatic |
Definition at line 926 of file query.c.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 949 of file query.c.
References analysis_state__clone(), and array_pop.
Referenced by analysis_state_set__insert_sorted_by_clone(), and analysis_state_set__push_by_clone().
|
inlinestatic |
Definition at line 1001 of file query.c.
References array_clear, and array_push_all.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 1008 of file query.c.
References array_delete, i, and ts_free.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 970 of file query.c.
References analysis_state__compare(), analysis_state_pool__clone_or_reuse(), array_insert, and array_search_sorted_with.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 991 of file query.c.
References analysis_state_pool__clone_or_reuse(), and array_push.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
typedef Array | ( | AnalysisState * | ) |
typedef Array | ( | TSQueryCapture | ) |
typedef Array | ( | uint8_t | ) |
CaptureQuantififers - a data structure holding the quantifiers of pattern captures.
Definition at line 126 of file query.c.
Referenced by Array(), ts_query__analyze_patterns(), and ts_query__parse_pattern().
|
static |
Definition at line 434 of file query.c.
References array_clear, array_init, array_push, i, list(), NONE, and UINT32_MAX.
Referenced by ts_query_cursor__prepare_to_capture().
|
static |
Definition at line 411 of file query.c.
References array_delete, and i.
Referenced by ts_query_cursor_delete().
|
static |
Definition at line 418 of file query.c.
References id.
Referenced by ts_query_cursor__advance(), ts_query_cursor__compare_captures(), ts_query_cursor__copy_state(), ts_query_cursor__first_in_progress_capture(), ts_query_cursor_next_capture(), and ts_query_cursor_next_match().
|
static |
|
static |
|
static |
Definition at line 394 of file query.c.
References array_new, CaptureListPool, and UINT32_MAX.
Referenced by ts_query_cursor_new().
|
static |
Definition at line 458 of file query.c.
References id, and UINT32_MAX.
Referenced by ts_query_cursor__advance(), ts_query_cursor_next_capture(), ts_query_cursor_next_match(), and ts_query_cursor_remove_match().
|
static |
Definition at line 403 of file query.c.
References i, and UINT32_MAX.
Referenced by ts_query_cursor_exec().
|
static |
Definition at line 656 of file query.c.
References array_get, and TSQuantifierZero.
Referenced by ts_query_capture_quantifier_for_id().
|
static |
Definition at line 677 of file query.c.
References array_get, array_grow_by, and quantifier_add().
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 664 of file query.c.
References array_get, array_grow_by, and quantifier_add().
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 640 of file query.c.
References array_clear.
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 633 of file query.c.
References array_delete.
Referenced by ts_query__parse_pattern(), ts_query_delete(), and ts_query_new().
|
static |
Definition at line 703 of file query.c.
References array_get, array_grow_by, quantifier_join(), and TSQuantifierZero.
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 692 of file query.c.
References array_get, and quantifier_mul().
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 628 of file query.c.
References array_new.
Referenced by ts_query__parse_pattern(), and ts_query_new().
|
static |
Definition at line 647 of file query.c.
References array_clear, and array_push_all.
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 578 of file query.c.
References TSQuantifierOne, TSQuantifierOneOrMore, TSQuantifierZero, TSQuantifierZeroOrMore, and TSQuantifierZeroOrOne.
Referenced by capture_quantifiers_add_all(), and capture_quantifiers_add_for_id().
|
static |
Definition at line 517 of file query.c.
References TSQuantifierOne, TSQuantifierOneOrMore, TSQuantifierZero, TSQuantifierZeroOrMore, and TSQuantifierZeroOrOne.
Referenced by capture_quantifiers_join_all(), and ts_query__parse_pattern().
|
static |
Definition at line 468 of file query.c.
References TSQuantifierOne, TSQuantifierOneOrMore, TSQuantifierZero, TSQuantifierZeroOrMore, and TSQuantifierZeroOrOne.
Referenced by capture_quantifiers_mul().
Definition at line 807 of file query.c.
References i, MAX_STEP_CAPTURE_COUNT, and NONE.
Referenced by ts_query__parse_pattern().
Definition at line 784 of file query.c.
References is_immediate(), NONE, and QueryStep::symbol.
Referenced by ts_query__parse_pattern(), and ts_query_new().
Definition at line 816 of file query.c.
References i, MAX_STEP_CAPTURE_COUNT, and NONE.
Referenced by ts_query_disable_capture().
|
inlinestatic |
Definition at line 850 of file query.c.
References count, and MAX_STATE_PREDECESSOR_COUNT.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 846 of file query.c.
References ts_free.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 866 of file query.c.
References count, and MAX_STATE_PREDECESSOR_COUNT.
Referenced by ts_query__analyze_patterns().
|
inlinestatic |
Definition at line 835 of file query.c.
References StatePredecessorMap::contents, MAX_STATE_PREDECESSOR_COUNT, TSLanguage::state_count, and ts_calloc.
Referenced by ts_query__analyze_patterns().
Definition at line 315 of file query.c.
References ts_decode_utf8().
Referenced by stream_new(), stream_reset(), stream_scan_identifier(), stream_skip_whitespace(), ts_query__parse_pattern(), ts_query__parse_predicate(), and ts_query__parse_string_literal().
Definition at line 369 of file query.c.
Referenced by ts_query__parse_pattern(), and ts_query__parse_predicate().
Definition at line 342 of file query.c.
References length, Stream::next, and stream_advance().
Referenced by ts_query_new().
Definition at line 386 of file query.c.
Referenced by test_read(), and ts_query_new().
Definition at line 336 of file query.c.
References input(), and stream_advance().
Referenced by ts_query__parse_pattern(), ts_query__parse_predicate(), and ts_query__parse_string_literal().
|
static |
Definition at line 373 of file query.c.
References stream_advance().
Referenced by ts_query__parse_pattern(), and ts_query__parse_predicate().
|
static |
Definition at line 353 of file query.c.
References stream_advance().
Referenced by ts_query__parse_pattern(), ts_query__parse_predicate(), and ts_query_new().
|
static |
|
static |
Definition at line 737 of file query.c.
References i, length, Slice::length, and Slice::offset.
Referenced by symbol_table_insert_name(), ts_query__parse_predicate(), and ts_query_disable_capture().
|
static |
Definition at line 762 of file query.c.
References array_grow_by, array_push, id, length, memcpy(), Slice::offset, and symbol_table_id_for_name().
Referenced by ts_query__parse_pattern(), and ts_query__parse_predicate().
|
static |
Definition at line 752 of file query.c.
References id, length, Slice::length, and Slice::offset.
Referenced by ts_query_capture_name_for_id(), and ts_query_string_value_for_id().
|
static |
Definition at line 725 of file query.c.
References array_new.
Referenced by ts_query_new().
|
static |
Definition at line 1835 of file query.c.
References array_extend, array_push, i, and step().
Referenced by ts_query__parse_pattern().
Definition at line 1116 of file query.c.
References test-lz4-speed::action, LookaheadIterator::action_count, LookaheadIterator::actions, QueryStep::alternative_index, analysis_state__compare_position(), analysis_state__has_supertype(), analysis_state__recursion_depth(), analysis_state__top(), analysis_state_set__clear(), analysis_state_set__delete(), analysis_state_set__insert_sorted_by_clone(), analysis_state_set__push_by_clone(), analysis_subgraph_node__compare(), AnalysisSubgraphNode, Array(), array_assign, array_back, array_clear, array_delete, array_erase, array_insert, array_insert_sorted_by, array_new, array_pop, array_push, array_search_sorted_by, array_search_sorted_with, assert(), QueryStep::capture_ids, TSFieldMapEntry::child_index, AnalysisStateEntry::child_index, QueryStep::depth, AnalysisState::depth, AnalysisStateEntry::done, done, test_evm::end, field_id, TSFieldMapEntry::field_id, AnalysisStateEntry::field_id, i, TSFieldMapEntry::inherited, QueryStep::is_dead_end, QueryStep::is_pass_through, k, Slice::length, MAX_ANALYSIS_ITERATION_COUNT, MAX_ANALYSIS_STATE_DEPTH, MAX_STEP_CAPTURE_COUNT, LookaheadIterator::next_state, NONE, Slice::offset, QueryStep::parent_pattern_guaranteed, AnalysisStateEntry::parent_symbol, AnalysisStateEntry::parse_state, PATTERN_DONE_MARKER, QueryPattern::predicate_steps, printf(), QueryStep::root_pattern_guaranteed, start, TSParseAction::state, state_predecessor_map_add(), state_predecessor_map_delete(), state_predecessor_map_get(), state_predecessor_map_new(), states, step(), AnalysisState::step_index, QueryPattern::steps, LookaheadIterator::symbol, AnalysisSubgraph::symbol, ts_builtin_sym_error, ts_free, ts_language_alias_at(), ts_language_aliases_for_symbol(), ts_language_field_map(), ts_language_field_name_for_id(), ts_language_lookaheads(), ts_language_state_is_primary(), ts_language_symbol_metadata(), ts_language_symbol_name(), ts_lookahead_iterator_next(), TSParseActionTypeReduce, TSParseActionTypeShift, TSQueryPredicateStepTypeCapture, TSSymbolMetadata::visible, and WILDCARD_SYMBOL.
|
static |
Definition at line 2050 of file query.c.
References QueryStep::alternative_index, QueryStep::alternative_is_immediate, Array(), array_back, array_delete, array_new, array_pop, array_push, capture_quantifiers_add_all(), capture_quantifiers_add_for_id(), capture_quantifiers_clear(), capture_quantifiers_delete(), capture_quantifiers_join_all(), capture_quantifiers_mul(), capture_quantifiers_new(), capture_quantifiers_replace(), e, field_id, field_name, i, QueryStep::is_dead_end, is_immediate(), QueryStep::is_pass_through, length, MAX_NEGATED_FIELD_COUNT, NONE, PARENT_DONE, quantifier_join(), query_step__add_capture(), query_step__new(), step(), stream_advance(), stream_is_ident_start(), stream_reset(), stream_scan_identifier(), stream_skip_whitespace(), TSSymbolMetadata::supertype, symbol_table_insert_name(), ts_language_field_id_for_name(), ts_language_symbol_for_name(), ts_language_symbol_metadata(), ts_query__add_negated_fields(), ts_query__parse_predicate(), ts_query__parse_string_literal(), TSQuantifierOne, TSQuantifierOneOrMore, TSQuantifierZeroOrMore, TSQuantifierZeroOrOne, TSQueryErrorField, TSQueryErrorNodeType, TSQueryErrorSyntax, and WILDCARD_SYMBOL.
Referenced by ts_query_new().
|
static |
Definition at line 1946 of file query.c.
References array_push, e, length, stream_advance(), stream_is_ident_start(), stream_reset(), stream_scan_identifier(), stream_skip_whitespace(), symbol_table_id_for_name(), symbol_table_insert_name(), ts_query__parse_string_literal(), TSQueryErrorCapture, and TSQueryErrorSyntax.
Referenced by ts_query__parse_pattern().
|
static |
Definition at line 1887 of file query.c.
References array_clear, array_extend, array_push, stream_advance(), stream_reset(), TSQueryErrorNone, and TSQueryErrorSyntax.
Referenced by ts_query__parse_pattern(), and ts_query__parse_predicate().
|
inlinestatic |
Definition at line 1089 of file query.c.
References array_insert, PatternEntry, and ts_query__pattern_map_search().
Referenced by ts_query_new().
|
inlinestatic |
Definition at line 1049 of file query.c.
Referenced by ts_query__pattern_map_insert(), and ts_query_cursor__advance().
Definition at line 2771 of file query.c.
References assert(), QueryStep::depth, QueryStep::parent_pattern_guaranteed, PATTERN_DONE_MARKER, and step().
Referenced by ts_query_cursor__advance().
Get the name and length of one of the query's captures, or one of the query's string literals. Each capture and string is associated with a numeric id based on the order that it appeared in the query's source.
Definition at line 2709 of file query.c.
References length, and symbol_table_name_for_id().
TSQuantifier ts_query_capture_quantifier_for_id | ( | const TSQuery * | self, |
uint32_t | pattern_id, | ||
uint32_t | capture_id | ||
) |
Get the quantifier of the query's captures. Each capture is * associated with a numeric id based on the order that it appeared in the query's source.
Definition at line 2717 of file query.c.
References array_get, and capture_quantifier_for_id().
|
static |
Definition at line 3036 of file query.c.
References array_insert, LOG, QueryState::pattern_index, QueryState::start_depth, step(), and QueryState::step_index.
Referenced by ts_query_cursor__advance().
|
inlinestatic |
Definition at line 3206 of file query.c.
References QueryStep::alternative_index, QueryStep::alternative_is_immediate, array_erase, array_pop, array_push, QueryStep::capture_ids, QueryState::capture_list_id, capture_list_pool_get(), capture_list_pool_release(), QueryStep::depth, field_id, QueryState::has_in_progress_alternatives, i, QueryStep::is_dead_end, QueryStep::is_pass_through, LOG, n, NONE, PATTERN_DONE_MARKER, QueryState::pattern_index, PatternEntry, point_gt(), point_lt(), QueryStep::root_pattern_guaranteed, QueryState::seeking_immediate_match, QueryState::start_depth, step(), QueryState::step_index, ts_language_field_name_for_id(), ts_node_child_by_field_id(), ts_node_end_byte(), ts_node_end_point(), ts_node_is_named(), ts_node_is_null(), ts_node_start_byte(), ts_node_start_point(), ts_node_symbol(), ts_node_type(), ts_query__pattern_map_search(), ts_query__step_is_fallible(), ts_query_cursor__add_state(), ts_query_cursor__capture(), ts_query_cursor__compare_captures(), ts_query_cursor__copy_state(), ts_tree_cursor_current_node(), ts_tree_cursor_current_status(), ts_tree_cursor_goto_first_child(), ts_tree_cursor_goto_next_sibling(), ts_tree_cursor_goto_parent(), ts_tree_cursor_parent_node(), and WILDCARD_SYMBOL.
Referenced by ts_query_cursor_next_capture(), and ts_query_cursor_next_match().
|
static |
Definition at line 3147 of file query.c.
References array_push, LOG, MAX_STEP_CAPTURE_COUNT, NONE, step(), ts_node_type(), ts_query_cursor__prepare_to_capture(), and UINT32_MAX.
Referenced by ts_query_cursor__advance().
void ts_query_cursor__compare_captures | ( | TSQueryCursor * | self, |
QueryState * | left_state, | ||
QueryState * | right_state, | ||
bool * | left_contains_right, | ||
bool * | right_contains_left | ||
) |
Definition at line 2973 of file query.c.
References QueryState::capture_list_id, capture_list_pool_get(), i, TSNode::id, TSQueryCapture::index, TSQueryCapture::node, and ts_query_cursor__compare_nodes().
Referenced by ts_query_cursor__advance().
Definition at line 2958 of file query.c.
References TSNode::id, ts_node_end_byte(), and ts_node_start_byte().
Referenced by ts_query_cursor__compare_captures().
|
static |
Definition at line 3177 of file query.c.
References array_insert, array_push_all, QueryState::capture_list_id, capture_list_pool_get(), NONE, NULL, and ts_query_cursor__prepare_to_capture().
Referenced by ts_query_cursor__advance().
|
static |
Definition at line 2902 of file query.c.
References capture_list_pool_get(), i, point_lte(), step(), ts_node_end_byte(), ts_node_end_point(), ts_node_start_byte(), and UINT32_MAX.
Referenced by ts_query_cursor__prepare_to_capture(), and ts_query_cursor_next_capture().
|
static |
Definition at line 3100 of file query.c.
References array_clear, QueryState::capture_list_id, capture_list_pool_acquire(), capture_list_pool_get_mut(), QueryState::dead, list(), LOG, NONE, NULL, and ts_query_cursor__first_in_progress_capture().
Referenced by ts_query_cursor__capture(), and ts_query_cursor__copy_state().
void ts_query_cursor_delete | ( | TSQueryCursor * | self | ) |
Delete a query cursor, freeing all of the memory that it used.
Definition at line 2839 of file query.c.
References array_delete, capture_list_pool_delete(), ts_free, and ts_tree_cursor_delete().
bool ts_query_cursor_did_exceed_match_limit | ( | const TSQueryCursor * | self | ) |
Manage the maximum number of in-progress matches allowed by this query cursor.
Query cursors have an optional maximum capacity for storing lists of in-progress captures. If this capacity is exceeded, then the earliest-starting match will silently be dropped to make room for further matches. This maximum capacity is optional — by default, query cursors allow any number of pending matches, dynamically allocating new space for them as needed as the query is executed.
Definition at line 2847 of file query.c.
Referenced by ts_query_captures_wasm(), and ts_query_matches_wasm().
void ts_query_cursor_exec | ( | TSQueryCursor * | self, |
const TSQuery * | query, | ||
TSNode | node | ||
) |
Start running a given query on a given node.
Definition at line 2859 of file query.c.
References array_clear, capture_list_pool_reset(), and ts_tree_cursor_reset().
Referenced by ts_query_captures_wasm(), and ts_query_matches_wasm().
uint32_t ts_query_cursor_match_limit | ( | const TSQueryCursor * | self | ) |
TSQueryCursor* ts_query_cursor_new | ( | void | ) |
Create a new cursor for executing a given query.
The cursor stores the state that is needed to iteratively search for matches. To use the query cursor, first call ts_query_cursor_exec
to start running a given query on a given syntax node. Then, there are two options for consuming the results of the query:
ts_query_cursor_next_match
to iterate over all of the matches in the order that they were found. Each match contains the index of the pattern that matched, and an array of captures. Because multiple patterns can match the same set of nodes, one match may contain captures that appear before some of the captures from a previous match.ts_query_cursor_next_capture
to iterate over all of the individual captures in the order that they appear. This is useful if don't care about which pattern matched, and just want a single ordered sequence of captures.If you don't care about consuming all of the results, you can stop calling ts_query_cursor_next_match
or ts_query_cursor_next_capture
at any point. You can then start executing another query on another node by calling ts_query_cursor_exec
again.
Definition at line 2820 of file query.c.
References array_new, array_reserve, capture_list_pool_new(), POINT_MAX, ts_malloc, and UINT32_MAX.
Referenced by ts_query_captures_wasm(), and ts_query_matches_wasm().
bool ts_query_cursor_next_capture | ( | TSQueryCursor * | self, |
TSQueryMatch * | match, | ||
uint32_t * | capture_index | ||
) |
Advance to the next capture of the currently running query.
If there is a capture, write its match to *match
and its index within the matche's capture list to *capture_index
. Otherwise, return false
.
Definition at line 3746 of file query.c.
References array_erase, capture_list_pool_get(), capture_list_pool_is_empty(), capture_list_pool_release(), i, LOG, NULL, ts_node_end_byte(), ts_node_start_byte(), ts_query_cursor__advance(), ts_query_cursor__first_in_progress_capture(), and UINT32_MAX.
Referenced by ts_query_captures_wasm().
bool ts_query_cursor_next_match | ( | TSQueryCursor * | self, |
TSQueryMatch * | match | ||
) |
Advance to the next match of the currently running query.
If there is a match, write it to *match
and return true
. Otherwise, return false
.
Definition at line 3690 of file query.c.
References array_erase, capture_list_pool_get(), capture_list_pool_release(), ts_query_cursor__advance(), and UINT32_MAX.
Referenced by ts_query_matches_wasm().
void ts_query_cursor_remove_match | ( | TSQueryCursor * | self, |
uint32_t | match_id | ||
) |
Definition at line 3715 of file query.c.
References array_erase, capture_list_pool_release(), and i.
void ts_query_cursor_set_byte_range | ( | TSQueryCursor * | self, |
uint32_t | start_byte, | ||
uint32_t | end_byte | ||
) |
Set the range of bytes or (row, column) positions in which the query will be executed.
Definition at line 2876 of file query.c.
References UINT32_MAX.
void ts_query_cursor_set_match_limit | ( | TSQueryCursor * | self, |
uint32_t | limit | ||
) |
Definition at line 2855 of file query.c.
References limit.
Referenced by ts_query_captures_wasm(), and ts_query_matches_wasm().
void ts_query_cursor_set_point_range | ( | TSQueryCursor * | self, |
TSPoint | start_point, | ||
TSPoint | end_point | ||
) |
Definition at line 2888 of file query.c.
References TSPoint::column, POINT_MAX, and TSPoint::row.
Referenced by ts_query_captures_wasm(), and ts_query_matches_wasm().
void ts_query_delete | ( | TSQuery * | self | ) |
Delete a query, freeing all of the memory that it used.
Definition at line 2677 of file query.c.
References array_delete, array_get, capture_quantifiers_delete(), symbol_table_delete(), and ts_free.
Referenced by ts_query_new().
Disable a certain capture within a query.
This prevents the capture from being returned in matches, and also avoids any resource usage associated with recording the capture. Currently, there is no way to undo this.
Definition at line 2785 of file query.c.
References i, length, query_step__remove_capture(), step(), and symbol_table_id_for_name().
Disable a certain pattern within a query.
This prevents the pattern from matching and removes most of the overhead associated with the pattern. Currently, there is no way to undo this.
Definition at line 2801 of file query.c.
References array_erase, i, and PatternEntry.
Definition at line 2754 of file query.c.
References StepOffset::byte_offset, i, StepOffset::step_index, and UINT32_MAX.
TSQuery* ts_query_new | ( | const TSLanguage * | language, |
const char * | source, | ||
uint32_t | source_len, | ||
uint32_t * | error_offset, | ||
TSQueryError * | error_type | ||
) |
Create a new query from a string containing one or more S-expression patterns. The query is associated with a particular language, and can only be run on syntax nodes parsed with that language.
If all of the given patterns are valid, this returns a TSQuery
. If a pattern is invalid, this returns NULL
, and provides two pieces of information about the problem:
error_offset
parameter.error_type
parameter. Definition at line 2546 of file query.c.
References array_back, array_new, array_push, capture_quantifiers_delete(), capture_quantifiers_new(), QueryStep::depth, Slice::length, NONE, NULL, PARENT_DONE, PATTERN_DONE_MARKER, PatternEntry, QueryPattern::predicate_steps, query_step__new(), source, step(), QueryPattern::steps, stream_new(), stream_offset(), stream_skip_whitespace(), QueryStep::symbol, symbol_table_new(), TREE_SITTER_LANGUAGE_VERSION, TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION, ts_malloc, ts_query__parse_pattern(), ts_query__pattern_map_insert(), ts_query_delete(), TSQueryErrorLanguage, TSQueryErrorSyntax, TSLanguage::version, and WILDCARD_SYMBOL.
const TSQueryPredicateStep* ts_query_predicates_for_pattern | ( | const TSQuery * | self, |
uint32_t | pattern_index, | ||
uint32_t * | length | ||
) |
Get all of the predicates for the given pattern in the query.
The predicates are represented as a single array of steps. There are three types of steps in this array, which correspond to the three legal values for the type
field:
TSQueryPredicateStepTypeCapture
- Steps with this type represent names of captures. Their value_id
can be used with the ts_query_capture_name_for_id
function to obtain the name of the capture.TSQueryPredicateStepTypeString
- Steps with this type represent literal strings. Their value_id
can be used with the ts_query_string_value_for_id
function to obtain their string value.TSQueryPredicateStepTypeDone
- Steps with this type are sentinels that represent the end of an individual predicate. If a pattern has two predicates, then there will be two steps with this type
in the array. Definition at line 2734 of file query.c.
References Slice::length, NULL, and Slice::offset.
const char* ts_query_string_value_for_id | ( | const TSQuery * | self, |
uint32_t | index, | ||
uint32_t * | length | ||
) |
Definition at line 2726 of file query.c.
References length, and symbol_table_name_for_id().
AnalysisSubgraphNode |
Definition at line 248 of file query.c.
Referenced by ts_query__analyze_patterns().
CaptureListPool |
Definition at line 213 of file query.c.
Referenced by capture_list_pool_new().
|
static |
Definition at line 307 of file query.c.
Referenced by capture_list_pool_acquire(), query_step__add_capture(), query_step__new(), query_step__remove_capture(), ts_query__analyze_patterns(), ts_query__parse_pattern(), ts_query_cursor__advance(), ts_query_cursor__capture(), ts_query_cursor__copy_state(), ts_query_cursor__prepare_to_capture(), and ts_query_new().
|
static |
Definition at line 305 of file query.c.
Referenced by ts_query__parse_pattern(), and ts_query_new().
|
static |
Definition at line 306 of file query.c.
Referenced by ts_query__analyze_patterns(), ts_query__step_is_fallible(), ts_query_cursor__advance(), and ts_query_new().
PatternEntry |
Definition at line 143 of file query.c.
Referenced by ts_query__pattern_map_insert(), ts_query_cursor__advance(), ts_query_disable_pattern(), and ts_query_new().
Definition at line 308 of file query.c.
Referenced by ts_query__analyze_patterns(), ts_query__parse_pattern(), ts_query_cursor__advance(), and ts_query_new().