robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
8a0eb8f10b
master
1// NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE 2// 3// This is NOT the original regular expression code as written by Henry 4// Spencer. This code has been modified specifically for use with Vim, and 5// should not be used apart from compiling Vim. If you want a good regular 6// expression library, get the original code. 7// 8// NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE 9 10#pragma once 11 12#include <stdbool.h> 13#include <stdint.h> 14 15#include "nvim/pos_defs.h" 16#include "nvim/types_defs.h" 17 18enum { 19/// The number of sub-matches is limited to 10. 20/// The first one (index 0) is the whole match, referenced with "\0". 21/// The second one (index 1) is the first sub-match, referenced with "\1". 22/// This goes up to the tenth (index 9), referenced with "\9". 23NSUBEXP = 10 , 24}; 25 26typedef struct regengine regengine_T ; 27 28/// Structure to be used for multi-line matching. 29/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" 30/// and ends in line "endpos[no].lnum" just before column "endpos[no].col". 31/// The line numbers are relative to the first line, thus startpos[0].lnum is 32/// always 0. 33/// When there is no match, the line number is -1. 34typedef struct { 35regprog_T * regprog ; 36lpos_T startpos [NSUBEXP ]; 37lpos_T endpos [NSUBEXP ]; 38 39colnr_T rmm_matchcol ;///< match start without "\zs" 40int rmm_ic ; 41colnr_T rmm_maxcol ;///< when not zero: maximum column 42}regmmatch_T ; 43 44/// Magicness of a pattern, used by regexp code. 45/// The order and values matter: 46/// magic <= MAGIC_OFF includes MAGIC_NONE 47/// magic >= MAGIC_ON includes MAGIC_ALL 48typedef enum { 49MAGIC_NONE = 1 ,///< "\V" very unmagic 50MAGIC_OFF = 2 ,///< "\M" or 'magic' off 51MAGIC_ON = 3 ,///< "\m" or 'magic' 52MAGIC_ALL = 4 ,///< "\v" very magic 53}magic_T ; 54 55/// Structure to be used for single-line matching. 56/// Sub-match "no" starts at "startp[no]" and ends just before "endp[no]". 57/// When there is no match, the pointer is NULL. 58typedef struct { 59regprog_T * regprog ; 60char * startp [NSUBEXP ]; 61char * endp [NSUBEXP ]; 62 63colnr_T rm_matchcol ;///< match start without "\zs" 64bool rm_ic ; 65}regmatch_T ; 66 67/// Structure used to store external references: "\z\(\)" to "\z\1". 68/// Use a reference count to avoid the need to copy this around. When it goes 69/// from 1 to zero the matches need to be freed. 70typedef struct { 71int16_t refcnt ; 72uint8_t * matches [NSUBEXP ]; 73}reg_extmatch_T ; 74 75/// Flags used by vim_regsub() and vim_regsub_both() 76enum { 77REGSUB_COPY = 1 , 78REGSUB_MAGIC = 2 , 79REGSUB_BACKSLASH = 4 , 80};