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:
parent
ae7869d1a6
commit
9bac066330
4 changed files with 131 additions and 59 deletions
|
|
@ -106,6 +106,13 @@ typedef struct {
|
|||
uint32_t index;
|
||||
} TSQueryCapture;
|
||||
|
||||
typedef enum {
|
||||
One,
|
||||
OneOrMore,
|
||||
ZeroOrOne,
|
||||
ZeroOrMore,
|
||||
} TSQuantifier;
|
||||
|
||||
typedef struct {
|
||||
uint32_t id;
|
||||
uint16_t pattern_index;
|
||||
|
|
@ -740,7 +747,13 @@ const char *ts_query_capture_name_for_id(
|
|||
uint32_t id,
|
||||
uint32_t *length
|
||||
);
|
||||
char ts_query_capture_suffix_for_id(
|
||||
|
||||
/**
|
||||
* Get the quantifier 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.
|
||||
*/
|
||||
TSQuantifier ts_query_capture_quantifier_for_id(
|
||||
const TSQuery *,
|
||||
uint32_t id
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue