1/* vi:set ts=8 sts=4 sw=4:
2 *
3 * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
4 *
5 * This is NOT the original regular expression code as written by Henry
6 * Spencer.  This code has been modified specifically for use with Vim, and
7 * should not be used apart from compiling Vim.  If you want a good regular
8 * expression library, get the original code.
9 *
10 * NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
11 */
12
13#ifndef _REGEXP_H
14#define _REGEXP_H
15
16/*
17 * The number of sub-matches is limited to 10.
18 * The first one (index 0) is the whole match, referenced with "\0".
19 * The second one (index 1) is the first sub-match, referenced with "\1".
20 * This goes up to the tenth (index 9), referenced with "\9".
21 */
22#define NSUBEXP  10
23
24/*
25 * Structure returned by vim_regcomp() to pass on to vim_regexec().
26 * These fields are only to be used in regexp.c!
27 * See regep.c for an explanation.
28 */
29typedef struct
30{
31    int			regstart;
32    char_u		reganch;
33    char_u		*regmust;
34    int			regmlen;
35    unsigned		regflags;
36    char_u		reghasz;
37    char_u		program[1];		/* actually longer.. */
38} regprog_T;
39
40/*
41 * Structure to be used for single-line matching.
42 * Sub-match "no" starts at "startp[no]" and ends just before "endp[no]".
43 * When there is no match, the pointer is NULL.
44 */
45typedef struct
46{
47    regprog_T		*regprog;
48    char_u		*startp[NSUBEXP];
49    char_u		*endp[NSUBEXP];
50    int			rm_ic;
51} regmatch_T;
52
53/*
54 * Structure to be used for multi-line matching.
55 * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col"
56 * and ends in line "endpos[no].lnum" just before column "endpos[no].col".
57 * The line numbers are relative to the first line, thus startpos[0].lnum is
58 * always 0.
59 * When there is no match, the line number is -1.
60 */
61typedef struct
62{
63    regprog_T		*regprog;
64    lpos_T		startpos[NSUBEXP];
65    lpos_T		endpos[NSUBEXP];
66    int			rmm_ic;
67    colnr_T		rmm_maxcol;	/* when not zero: maximum column */
68} regmmatch_T;
69
70/*
71 * Structure used to store external references: "\z\(\)" to "\z\1".
72 * Use a reference count to avoid the need to copy this around.  When it goes
73 * from 1 to zero the matches need to be freed.
74 */
75typedef struct
76{
77    short		refcnt;
78    char_u		*matches[NSUBEXP];
79} reg_extmatch_T;
80
81#endif	/* _REGEXP_H */
82