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'.
This commit is contained in:
Hendrik van Antwerpen 2021-12-01 19:05:41 +01:00
parent ae7869d1a6
commit 9bac066330
4 changed files with 131 additions and 59 deletions

View file

@ -107,6 +107,11 @@ pub struct TSQueryCapture {
pub node: TSNode,
pub index: u32,
}
pub const TSQuantifier_One: TSQuantifier = 0;
pub const TSQuantifier_OneOrMore: TSQuantifier = 1;
pub const TSQuantifier_ZeroOrOne: TSQuantifier = 2;
pub const TSQuantifier_ZeroOrMore: TSQuantifier = 3;
pub type TSQuantifier = u32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TSQueryMatch {
@ -666,13 +671,10 @@ extern "C" {
) -> *const ::std::os::raw::c_char;
}
extern "C" {
#[doc = " Get the suffix of one of the query's captures, or one of the query's"]
#[doc = " string literals. Each capture and string is associated with a numeric"]
#[doc = " id based on the order that it appeared in the query's source."]
pub fn ts_query_capture_suffix_for_id(
arg1: *const TSQuery,
id: u32,
) -> ::std::os::raw::c_char;
#[doc = " Get the quantifier of the query's captures, or one of the query's string"]
#[doc = " literals. Each capture and string is associated with a numeric id based"]
#[doc = " on the order that it appeared in the query's source."]
pub fn ts_query_capture_quantifier_for_id(arg1: *const TSQuery, id: u32) -> TSQuantifier;
}
extern "C" {
pub fn ts_query_string_value_for_id(