Mercurial > vim
annotate src/regexp_nfa.c @ 8134:8abef552ece7 v7.4.1361
commit https://github.com/vim/vim/commit/254e00d71429aa4e71b93d3e8c6bb93bfebe4f26
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 19 23:23:12 2016 +0100
patch 7.4.1361
Problem: Channel test fails on Solaris.
Solution: Use the 1 msec waittime for all systems.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 19 Feb 2016 23:45:04 +0100 |
parents | b6b4f354df23 |
children | f196308a2813 |
rev | line source |
---|---|
4444 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * NFA regular expression implementation. | |
4 * | |
5 * This file is included in "regexp.c". | |
6 */ | |
7 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
8 /* |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
9 * Logging of NFA engine. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
10 * |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
11 * The NFA engine can write four log files: |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
12 * - Error log: Contains NFA engine's fatal errors. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
13 * - Dump log: Contains compiled NFA state machine's information. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
14 * - Run log: Contains information of matching procedure. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
15 * - Debug log: Contains detailed information of matching procedure. Can be |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
16 * disabled by undefining NFA_REGEXP_DEBUG_LOG. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
17 * The first one can also be used without debug mode. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
18 * The last three are enabled when compiled as debug mode and individually |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
19 * disabled by commenting them out. |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
20 * The log files can get quite big! |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
21 * Do disable all of this when compiling Vim for debugging, undefine DEBUG in |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
22 * regexp.c |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
23 */ |
4444 | 24 #ifdef DEBUG |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
25 # define NFA_REGEXP_ERROR_LOG "nfa_regexp_error.log" |
4444 | 26 # define ENABLE_LOG |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
27 # define NFA_REGEXP_DUMP_LOG "nfa_regexp_dump.log" |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
28 # define NFA_REGEXP_RUN_LOG "nfa_regexp_run.log" |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
29 # define NFA_REGEXP_DEBUG_LOG "nfa_regexp_debug.log" |
4444 | 30 #endif |
31 | |
5296 | 32 /* Added to NFA_ANY - NFA_NUPPER_IC to include a NL. */ |
33 #define NFA_ADD_NL 31 | |
34 | |
4444 | 35 enum |
36 { | |
37 NFA_SPLIT = -1024, | |
38 NFA_MATCH, | |
5370 | 39 NFA_EMPTY, /* matches 0-length */ |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
40 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
41 NFA_START_COLL, /* [abc] start */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
42 NFA_END_COLL, /* [abc] end */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
43 NFA_START_NEG_COLL, /* [^abc] start */ |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
44 NFA_END_NEG_COLL, /* [^abc] end (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
45 NFA_RANGE, /* range of the two previous items |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
46 * (postfix only) */ |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
47 NFA_RANGE_MIN, /* low end of a range */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
48 NFA_RANGE_MAX, /* high end of a range */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
49 |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
50 NFA_CONCAT, /* concatenate two previous items (postfix |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
51 * only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
52 NFA_OR, /* \| (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
53 NFA_STAR, /* greedy * (posfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
54 NFA_STAR_NONGREEDY, /* non-greedy * (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
55 NFA_QUEST, /* greedy \? (postfix only) */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
56 NFA_QUEST_NONGREEDY, /* non-greedy \? (postfix only) */ |
4444 | 57 |
58 NFA_BOL, /* ^ Begin line */ | |
59 NFA_EOL, /* $ End line */ | |
60 NFA_BOW, /* \< Begin word */ | |
61 NFA_EOW, /* \> End word */ | |
62 NFA_BOF, /* \%^ Begin file */ | |
63 NFA_EOF, /* \%$ End file */ | |
64 NFA_NEWL, | |
65 NFA_ZSTART, /* Used for \zs */ | |
66 NFA_ZEND, /* Used for \ze */ | |
67 NFA_NOPEN, /* Start of subexpression marked with \%( */ | |
68 NFA_NCLOSE, /* End of subexpr. marked with \%( ... \) */ | |
69 NFA_START_INVISIBLE, | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
70 NFA_START_INVISIBLE_FIRST, |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
71 NFA_START_INVISIBLE_NEG, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
72 NFA_START_INVISIBLE_NEG_FIRST, |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
73 NFA_START_INVISIBLE_BEFORE, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
74 NFA_START_INVISIBLE_BEFORE_FIRST, |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
75 NFA_START_INVISIBLE_BEFORE_NEG, |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
76 NFA_START_INVISIBLE_BEFORE_NEG_FIRST, |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
77 NFA_START_PATTERN, |
4444 | 78 NFA_END_INVISIBLE, |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
79 NFA_END_INVISIBLE_NEG, |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
80 NFA_END_PATTERN, |
4444 | 81 NFA_COMPOSING, /* Next nodes in NFA are part of the |
82 composing multibyte char */ | |
83 NFA_END_COMPOSING, /* End of a composing char in the NFA */ | |
5901 | 84 NFA_ANY_COMPOSING, /* \%C: Any composing characters. */ |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
85 NFA_OPT_CHARS, /* \%[abc] */ |
4444 | 86 |
87 /* The following are used only in the postfix form, not in the NFA */ | |
88 NFA_PREV_ATOM_NO_WIDTH, /* Used for \@= */ | |
89 NFA_PREV_ATOM_NO_WIDTH_NEG, /* Used for \@! */ | |
90 NFA_PREV_ATOM_JUST_BEFORE, /* Used for \@<= */ | |
91 NFA_PREV_ATOM_JUST_BEFORE_NEG, /* Used for \@<! */ | |
92 NFA_PREV_ATOM_LIKE_PATTERN, /* Used for \@> */ | |
93 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
94 NFA_BACKREF1, /* \1 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
95 NFA_BACKREF2, /* \2 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
96 NFA_BACKREF3, /* \3 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
97 NFA_BACKREF4, /* \4 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
98 NFA_BACKREF5, /* \5 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
99 NFA_BACKREF6, /* \6 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
100 NFA_BACKREF7, /* \7 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
101 NFA_BACKREF8, /* \8 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
102 NFA_BACKREF9, /* \9 */ |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
103 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
104 NFA_ZREF1, /* \z1 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
105 NFA_ZREF2, /* \z2 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
106 NFA_ZREF3, /* \z3 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
107 NFA_ZREF4, /* \z4 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
108 NFA_ZREF5, /* \z5 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
109 NFA_ZREF6, /* \z6 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
110 NFA_ZREF7, /* \z7 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
111 NFA_ZREF8, /* \z8 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
112 NFA_ZREF9, /* \z9 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
113 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
114 NFA_SKIP, /* Skip characters */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
115 |
4444 | 116 NFA_MOPEN, |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
117 NFA_MOPEN1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
118 NFA_MOPEN2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
119 NFA_MOPEN3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
120 NFA_MOPEN4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
121 NFA_MOPEN5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
122 NFA_MOPEN6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
123 NFA_MOPEN7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
124 NFA_MOPEN8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
125 NFA_MOPEN9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
126 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
127 NFA_MCLOSE, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
128 NFA_MCLOSE1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
129 NFA_MCLOSE2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
130 NFA_MCLOSE3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
131 NFA_MCLOSE4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
132 NFA_MCLOSE5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
133 NFA_MCLOSE6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
134 NFA_MCLOSE7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
135 NFA_MCLOSE8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
136 NFA_MCLOSE9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
137 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
138 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
139 NFA_ZOPEN, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
140 NFA_ZOPEN1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
141 NFA_ZOPEN2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
142 NFA_ZOPEN3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
143 NFA_ZOPEN4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
144 NFA_ZOPEN5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
145 NFA_ZOPEN6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
146 NFA_ZOPEN7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
147 NFA_ZOPEN8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
148 NFA_ZOPEN9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
149 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
150 NFA_ZCLOSE, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
151 NFA_ZCLOSE1, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
152 NFA_ZCLOSE2, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
153 NFA_ZCLOSE3, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
154 NFA_ZCLOSE4, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
155 NFA_ZCLOSE5, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
156 NFA_ZCLOSE6, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
157 NFA_ZCLOSE7, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
158 NFA_ZCLOSE8, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
159 NFA_ZCLOSE9, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
160 #endif |
4444 | 161 |
162 /* NFA_FIRST_NL */ | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
163 NFA_ANY, /* Match any one character. */ |
4444 | 164 NFA_IDENT, /* Match identifier char */ |
165 NFA_SIDENT, /* Match identifier char but no digit */ | |
166 NFA_KWORD, /* Match keyword char */ | |
167 NFA_SKWORD, /* Match word char but no digit */ | |
168 NFA_FNAME, /* Match file name char */ | |
169 NFA_SFNAME, /* Match file name char but no digit */ | |
170 NFA_PRINT, /* Match printable char */ | |
171 NFA_SPRINT, /* Match printable char but no digit */ | |
172 NFA_WHITE, /* Match whitespace char */ | |
173 NFA_NWHITE, /* Match non-whitespace char */ | |
174 NFA_DIGIT, /* Match digit char */ | |
175 NFA_NDIGIT, /* Match non-digit char */ | |
176 NFA_HEX, /* Match hex char */ | |
177 NFA_NHEX, /* Match non-hex char */ | |
178 NFA_OCTAL, /* Match octal char */ | |
179 NFA_NOCTAL, /* Match non-octal char */ | |
180 NFA_WORD, /* Match word char */ | |
181 NFA_NWORD, /* Match non-word char */ | |
182 NFA_HEAD, /* Match head char */ | |
183 NFA_NHEAD, /* Match non-head char */ | |
184 NFA_ALPHA, /* Match alpha char */ | |
185 NFA_NALPHA, /* Match non-alpha char */ | |
186 NFA_LOWER, /* Match lowercase char */ | |
187 NFA_NLOWER, /* Match non-lowercase char */ | |
188 NFA_UPPER, /* Match uppercase char */ | |
189 NFA_NUPPER, /* Match non-uppercase char */ | |
5296 | 190 NFA_LOWER_IC, /* Match [a-z] */ |
191 NFA_NLOWER_IC, /* Match [^a-z] */ | |
192 NFA_UPPER_IC, /* Match [A-Z] */ | |
193 NFA_NUPPER_IC, /* Match [^A-Z] */ | |
194 | |
195 NFA_FIRST_NL = NFA_ANY + NFA_ADD_NL, | |
196 NFA_LAST_NL = NFA_NUPPER_IC + NFA_ADD_NL, | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
197 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
198 NFA_CURSOR, /* Match cursor pos */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
199 NFA_LNUM, /* Match line number */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
200 NFA_LNUM_GT, /* Match > line number */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
201 NFA_LNUM_LT, /* Match < line number */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
202 NFA_COL, /* Match cursor column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
203 NFA_COL_GT, /* Match > cursor column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
204 NFA_COL_LT, /* Match < cursor column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
205 NFA_VCOL, /* Match cursor virtual column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
206 NFA_VCOL_GT, /* Match > cursor virtual column */ |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
207 NFA_VCOL_LT, /* Match < cursor virtual column */ |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
208 NFA_MARK, /* Match mark */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
209 NFA_MARK_GT, /* Match > mark */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
210 NFA_MARK_LT, /* Match < mark */ |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
211 NFA_VISUAL, /* Match Visual area */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
212 |
4444 | 213 /* Character classes [:alnum:] etc */ |
214 NFA_CLASS_ALNUM, | |
215 NFA_CLASS_ALPHA, | |
216 NFA_CLASS_BLANK, | |
217 NFA_CLASS_CNTRL, | |
218 NFA_CLASS_DIGIT, | |
219 NFA_CLASS_GRAPH, | |
220 NFA_CLASS_LOWER, | |
221 NFA_CLASS_PRINT, | |
222 NFA_CLASS_PUNCT, | |
223 NFA_CLASS_SPACE, | |
224 NFA_CLASS_UPPER, | |
225 NFA_CLASS_XDIGIT, | |
226 NFA_CLASS_TAB, | |
227 NFA_CLASS_RETURN, | |
228 NFA_CLASS_BACKSPACE, | |
229 NFA_CLASS_ESCAPE | |
230 }; | |
231 | |
232 /* Keep in sync with classchars. */ | |
233 static int nfa_classcodes[] = { | |
234 NFA_ANY, NFA_IDENT, NFA_SIDENT, NFA_KWORD,NFA_SKWORD, | |
235 NFA_FNAME, NFA_SFNAME, NFA_PRINT, NFA_SPRINT, | |
236 NFA_WHITE, NFA_NWHITE, NFA_DIGIT, NFA_NDIGIT, | |
237 NFA_HEX, NFA_NHEX, NFA_OCTAL, NFA_NOCTAL, | |
238 NFA_WORD, NFA_NWORD, NFA_HEAD, NFA_NHEAD, | |
239 NFA_ALPHA, NFA_NALPHA, NFA_LOWER, NFA_NLOWER, | |
240 NFA_UPPER, NFA_NUPPER | |
241 }; | |
242 | |
5511 | 243 static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely"); |
4444 | 244 static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c"); |
5511 | 245 static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %ld"); |
4444 | 246 |
6533 | 247 /* re_flags passed to nfa_regcomp() */ |
248 static int nfa_re_flags; | |
249 | |
4444 | 250 /* NFA regexp \ze operator encountered. */ |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
251 static int nfa_has_zend; |
4444 | 252 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
253 /* NFA regexp \1 .. \9 encountered. */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
254 static int nfa_has_backref; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
255 |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
256 #ifdef FEAT_SYN_HL |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
257 /* NFA regexp has \z( ), set zsubexpr. */ |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
258 static int nfa_has_zsubexpr; |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
259 #endif |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
260 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
261 /* Number of sub expressions actually being used during execution. 1 if only |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
262 * the whole match (subexpr 0) is used. */ |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
263 static int nfa_nsubexpr; |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
264 |
4444 | 265 static int *post_start; /* holds the postfix form of r.e. */ |
266 static int *post_end; | |
267 static int *post_ptr; | |
268 | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
269 static int nstate; /* Number of states in the NFA. Also used when |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
270 * executing. */ |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
271 static int istate; /* Index in the state vector, used in alloc_state() */ |
4444 | 272 |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
273 /* If not NULL match must end at this position */ |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
274 static save_se_T *nfa_endp = NULL; |
4444 | 275 |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
276 /* listid is global, so that it increases on recursive calls to |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
277 * nfa_regmatch(), which means we don't have to clear the lastlist field of |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
278 * all the states. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
279 static int nfa_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
280 static int nfa_alt_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
281 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
282 /* 0 for first call to nfa_regmatch(), 1 for recursive call. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
283 static int nfa_ll_index = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
284 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
285 static int nfa_regcomp_start(char_u *expr, int re_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
286 static int nfa_get_reganch(nfa_state_T *start, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
287 static int nfa_get_regstart(nfa_state_T *start, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
288 static char_u *nfa_get_match_text(nfa_state_T *start); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
289 static int realloc_post_list(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
290 static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
291 static int nfa_emit_equi_class(int c); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
292 static int nfa_regatom(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
293 static int nfa_regpiece(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
294 static int nfa_regconcat(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
295 static int nfa_regbranch(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
296 static int nfa_reg(int paren); |
4444 | 297 #ifdef DEBUG |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
298 static void nfa_set_code(int c); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
299 static void nfa_postfix_dump(char_u *expr, int retval); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
300 static void nfa_print_state(FILE *debugf, nfa_state_T *state); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
301 static void nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
302 static void nfa_dump(nfa_regprog_T *prog); |
4444 | 303 #endif |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
304 static int *re2post(void); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
305 static nfa_state_T *alloc_state(int c, nfa_state_T *out, nfa_state_T *out1); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
306 static void st_error(int *postfix, int *end, int *p); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
307 static int nfa_max_width(nfa_state_T *startstate, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
308 static nfa_state_T *post2nfa(int *postfix, int *end, int nfa_calc_size); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
309 static void nfa_postprocess(nfa_regprog_T *prog); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
310 static int check_char_class(int class, int c); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
311 static void nfa_save_listids(nfa_regprog_T *prog, int *list); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
312 static void nfa_restore_listids(nfa_regprog_T *prog, int *list); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
313 static int nfa_re_num_cmp(long_u val, int op, long_u pos); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
314 static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
315 static long nfa_regexec_both(char_u *line, colnr_T col, proftime_T *tm); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
316 static regprog_T *nfa_regcomp(char_u *expr, int re_flags); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
317 static void nfa_regfree(regprog_T *prog); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
318 static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
319 static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
320 static int match_follows(nfa_state_T *startstate, int depth); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
321 static int failure_chance(nfa_state_T *state, int depth); |
4444 | 322 |
323 /* helper functions used when doing re2post() ... regatom() parsing */ | |
324 #define EMIT(c) do { \ | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
325 if (post_ptr >= post_end && realloc_post_list() == FAIL) \ |
4444 | 326 return FAIL; \ |
327 *post_ptr++ = c; \ | |
328 } while (0) | |
329 | |
330 /* | |
331 * Initialize internal variables before NFA compilation. | |
332 * Return OK on success, FAIL otherwise. | |
333 */ | |
334 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
335 nfa_regcomp_start( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
336 char_u *expr, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
337 int re_flags) /* see vim_regcomp() */ |
4444 | 338 { |
4458 | 339 size_t postfix_size; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
340 int nstate_max; |
4444 | 341 |
342 nstate = 0; | |
343 istate = 0; | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
344 /* A reasonable estimation for maximum size */ |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
345 nstate_max = (int)(STRLEN(expr) + 1) * 25; |
4444 | 346 |
4454 | 347 /* Some items blow up in size, such as [A-z]. Add more space for that. |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
348 * When it is still not enough realloc_post_list() will be used. */ |
4458 | 349 nstate_max += 1000; |
4454 | 350 |
351 /* Size for postfix representation of expr. */ | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
352 postfix_size = sizeof(int) * nstate_max; |
4454 | 353 |
4444 | 354 post_start = (int *)lalloc(postfix_size, TRUE); |
355 if (post_start == NULL) | |
356 return FAIL; | |
357 post_ptr = post_start; | |
4454 | 358 post_end = post_start + nstate_max; |
4444 | 359 nfa_has_zend = FALSE; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
360 nfa_has_backref = FALSE; |
4444 | 361 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
362 /* shared with BT engine */ |
4444 | 363 regcomp_start(expr, re_flags); |
364 | |
365 return OK; | |
366 } | |
367 | |
368 /* | |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
369 * Figure out if the NFA state list starts with an anchor, must match at start |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
370 * of the line. |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
371 */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
372 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
373 nfa_get_reganch(nfa_state_T *start, int depth) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
374 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
375 nfa_state_T *p = start; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
376 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
377 if (depth > 4) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
378 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
379 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
380 while (p != NULL) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
381 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
382 switch (p->c) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
383 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
384 case NFA_BOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
385 case NFA_BOF: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
386 return 1; /* yes! */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
387 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
388 case NFA_ZSTART: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
389 case NFA_ZEND: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
390 case NFA_CURSOR: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
391 case NFA_VISUAL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
392 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
393 case NFA_MOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
394 case NFA_MOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
395 case NFA_MOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
396 case NFA_MOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
397 case NFA_MOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
398 case NFA_MOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
399 case NFA_MOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
400 case NFA_MOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
401 case NFA_MOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
402 case NFA_MOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
403 case NFA_NOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
404 #ifdef FEAT_SYN_HL |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
405 case NFA_ZOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
406 case NFA_ZOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
407 case NFA_ZOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
408 case NFA_ZOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
409 case NFA_ZOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
410 case NFA_ZOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
411 case NFA_ZOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
412 case NFA_ZOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
413 case NFA_ZOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
414 case NFA_ZOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
415 #endif |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
416 p = p->out; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
417 break; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
418 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
419 case NFA_SPLIT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
420 return nfa_get_reganch(p->out, depth + 1) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
421 && nfa_get_reganch(p->out1, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
422 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
423 default: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
424 return 0; /* noooo */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
425 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
426 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
427 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
428 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
429 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
430 /* |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
431 * Figure out if the NFA state list starts with a character which must match |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
432 * at start of the match. |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
433 */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
434 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
435 nfa_get_regstart(nfa_state_T *start, int depth) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
436 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
437 nfa_state_T *p = start; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
438 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
439 if (depth > 4) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
440 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
441 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
442 while (p != NULL) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
443 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
444 switch (p->c) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
445 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
446 /* all kinds of zero-width matches */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
447 case NFA_BOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
448 case NFA_BOF: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
449 case NFA_BOW: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
450 case NFA_EOW: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
451 case NFA_ZSTART: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
452 case NFA_ZEND: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
453 case NFA_CURSOR: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
454 case NFA_VISUAL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
455 case NFA_LNUM: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
456 case NFA_LNUM_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
457 case NFA_LNUM_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
458 case NFA_COL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
459 case NFA_COL_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
460 case NFA_COL_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
461 case NFA_VCOL: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
462 case NFA_VCOL_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
463 case NFA_VCOL_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
464 case NFA_MARK: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
465 case NFA_MARK_GT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
466 case NFA_MARK_LT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
467 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
468 case NFA_MOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
469 case NFA_MOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
470 case NFA_MOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
471 case NFA_MOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
472 case NFA_MOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
473 case NFA_MOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
474 case NFA_MOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
475 case NFA_MOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
476 case NFA_MOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
477 case NFA_MOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
478 case NFA_NOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
479 #ifdef FEAT_SYN_HL |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
480 case NFA_ZOPEN: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
481 case NFA_ZOPEN1: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
482 case NFA_ZOPEN2: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
483 case NFA_ZOPEN3: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
484 case NFA_ZOPEN4: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
485 case NFA_ZOPEN5: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
486 case NFA_ZOPEN6: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
487 case NFA_ZOPEN7: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
488 case NFA_ZOPEN8: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
489 case NFA_ZOPEN9: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
490 #endif |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
491 p = p->out; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
492 break; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
493 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
494 case NFA_SPLIT: |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
495 { |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
496 int c1 = nfa_get_regstart(p->out, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
497 int c2 = nfa_get_regstart(p->out1, depth + 1); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
498 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
499 if (c1 == c2) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
500 return c1; /* yes! */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
501 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
502 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
503 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
504 default: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
505 if (p->c > 0) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
506 return p->c; /* yes! */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
507 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
508 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
509 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
510 return 0; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
511 } |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
512 |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
513 /* |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
514 * Figure out if the NFA state list contains just literal text and nothing |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
515 * else. If so return a string in allocated memory with what must match after |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
516 * regstart. Otherwise return NULL. |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
517 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
518 static char_u * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
519 nfa_get_match_text(nfa_state_T *start) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
520 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
521 nfa_state_T *p = start; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
522 int len = 0; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
523 char_u *ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
524 char_u *s; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
525 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
526 if (p->c != NFA_MOPEN) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
527 return NULL; /* just in case */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
528 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
529 while (p->c > 0) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
530 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
531 len += MB_CHAR2LEN(p->c); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
532 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
533 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
534 if (p->c != NFA_MCLOSE || p->out->c != NFA_MATCH) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
535 return NULL; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
536 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
537 ret = alloc(len); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
538 if (ret != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
539 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
540 p = start->out->out; /* skip first char, it goes into regstart */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
541 s = ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
542 while (p->c > 0) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
543 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
544 #ifdef FEAT_MBYTE |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
545 if (has_mbyte) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
546 s += (*mb_char2bytes)(p->c, s); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
547 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
548 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
549 *s++ = p->c; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
550 p = p->out; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
551 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
552 *s = NUL; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
553 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
554 return ret; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
555 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
556 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
557 /* |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
558 * Allocate more space for post_start. Called when |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
559 * running above the estimated number of states. |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
560 */ |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
561 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
562 realloc_post_list(void) |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
563 { |
4667
9e7ef781d494
updated for version 7.3.1081
Bram Moolenaar <bram@vim.org>
parents:
4661
diff
changeset
|
564 int nstate_max = (int)(post_end - post_start); |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
565 int new_max = nstate_max + 1000; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
566 int *new_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
567 int *old_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
568 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
569 new_start = (int *)lalloc(new_max * sizeof(int), TRUE); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
570 if (new_start == NULL) |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
571 return FAIL; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
572 mch_memmove(new_start, post_start, nstate_max * sizeof(int)); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
573 old_start = post_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
574 post_start = new_start; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
575 post_ptr = new_start + (post_ptr - old_start); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
576 post_end = post_start + new_max; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
577 vim_free(old_start); |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
578 return OK; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
579 } |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
580 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
581 /* |
4444 | 582 * Search between "start" and "end" and try to recognize a |
583 * character class in expanded form. For example [0-9]. | |
584 * On success, return the id the character class to be emitted. | |
585 * On failure, return 0 (=FAIL) | |
586 * Start points to the first char of the range, while end should point | |
587 * to the closing brace. | |
5296 | 588 * Keep in mind that 'ignorecase' applies at execution time, thus [a-z] may |
589 * need to be interpreted as [a-zA-Z]. | |
4444 | 590 */ |
591 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
592 nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) |
4444 | 593 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
594 # define CLASS_not 0x80 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
595 # define CLASS_af 0x40 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
596 # define CLASS_AF 0x20 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
597 # define CLASS_az 0x10 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
598 # define CLASS_AZ 0x08 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
599 # define CLASS_o7 0x04 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
600 # define CLASS_o9 0x02 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
601 # define CLASS_underscore 0x01 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
602 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
603 int newl = FALSE; |
4444 | 604 char_u *p; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
605 int config = 0; |
4444 | 606 |
607 if (extra_newl == TRUE) | |
608 newl = TRUE; | |
609 | |
610 if (*end != ']') | |
611 return FAIL; | |
612 p = start; | |
613 if (*p == '^') | |
614 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
615 config |= CLASS_not; |
4720
bd6bef0bd0fb
updated for version 7.3.1107
Bram Moolenaar <bram@vim.org>
parents:
4718
diff
changeset
|
616 p++; |
4444 | 617 } |
618 | |
619 while (p < end) | |
620 { | |
621 if (p + 2 < end && *(p + 1) == '-') | |
622 { | |
623 switch (*p) | |
624 { | |
625 case '0': | |
626 if (*(p + 2) == '9') | |
627 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
628 config |= CLASS_o9; |
4444 | 629 break; |
630 } | |
631 else | |
632 if (*(p + 2) == '7') | |
633 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
634 config |= CLASS_o7; |
4444 | 635 break; |
636 } | |
637 case 'a': | |
638 if (*(p + 2) == 'z') | |
639 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
640 config |= CLASS_az; |
4444 | 641 break; |
642 } | |
643 else | |
644 if (*(p + 2) == 'f') | |
645 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
646 config |= CLASS_af; |
4444 | 647 break; |
648 } | |
649 case 'A': | |
650 if (*(p + 2) == 'Z') | |
651 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
652 config |= CLASS_AZ; |
4444 | 653 break; |
654 } | |
655 else | |
656 if (*(p + 2) == 'F') | |
657 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
658 config |= CLASS_AF; |
4444 | 659 break; |
660 } | |
661 /* FALLTHROUGH */ | |
662 default: | |
663 return FAIL; | |
664 } | |
665 p += 3; | |
666 } | |
667 else if (p + 1 < end && *p == '\\' && *(p + 1) == 'n') | |
668 { | |
669 newl = TRUE; | |
670 p += 2; | |
671 } | |
672 else if (*p == '_') | |
673 { | |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
674 config |= CLASS_underscore; |
4444 | 675 p ++; |
676 } | |
677 else if (*p == '\n') | |
678 { | |
679 newl = TRUE; | |
680 p ++; | |
681 } | |
682 else | |
683 return FAIL; | |
684 } /* while (p < end) */ | |
685 | |
686 if (p != end) | |
687 return FAIL; | |
688 | |
689 if (newl == TRUE) | |
5296 | 690 extra_newl = NFA_ADD_NL; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
691 |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
692 switch (config) |
4444 | 693 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
694 case CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
695 return extra_newl + NFA_DIGIT; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
696 case CLASS_not | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
697 return extra_newl + NFA_NDIGIT; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
698 case CLASS_af | CLASS_AF | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
699 return extra_newl + NFA_HEX; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
700 case CLASS_not | CLASS_af | CLASS_AF | CLASS_o9: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
701 return extra_newl + NFA_NHEX; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
702 case CLASS_o7: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
703 return extra_newl + NFA_OCTAL; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
704 case CLASS_not | CLASS_o7: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
705 return extra_newl + NFA_NOCTAL; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
706 case CLASS_az | CLASS_AZ | CLASS_o9 | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
707 return extra_newl + NFA_WORD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
708 case CLASS_not | CLASS_az | CLASS_AZ | CLASS_o9 | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
709 return extra_newl + NFA_NWORD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
710 case CLASS_az | CLASS_AZ | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
711 return extra_newl + NFA_HEAD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
712 case CLASS_not | CLASS_az | CLASS_AZ | CLASS_underscore: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
713 return extra_newl + NFA_NHEAD; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
714 case CLASS_az | CLASS_AZ: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
715 return extra_newl + NFA_ALPHA; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
716 case CLASS_not | CLASS_az | CLASS_AZ: |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
717 return extra_newl + NFA_NALPHA; |
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
718 case CLASS_az: |
5296 | 719 return extra_newl + NFA_LOWER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
720 case CLASS_not | CLASS_az: |
5296 | 721 return extra_newl + NFA_NLOWER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
722 case CLASS_AZ: |
5296 | 723 return extra_newl + NFA_UPPER_IC; |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
724 case CLASS_not | CLASS_AZ: |
5296 | 725 return extra_newl + NFA_NUPPER_IC; |
4444 | 726 } |
727 return FAIL; | |
728 } | |
729 | |
730 /* | |
731 * Produce the bytes for equivalence class "c". | |
732 * Currently only handles latin1, latin9 and utf-8. | |
733 * Emits bytes in postfix notation: 'a,b,NFA_OR,c,NFA_OR' is | |
734 * equivalent to 'a OR b OR c' | |
735 * | |
736 * NOTE! When changing this function, also update reg_equi_class() | |
737 */ | |
738 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
739 nfa_emit_equi_class(int c) |
4444 | 740 { |
5351 | 741 #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); |
742 #ifdef FEAT_MBYTE | |
743 # define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT); | |
744 #else | |
745 # define EMITMBC(c) | |
746 #endif | |
4444 | 747 |
748 #ifdef FEAT_MBYTE | |
749 if (enc_utf8 || STRCMP(p_enc, "latin1") == 0 | |
750 || STRCMP(p_enc, "iso-8859-15") == 0) | |
751 #endif | |
752 { | |
753 switch (c) | |
754 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
755 case 'A': case 0300: case 0301: case 0302: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
756 case 0303: case 0304: case 0305: |
5351 | 757 CASEMBC(0x100) CASEMBC(0x102) CASEMBC(0x104) CASEMBC(0x1cd) |
758 CASEMBC(0x1de) CASEMBC(0x1e0) CASEMBC(0x1ea2) | |
759 EMIT2('A'); EMIT2(0300); EMIT2(0301); EMIT2(0302); | |
760 EMIT2(0303); EMIT2(0304); EMIT2(0305); | |
761 EMITMBC(0x100) EMITMBC(0x102) EMITMBC(0x104) | |
762 EMITMBC(0x1cd) EMITMBC(0x1de) EMITMBC(0x1e0) | |
763 EMITMBC(0x1ea2) | |
764 return OK; | |
765 | |
766 case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06) | |
767 EMIT2('B'); EMITMBC(0x1e02) EMITMBC(0x1e06) | |
4444 | 768 return OK; |
769 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
770 case 'C': case 0307: |
5351 | 771 CASEMBC(0x106) CASEMBC(0x108) CASEMBC(0x10a) CASEMBC(0x10c) |
772 EMIT2('C'); EMIT2(0307); EMITMBC(0x106) EMITMBC(0x108) | |
773 EMITMBC(0x10a) EMITMBC(0x10c) | |
774 return OK; | |
775 | |
776 case 'D': CASEMBC(0x10e) CASEMBC(0x110) CASEMBC(0x1e0a) | |
777 CASEMBC(0x1e0e) CASEMBC(0x1e10) | |
778 EMIT2('D'); EMITMBC(0x10e) EMITMBC(0x110) EMITMBC(0x1e0a) | |
779 EMITMBC(0x1e0e) EMITMBC(0x1e10) | |
4444 | 780 return OK; |
781 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
782 case 'E': case 0310: case 0311: case 0312: case 0313: |
5351 | 783 CASEMBC(0x112) CASEMBC(0x114) CASEMBC(0x116) CASEMBC(0x118) |
784 CASEMBC(0x11a) CASEMBC(0x1eba) CASEMBC(0x1ebc) | |
785 EMIT2('E'); EMIT2(0310); EMIT2(0311); EMIT2(0312); | |
786 EMIT2(0313); | |
787 EMITMBC(0x112) EMITMBC(0x114) EMITMBC(0x116) | |
788 EMITMBC(0x118) EMITMBC(0x11a) EMITMBC(0x1eba) | |
789 EMITMBC(0x1ebc) | |
790 return OK; | |
791 | |
792 case 'F': CASEMBC(0x1e1e) | |
793 EMIT2('F'); EMITMBC(0x1e1e) | |
794 return OK; | |
795 | |
796 case 'G': CASEMBC(0x11c) CASEMBC(0x11e) CASEMBC(0x120) | |
797 CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6) CASEMBC(0x1f4) | |
798 CASEMBC(0x1e20) | |
799 EMIT2('G'); EMITMBC(0x11c) EMITMBC(0x11e) EMITMBC(0x120) | |
800 EMITMBC(0x122) EMITMBC(0x1e4) EMITMBC(0x1e6) | |
801 EMITMBC(0x1f4) EMITMBC(0x1e20) | |
802 return OK; | |
803 | |
804 case 'H': CASEMBC(0x124) CASEMBC(0x126) CASEMBC(0x1e22) | |
805 CASEMBC(0x1e26) CASEMBC(0x1e28) | |
806 EMIT2('H'); EMITMBC(0x124) EMITMBC(0x126) EMITMBC(0x1e22) | |
807 EMITMBC(0x1e26) EMITMBC(0x1e28) | |
4444 | 808 return OK; |
809 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
810 case 'I': case 0314: case 0315: case 0316: case 0317: |
5351 | 811 CASEMBC(0x128) CASEMBC(0x12a) CASEMBC(0x12c) CASEMBC(0x12e) |
812 CASEMBC(0x130) CASEMBC(0x1cf) CASEMBC(0x1ec8) | |
813 EMIT2('I'); EMIT2(0314); EMIT2(0315); EMIT2(0316); | |
814 EMIT2(0317); EMITMBC(0x128) EMITMBC(0x12a) | |
815 EMITMBC(0x12c) EMITMBC(0x12e) EMITMBC(0x130) | |
816 EMITMBC(0x1cf) EMITMBC(0x1ec8) | |
817 return OK; | |
818 | |
819 case 'J': CASEMBC(0x134) | |
820 EMIT2('J'); EMITMBC(0x134) | |
821 return OK; | |
822 | |
823 case 'K': CASEMBC(0x136) CASEMBC(0x1e8) CASEMBC(0x1e30) | |
824 CASEMBC(0x1e34) | |
825 EMIT2('K'); EMITMBC(0x136) EMITMBC(0x1e8) EMITMBC(0x1e30) | |
826 EMITMBC(0x1e34) | |
827 return OK; | |
828 | |
829 case 'L': CASEMBC(0x139) CASEMBC(0x13b) CASEMBC(0x13d) | |
830 CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a) | |
831 EMIT2('L'); EMITMBC(0x139) EMITMBC(0x13b) EMITMBC(0x13d) | |
832 EMITMBC(0x13f) EMITMBC(0x141) EMITMBC(0x1e3a) | |
833 return OK; | |
834 | |
835 case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40) | |
836 EMIT2('M'); EMITMBC(0x1e3e) EMITMBC(0x1e40) | |
4444 | 837 return OK; |
838 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
839 case 'N': case 0321: |
5351 | 840 CASEMBC(0x143) CASEMBC(0x145) CASEMBC(0x147) CASEMBC(0x1e44) |
841 CASEMBC(0x1e48) | |
842 EMIT2('N'); EMIT2(0321); EMITMBC(0x143) EMITMBC(0x145) | |
843 EMITMBC(0x147) EMITMBC(0x1e44) EMITMBC(0x1e48) | |
4444 | 844 return OK; |
845 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
846 case 'O': case 0322: case 0323: case 0324: case 0325: |
5351 | 847 case 0326: case 0330: |
848 CASEMBC(0x14c) CASEMBC(0x14e) CASEMBC(0x150) CASEMBC(0x1a0) | |
849 CASEMBC(0x1d1) CASEMBC(0x1ea) CASEMBC(0x1ec) CASEMBC(0x1ece) | |
850 EMIT2('O'); EMIT2(0322); EMIT2(0323); EMIT2(0324); | |
851 EMIT2(0325); EMIT2(0326); EMIT2(0330); | |
852 EMITMBC(0x14c) EMITMBC(0x14e) EMITMBC(0x150) | |
853 EMITMBC(0x1a0) EMITMBC(0x1d1) EMITMBC(0x1ea) | |
854 EMITMBC(0x1ec) EMITMBC(0x1ece) | |
855 return OK; | |
856 | |
857 case 'P': case 0x1e54: case 0x1e56: | |
858 EMIT2('P'); EMITMBC(0x1e54) EMITMBC(0x1e56) | |
859 return OK; | |
860 | |
861 case 'R': CASEMBC(0x154) CASEMBC(0x156) CASEMBC(0x158) | |
862 CASEMBC(0x1e58) CASEMBC(0x1e5e) | |
863 EMIT2('R'); EMITMBC(0x154) EMITMBC(0x156) EMITMBC(0x158) | |
864 EMITMBC(0x1e58) EMITMBC(0x1e5e) | |
865 return OK; | |
866 | |
867 case 'S': CASEMBC(0x15a) CASEMBC(0x15c) CASEMBC(0x15e) | |
868 CASEMBC(0x160) CASEMBC(0x1e60) | |
869 EMIT2('S'); EMITMBC(0x15a) EMITMBC(0x15c) EMITMBC(0x15e) | |
870 EMITMBC(0x160) EMITMBC(0x1e60) | |
871 return OK; | |
872 | |
873 case 'T': CASEMBC(0x162) CASEMBC(0x164) CASEMBC(0x166) | |
874 CASEMBC(0x1e6a) CASEMBC(0x1e6e) | |
875 EMIT2('T'); EMITMBC(0x162) EMITMBC(0x164) EMITMBC(0x166) | |
876 EMITMBC(0x1e6a) EMITMBC(0x1e6e) | |
4444 | 877 return OK; |
878 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
879 case 'U': case 0331: case 0332: case 0333: case 0334: |
5351 | 880 CASEMBC(0x168) CASEMBC(0x16a) CASEMBC(0x16c) CASEMBC(0x16e) |
881 CASEMBC(0x170) CASEMBC(0x172) CASEMBC(0x1af) CASEMBC(0x1d3) | |
882 CASEMBC(0x1ee6) | |
883 EMIT2('U'); EMIT2(0331); EMIT2(0332); EMIT2(0333); | |
884 EMIT2(0334); EMITMBC(0x168) EMITMBC(0x16a) | |
885 EMITMBC(0x16c) EMITMBC(0x16e) EMITMBC(0x170) | |
886 EMITMBC(0x172) EMITMBC(0x1af) EMITMBC(0x1d3) | |
887 EMITMBC(0x1ee6) | |
888 return OK; | |
889 | |
890 case 'V': CASEMBC(0x1e7c) | |
891 EMIT2('V'); EMITMBC(0x1e7c) | |
892 return OK; | |
893 | |
894 case 'W': CASEMBC(0x174) CASEMBC(0x1e80) CASEMBC(0x1e82) | |
895 CASEMBC(0x1e84) CASEMBC(0x1e86) | |
896 EMIT2('W'); EMITMBC(0x174) EMITMBC(0x1e80) EMITMBC(0x1e82) | |
897 EMITMBC(0x1e84) EMITMBC(0x1e86) | |
898 return OK; | |
899 | |
900 case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c) | |
901 EMIT2('X'); EMITMBC(0x1e8a) EMITMBC(0x1e8c) | |
4444 | 902 return OK; |
903 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
904 case 'Y': case 0335: |
5351 | 905 CASEMBC(0x176) CASEMBC(0x178) CASEMBC(0x1e8e) CASEMBC(0x1ef2) |
906 CASEMBC(0x1ef6) CASEMBC(0x1ef8) | |
907 EMIT2('Y'); EMIT2(0335); EMITMBC(0x176) EMITMBC(0x178) | |
908 EMITMBC(0x1e8e) EMITMBC(0x1ef2) EMITMBC(0x1ef6) | |
909 EMITMBC(0x1ef8) | |
910 return OK; | |
911 | |
912 case 'Z': CASEMBC(0x179) CASEMBC(0x17b) CASEMBC(0x17d) | |
913 CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94) | |
914 EMIT2('Z'); EMITMBC(0x179) EMITMBC(0x17b) EMITMBC(0x17d) | |
915 EMITMBC(0x1b5) EMITMBC(0x1e90) EMITMBC(0x1e94) | |
4444 | 916 return OK; |
917 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
918 case 'a': case 0340: case 0341: case 0342: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
919 case 0343: case 0344: case 0345: |
5351 | 920 CASEMBC(0x101) CASEMBC(0x103) CASEMBC(0x105) CASEMBC(0x1ce) |
921 CASEMBC(0x1df) CASEMBC(0x1e1) CASEMBC(0x1ea3) | |
922 EMIT2('a'); EMIT2(0340); EMIT2(0341); EMIT2(0342); | |
923 EMIT2(0343); EMIT2(0344); EMIT2(0345); | |
924 EMITMBC(0x101) EMITMBC(0x103) EMITMBC(0x105) | |
925 EMITMBC(0x1ce) EMITMBC(0x1df) EMITMBC(0x1e1) | |
926 EMITMBC(0x1ea3) | |
927 return OK; | |
928 | |
929 case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07) | |
930 EMIT2('b'); EMITMBC(0x1e03) EMITMBC(0x1e07) | |
4444 | 931 return OK; |
932 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
933 case 'c': case 0347: |
5351 | 934 CASEMBC(0x107) CASEMBC(0x109) CASEMBC(0x10b) CASEMBC(0x10d) |
935 EMIT2('c'); EMIT2(0347); EMITMBC(0x107) EMITMBC(0x109) | |
936 EMITMBC(0x10b) EMITMBC(0x10d) | |
937 return OK; | |
938 | |
6914 | 939 case 'd': CASEMBC(0x10f) CASEMBC(0x111) CASEMBC(0x1e0b) |
940 CASEMBC(0x1e0f) CASEMBC(0x1e11) | |
941 EMIT2('d'); EMITMBC(0x10f) EMITMBC(0x111) | |
942 EMITMBC(0x1e0b) EMITMBC(0x1e0f) EMITMBC(0x1e11) | |
4444 | 943 return OK; |
944 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
945 case 'e': case 0350: case 0351: case 0352: case 0353: |
5351 | 946 CASEMBC(0x113) CASEMBC(0x115) CASEMBC(0x117) CASEMBC(0x119) |
947 CASEMBC(0x11b) CASEMBC(0x1ebb) CASEMBC(0x1ebd) | |
948 EMIT2('e'); EMIT2(0350); EMIT2(0351); EMIT2(0352); | |
949 EMIT2(0353); EMITMBC(0x113) EMITMBC(0x115) | |
950 EMITMBC(0x117) EMITMBC(0x119) EMITMBC(0x11b) | |
951 EMITMBC(0x1ebb) EMITMBC(0x1ebd) | |
952 return OK; | |
953 | |
954 case 'f': CASEMBC(0x1e1f) | |
955 EMIT2('f'); EMITMBC(0x1e1f) | |
956 return OK; | |
957 | |
958 case 'g': CASEMBC(0x11d) CASEMBC(0x11f) CASEMBC(0x121) | |
959 CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7) CASEMBC(0x1f5) | |
960 CASEMBC(0x1e21) | |
961 EMIT2('g'); EMITMBC(0x11d) EMITMBC(0x11f) EMITMBC(0x121) | |
962 EMITMBC(0x123) EMITMBC(0x1e5) EMITMBC(0x1e7) | |
963 EMITMBC(0x1f5) EMITMBC(0x1e21) | |
964 return OK; | |
965 | |
966 case 'h': CASEMBC(0x125) CASEMBC(0x127) CASEMBC(0x1e23) | |
967 CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96) | |
968 EMIT2('h'); EMITMBC(0x125) EMITMBC(0x127) EMITMBC(0x1e23) | |
969 EMITMBC(0x1e27) EMITMBC(0x1e29) EMITMBC(0x1e96) | |
4444 | 970 return OK; |
971 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
972 case 'i': case 0354: case 0355: case 0356: case 0357: |
5351 | 973 CASEMBC(0x129) CASEMBC(0x12b) CASEMBC(0x12d) CASEMBC(0x12f) |
974 CASEMBC(0x1d0) CASEMBC(0x1ec9) | |
975 EMIT2('i'); EMIT2(0354); EMIT2(0355); EMIT2(0356); | |
976 EMIT2(0357); EMITMBC(0x129) EMITMBC(0x12b) | |
977 EMITMBC(0x12d) EMITMBC(0x12f) EMITMBC(0x1d0) | |
978 EMITMBC(0x1ec9) | |
979 return OK; | |
980 | |
981 case 'j': CASEMBC(0x135) CASEMBC(0x1f0) | |
982 EMIT2('j'); EMITMBC(0x135) EMITMBC(0x1f0) | |
983 return OK; | |
984 | |
985 case 'k': CASEMBC(0x137) CASEMBC(0x1e9) CASEMBC(0x1e31) | |
986 CASEMBC(0x1e35) | |
987 EMIT2('k'); EMITMBC(0x137) EMITMBC(0x1e9) EMITMBC(0x1e31) | |
988 EMITMBC(0x1e35) | |
989 return OK; | |
990 | |
991 case 'l': CASEMBC(0x13a) CASEMBC(0x13c) CASEMBC(0x13e) | |
992 CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b) | |
993 EMIT2('l'); EMITMBC(0x13a) EMITMBC(0x13c) EMITMBC(0x13e) | |
994 EMITMBC(0x140) EMITMBC(0x142) EMITMBC(0x1e3b) | |
995 return OK; | |
996 | |
997 case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41) | |
998 EMIT2('m'); EMITMBC(0x1e3f) EMITMBC(0x1e41) | |
4444 | 999 return OK; |
1000 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1001 case 'n': case 0361: |
5351 | 1002 CASEMBC(0x144) CASEMBC(0x146) CASEMBC(0x148) CASEMBC(0x149) |
1003 CASEMBC(0x1e45) CASEMBC(0x1e49) | |
1004 EMIT2('n'); EMIT2(0361); EMITMBC(0x144) EMITMBC(0x146) | |
1005 EMITMBC(0x148) EMITMBC(0x149) EMITMBC(0x1e45) | |
1006 EMITMBC(0x1e49) | |
4444 | 1007 return OK; |
1008 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1009 case 'o': case 0362: case 0363: case 0364: case 0365: |
5351 | 1010 case 0366: case 0370: |
1011 CASEMBC(0x14d) CASEMBC(0x14f) CASEMBC(0x151) CASEMBC(0x1a1) | |
1012 CASEMBC(0x1d2) CASEMBC(0x1eb) CASEMBC(0x1ed) CASEMBC(0x1ecf) | |
1013 EMIT2('o'); EMIT2(0362); EMIT2(0363); EMIT2(0364); | |
1014 EMIT2(0365); EMIT2(0366); EMIT2(0370); | |
1015 EMITMBC(0x14d) EMITMBC(0x14f) EMITMBC(0x151) | |
1016 EMITMBC(0x1a1) EMITMBC(0x1d2) EMITMBC(0x1eb) | |
1017 EMITMBC(0x1ed) EMITMBC(0x1ecf) | |
1018 return OK; | |
1019 | |
1020 case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57) | |
1021 EMIT2('p'); EMITMBC(0x1e55) EMITMBC(0x1e57) | |
1022 return OK; | |
1023 | |
1024 case 'r': CASEMBC(0x155) CASEMBC(0x157) CASEMBC(0x159) | |
1025 CASEMBC(0x1e59) CASEMBC(0x1e5f) | |
1026 EMIT2('r'); EMITMBC(0x155) EMITMBC(0x157) EMITMBC(0x159) | |
1027 EMITMBC(0x1e59) EMITMBC(0x1e5f) | |
1028 return OK; | |
1029 | |
1030 case 's': CASEMBC(0x15b) CASEMBC(0x15d) CASEMBC(0x15f) | |
1031 CASEMBC(0x161) CASEMBC(0x1e61) | |
1032 EMIT2('s'); EMITMBC(0x15b) EMITMBC(0x15d) EMITMBC(0x15f) | |
1033 EMITMBC(0x161) EMITMBC(0x1e61) | |
1034 return OK; | |
1035 | |
1036 case 't': CASEMBC(0x163) CASEMBC(0x165) CASEMBC(0x167) | |
1037 CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97) | |
1038 EMIT2('t'); EMITMBC(0x163) EMITMBC(0x165) EMITMBC(0x167) | |
1039 EMITMBC(0x1e6b) EMITMBC(0x1e6f) EMITMBC(0x1e97) | |
4444 | 1040 return OK; |
1041 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1042 case 'u': case 0371: case 0372: case 0373: case 0374: |
5351 | 1043 CASEMBC(0x169) CASEMBC(0x16b) CASEMBC(0x16d) CASEMBC(0x16f) |
1044 CASEMBC(0x171) CASEMBC(0x173) CASEMBC(0x1b0) CASEMBC(0x1d4) | |
1045 CASEMBC(0x1ee7) | |
1046 EMIT2('u'); EMIT2(0371); EMIT2(0372); EMIT2(0373); | |
1047 EMIT2(0374); EMITMBC(0x169) EMITMBC(0x16b) | |
1048 EMITMBC(0x16d) EMITMBC(0x16f) EMITMBC(0x171) | |
1049 EMITMBC(0x173) EMITMBC(0x1b0) EMITMBC(0x1d4) | |
1050 EMITMBC(0x1ee7) | |
1051 return OK; | |
1052 | |
1053 case 'v': CASEMBC(0x1e7d) | |
1054 EMIT2('v'); EMITMBC(0x1e7d) | |
1055 return OK; | |
1056 | |
1057 case 'w': CASEMBC(0x175) CASEMBC(0x1e81) CASEMBC(0x1e83) | |
1058 CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98) | |
1059 EMIT2('w'); EMITMBC(0x175) EMITMBC(0x1e81) EMITMBC(0x1e83) | |
1060 EMITMBC(0x1e85) EMITMBC(0x1e87) EMITMBC(0x1e98) | |
1061 return OK; | |
1062 | |
1063 case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d) | |
1064 EMIT2('x'); EMITMBC(0x1e8b) EMITMBC(0x1e8d) | |
4444 | 1065 return OK; |
1066 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1067 case 'y': case 0375: case 0377: |
5351 | 1068 CASEMBC(0x177) CASEMBC(0x1e8f) CASEMBC(0x1e99) |
1069 CASEMBC(0x1ef3) CASEMBC(0x1ef7) CASEMBC(0x1ef9) | |
1070 EMIT2('y'); EMIT2(0375); EMIT2(0377); EMITMBC(0x177) | |
1071 EMITMBC(0x1e8f) EMITMBC(0x1e99) EMITMBC(0x1ef3) | |
1072 EMITMBC(0x1ef7) EMITMBC(0x1ef9) | |
4444 | 1073 return OK; |
1074 | |
5351 | 1075 case 'z': CASEMBC(0x17a) CASEMBC(0x17c) CASEMBC(0x17e) |
1076 CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95) | |
1077 EMIT2('z'); EMITMBC(0x17a) EMITMBC(0x17c) EMITMBC(0x17e) | |
1078 EMITMBC(0x1b6) EMITMBC(0x1e91) EMITMBC(0x1e95) | |
1079 return OK; | |
1080 | |
1081 /* default: character itself */ | |
4444 | 1082 } |
1083 } | |
1084 | |
5351 | 1085 EMIT2(c); |
4444 | 1086 return OK; |
1087 #undef EMIT2 | |
5351 | 1088 #undef EMITMBC |
4444 | 1089 } |
1090 | |
1091 /* | |
1092 * Code to parse regular expression. | |
1093 * | |
1094 * We try to reuse parsing functions in regexp.c to | |
1095 * minimize surprise and keep the syntax consistent. | |
1096 */ | |
1097 | |
1098 /* | |
1099 * Parse the lowest level. | |
1100 * | |
1101 * An atom can be one of a long list of items. Many atoms match one character | |
1102 * in the text. It is often an ordinary character or a character class. | |
1103 * Braces can be used to make a pattern into an atom. The "\z(\)" construct | |
1104 * is only for syntax highlighting. | |
1105 * | |
1106 * atom ::= ordinary-atom | |
1107 * or \( pattern \) | |
1108 * or \%( pattern \) | |
1109 * or \z( pattern \) | |
1110 */ | |
1111 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1112 nfa_regatom(void) |
4444 | 1113 { |
1114 int c; | |
1115 int charclass; | |
1116 int equiclass; | |
1117 int collclass; | |
1118 int got_coll_char; | |
1119 char_u *p; | |
1120 char_u *endp; | |
1121 #ifdef FEAT_MBYTE | |
1122 char_u *old_regparse = regparse; | |
1123 #endif | |
1124 int extra = 0; | |
1125 int emit_range; | |
1126 int negated; | |
1127 int result; | |
1128 int startc = -1; | |
1129 int endc = -1; | |
1130 int oldstartc = -1; | |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1131 int save_prev_at_start = prev_at_start; |
4444 | 1132 |
1133 c = getchr(); | |
1134 switch (c) | |
1135 { | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1136 case NUL: |
5511 | 1137 EMSG_RET_FAIL(_(e_nul_found)); |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1138 |
4444 | 1139 case Magic('^'): |
1140 EMIT(NFA_BOL); | |
1141 break; | |
1142 | |
1143 case Magic('$'): | |
1144 EMIT(NFA_EOL); | |
1145 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
1146 had_eol = TRUE; | |
1147 #endif | |
1148 break; | |
1149 | |
1150 case Magic('<'): | |
1151 EMIT(NFA_BOW); | |
1152 break; | |
1153 | |
1154 case Magic('>'): | |
1155 EMIT(NFA_EOW); | |
1156 break; | |
1157 | |
1158 case Magic('_'): | |
1159 c = no_Magic(getchr()); | |
5511 | 1160 if (c == NUL) |
1161 EMSG_RET_FAIL(_(e_nul_found)); | |
1162 | |
4444 | 1163 if (c == '^') /* "\_^" is start-of-line */ |
1164 { | |
1165 EMIT(NFA_BOL); | |
1166 break; | |
1167 } | |
1168 if (c == '$') /* "\_$" is end-of-line */ | |
1169 { | |
1170 EMIT(NFA_EOL); | |
1171 #if defined(FEAT_SYN_HL) || defined(PROTO) | |
1172 had_eol = TRUE; | |
1173 #endif | |
1174 break; | |
1175 } | |
1176 | |
5296 | 1177 extra = NFA_ADD_NL; |
4444 | 1178 |
1179 /* "\_[" is collection plus newline */ | |
1180 if (c == '[') | |
4517
9a2183bd8295
updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents:
4515
diff
changeset
|
1181 goto collection; |
4444 | 1182 |
1183 /* "\_x" is character class plus newline */ | |
1184 /*FALLTHROUGH*/ | |
1185 | |
1186 /* | |
1187 * Character classes. | |
1188 */ | |
1189 case Magic('.'): | |
1190 case Magic('i'): | |
1191 case Magic('I'): | |
1192 case Magic('k'): | |
1193 case Magic('K'): | |
1194 case Magic('f'): | |
1195 case Magic('F'): | |
1196 case Magic('p'): | |
1197 case Magic('P'): | |
1198 case Magic('s'): | |
1199 case Magic('S'): | |
1200 case Magic('d'): | |
1201 case Magic('D'): | |
1202 case Magic('x'): | |
1203 case Magic('X'): | |
1204 case Magic('o'): | |
1205 case Magic('O'): | |
1206 case Magic('w'): | |
1207 case Magic('W'): | |
1208 case Magic('h'): | |
1209 case Magic('H'): | |
1210 case Magic('a'): | |
1211 case Magic('A'): | |
1212 case Magic('l'): | |
1213 case Magic('L'): | |
1214 case Magic('u'): | |
1215 case Magic('U'): | |
1216 p = vim_strchr(classchars, no_Magic(c)); | |
1217 if (p == NULL) | |
1218 { | |
5511 | 1219 if (extra == NFA_ADD_NL) |
1220 { | |
1221 EMSGN(_(e_ill_char_class), c); | |
1222 rc_did_emsg = TRUE; | |
1223 return FAIL; | |
1224 } | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1225 EMSGN("INTERNAL: Unknown character class char: %ld", c); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1226 return FAIL; |
4444 | 1227 } |
1228 #ifdef FEAT_MBYTE | |
1229 /* When '.' is followed by a composing char ignore the dot, so that | |
1230 * the composing char is matched here. */ | |
1231 if (enc_utf8 && c == Magic('.') && utf_iscomposing(peekchr())) | |
1232 { | |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1233 old_regparse = regparse; |
4444 | 1234 c = getchr(); |
1235 goto nfa_do_multibyte; | |
1236 } | |
1237 #endif | |
1238 EMIT(nfa_classcodes[p - classchars]); | |
5296 | 1239 if (extra == NFA_ADD_NL) |
4444 | 1240 { |
1241 EMIT(NFA_NEWL); | |
1242 EMIT(NFA_OR); | |
1243 regflags |= RF_HASNL; | |
1244 } | |
1245 break; | |
1246 | |
1247 case Magic('n'): | |
1248 if (reg_string) | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1249 /* In a string "\n" matches a newline character. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1250 EMIT(NL); |
4444 | 1251 else |
1252 { | |
1253 /* In buffer text "\n" matches the end of a line. */ | |
1254 EMIT(NFA_NEWL); | |
1255 regflags |= RF_HASNL; | |
1256 } | |
1257 break; | |
1258 | |
1259 case Magic('('): | |
1260 if (nfa_reg(REG_PAREN) == FAIL) | |
1261 return FAIL; /* cascaded error */ | |
1262 break; | |
1263 | |
1264 case Magic('|'): | |
1265 case Magic('&'): | |
1266 case Magic(')'): | |
4450 | 1267 EMSGN(_(e_misplaced), no_Magic(c)); |
4444 | 1268 return FAIL; |
1269 | |
1270 case Magic('='): | |
1271 case Magic('?'): | |
1272 case Magic('+'): | |
1273 case Magic('@'): | |
1274 case Magic('*'): | |
1275 case Magic('{'): | |
1276 /* these should follow an atom, not form an atom */ | |
4450 | 1277 EMSGN(_(e_misplaced), no_Magic(c)); |
4444 | 1278 return FAIL; |
1279 | |
4714
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1280 case Magic('~'): |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1281 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1282 char_u *lp; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1283 |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1284 /* Previous substitute pattern. |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1285 * Generated as "\%(pattern\)". */ |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1286 if (reg_prev_sub == NULL) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1287 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1288 EMSG(_(e_nopresub)); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1289 return FAIL; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1290 } |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1291 for (lp = reg_prev_sub; *lp != NUL; mb_cptr_adv(lp)) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1292 { |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1293 EMIT(PTR2CHAR(lp)); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1294 if (lp != reg_prev_sub) |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1295 EMIT(NFA_CONCAT); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1296 } |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1297 EMIT(NFA_NOPEN); |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1298 break; |
fc4d7f02ea3a
updated for version 7.3.1104
Bram Moolenaar <bram@vim.org>
parents:
4712
diff
changeset
|
1299 } |
4444 | 1300 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1301 case Magic('1'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1302 case Magic('2'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1303 case Magic('3'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1304 case Magic('4'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1305 case Magic('5'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1306 case Magic('6'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1307 case Magic('7'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1308 case Magic('8'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1309 case Magic('9'): |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1310 EMIT(NFA_BACKREF1 + (no_Magic(c) - '1')); |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1311 nfa_has_backref = TRUE; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
1312 break; |
4444 | 1313 |
1314 case Magic('z'): | |
1315 c = no_Magic(getchr()); | |
1316 switch (c) | |
1317 { | |
1318 case 's': | |
1319 EMIT(NFA_ZSTART); | |
6170 | 1320 if (re_mult_next("\\zs") == FAIL) |
1321 return FAIL; | |
4444 | 1322 break; |
1323 case 'e': | |
1324 EMIT(NFA_ZEND); | |
1325 nfa_has_zend = TRUE; | |
6170 | 1326 if (re_mult_next("\\ze") == FAIL) |
1327 return FAIL; | |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
1328 break; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1329 #ifdef FEAT_SYN_HL |
4444 | 1330 case '1': |
1331 case '2': | |
1332 case '3': | |
1333 case '4': | |
1334 case '5': | |
1335 case '6': | |
1336 case '7': | |
1337 case '8': | |
1338 case '9': | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1339 /* \z1...\z9 */ |
4688
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1340 if (reg_do_extmatch != REX_USE) |
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1341 EMSG_RET_FAIL(_(e_z1_not_allowed)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1342 EMIT(NFA_ZREF1 + (no_Magic(c) - '1')); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1343 /* No need to set nfa_has_backref, the sub-matches don't |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
1344 * change when \z1 .. \z9 matches or not. */ |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1345 re_has_z = REX_USE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1346 break; |
4444 | 1347 case '(': |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1348 /* \z( */ |
4688
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1349 if (reg_do_extmatch != REX_SET) |
371cc0c44097
updated for version 7.3.1091
Bram Moolenaar <bram@vim.org>
parents:
4686
diff
changeset
|
1350 EMSG_RET_FAIL(_(e_z_not_allowed)); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1351 if (nfa_reg(REG_ZPAREN) == FAIL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1352 return FAIL; /* cascaded error */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1353 re_has_z = REX_SET; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1354 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
1355 #endif |
4444 | 1356 default: |
4450 | 1357 EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"), |
4444 | 1358 no_Magic(c)); |
1359 return FAIL; | |
1360 } | |
1361 break; | |
1362 | |
1363 case Magic('%'): | |
1364 c = no_Magic(getchr()); | |
1365 switch (c) | |
1366 { | |
1367 /* () without a back reference */ | |
1368 case '(': | |
1369 if (nfa_reg(REG_NPAREN) == FAIL) | |
1370 return FAIL; | |
1371 EMIT(NFA_NOPEN); | |
1372 break; | |
1373 | |
1374 case 'd': /* %d123 decimal */ | |
1375 case 'o': /* %o123 octal */ | |
1376 case 'x': /* %xab hex 2 */ | |
1377 case 'u': /* %uabcd hex 4 */ | |
1378 case 'U': /* %U1234abcd hex 8 */ | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1379 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1380 int nr; |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1381 |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1382 switch (c) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1383 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1384 case 'd': nr = getdecchrs(); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1385 case 'o': nr = getoctchrs(); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1386 case 'x': nr = gethexchrs(2); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1387 case 'u': nr = gethexchrs(4); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1388 case 'U': nr = gethexchrs(8); break; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1389 default: nr = -1; break; |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1390 } |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1391 |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1392 if (nr < 0) |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1393 EMSG2_RET_FAIL( |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1394 _("E678: Invalid character after %s%%[dxouU]"), |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1395 reg_magic == MAGIC_ALL); |
5360 | 1396 /* A NUL is stored in the text as NL */ |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1397 /* TODO: what if a composing character follows? */ |
5360 | 1398 EMIT(nr == 0 ? 0x0a : nr); |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1399 } |
4444 | 1400 break; |
1401 | |
1402 /* Catch \%^ and \%$ regardless of where they appear in the | |
1403 * pattern -- regardless of whether or not it makes sense. */ | |
1404 case '^': | |
1405 EMIT(NFA_BOF); | |
1406 break; | |
1407 | |
1408 case '$': | |
1409 EMIT(NFA_EOF); | |
1410 break; | |
1411 | |
1412 case '#': | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1413 EMIT(NFA_CURSOR); |
4444 | 1414 break; |
1415 | |
1416 case 'V': | |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
1417 EMIT(NFA_VISUAL); |
4444 | 1418 break; |
1419 | |
5901 | 1420 case 'C': |
1421 EMIT(NFA_ANY_COMPOSING); | |
1422 break; | |
1423 | |
4444 | 1424 case '[': |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1425 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1426 int n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1427 |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1428 /* \%[abc] */ |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1429 for (n = 0; (c = peekchr()) != ']'; ++n) |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1430 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1431 if (c == NUL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1432 EMSG2_RET_FAIL(_(e_missing_sb), |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1433 reg_magic == MAGIC_ALL); |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1434 /* recursive call! */ |
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1435 if (nfa_regatom() == FAIL) |
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1436 return FAIL; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1437 } |
4944
613651492c19
updated for version 7.3.1217
Bram Moolenaar <bram@vim.org>
parents:
4938
diff
changeset
|
1438 getchr(); /* get the ] */ |
4760
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1439 if (n == 0) |
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1440 EMSG2_RET_FAIL(_(e_empty_sb), |
532a9855bd30
updated for version 7.3.1127
Bram Moolenaar <bram@vim.org>
parents:
4758
diff
changeset
|
1441 reg_magic == MAGIC_ALL); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1442 EMIT(NFA_OPT_CHARS); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1443 EMIT(n); |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1444 |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1445 /* Emit as "\%(\%[abc]\)" to be able to handle |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1446 * "\%[abc]*" which would cause the empty string to be |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1447 * matched an unlimited number of times. NFA_NOPEN is |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1448 * added only once at a position, while NFA_SPLIT is |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1449 * added multiple times. This is more efficient than |
6547 | 1450 * not allowing NFA_SPLIT multiple times, it is used |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1451 * a lot. */ |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1452 EMIT(NFA_NOPEN); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1453 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1454 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1455 |
4444 | 1456 default: |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1457 { |
4655
779ca415f8e1
updated for version 7.3.1075
Bram Moolenaar <bram@vim.org>
parents:
4651
diff
changeset
|
1458 int n = 0; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1459 int cmp = c; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1460 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1461 if (c == '<' || c == '>') |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1462 c = getchr(); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1463 while (VIM_ISDIGIT(c)) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1464 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1465 n = n * 10 + (c - '0'); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1466 c = getchr(); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1467 } |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1468 if (c == 'l' || c == 'c' || c == 'v') |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1469 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1470 if (c == 'l') |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1471 { |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1472 /* \%{n}l \%{n}<l \%{n}>l */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1473 EMIT(cmp == '<' ? NFA_LNUM_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1474 cmp == '>' ? NFA_LNUM_GT : NFA_LNUM); |
8021
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1475 if (save_prev_at_start) |
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1476 at_start = TRUE; |
b6b4f354df23
commit https://github.com/vim/vim/commit/7c29f387819b5817b003d2ba73e2b5cf3cb3d0dd
Christian Brabandt <cb@256bit.org>
parents:
7833
diff
changeset
|
1477 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1478 else if (c == 'c') |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1479 /* \%{n}c \%{n}<c \%{n}>c */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1480 EMIT(cmp == '<' ? NFA_COL_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1481 cmp == '>' ? NFA_COL_GT : NFA_COL); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1482 else |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1483 /* \%{n}v \%{n}<v \%{n}>v */ |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1484 EMIT(cmp == '<' ? NFA_VCOL_LT : |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1485 cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1486 EMIT(n); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1487 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1488 } |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1489 else if (c == '\'' && n == 0) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1490 { |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1491 /* \%'m \%<'m \%>'m */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1492 EMIT(cmp == '<' ? NFA_MARK_LT : |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1493 cmp == '>' ? NFA_MARK_GT : NFA_MARK); |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
1494 EMIT(getchr()); |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1495 break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
1496 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
1497 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1498 EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"), |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
1499 no_Magic(c)); |
4444 | 1500 return FAIL; |
1501 } | |
1502 break; | |
1503 | |
1504 case Magic('['): | |
4517
9a2183bd8295
updated for version 7.3.1006
Bram Moolenaar <bram@vim.org>
parents:
4515
diff
changeset
|
1505 collection: |
4444 | 1506 /* |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1507 * [abc] uses NFA_START_COLL - NFA_END_COLL |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1508 * [^abc] uses NFA_START_NEG_COLL - NFA_END_NEG_COLL |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1509 * Each character is produced as a regular state, using |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1510 * NFA_CONCAT to bind them together. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1511 * Besides normal characters there can be: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1512 * - character classes NFA_CLASS_* |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1513 * - ranges, two characters followed by NFA_RANGE. |
4444 | 1514 */ |
1515 | |
1516 p = regparse; | |
1517 endp = skip_anyof(p); | |
1518 if (*endp == ']') | |
1519 { | |
1520 /* | |
1521 * Try to reverse engineer character classes. For example, | |
5296 | 1522 * recognize that [0-9] stands for \d and [A-Za-z_] for \h, |
4444 | 1523 * and perform the necessary substitutions in the NFA. |
1524 */ | |
1525 result = nfa_recognize_char_class(regparse, endp, | |
5296 | 1526 extra == NFA_ADD_NL); |
4444 | 1527 if (result != FAIL) |
1528 { | |
5296 | 1529 if (result >= NFA_FIRST_NL && result <= NFA_LAST_NL) |
4444 | 1530 { |
5296 | 1531 EMIT(result - NFA_ADD_NL); |
4444 | 1532 EMIT(NFA_NEWL); |
1533 EMIT(NFA_OR); | |
1534 } | |
5296 | 1535 else |
1536 EMIT(result); | |
4444 | 1537 regparse = endp; |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1538 mb_ptr_adv(regparse); |
4444 | 1539 return OK; |
1540 } | |
1541 /* | |
1542 * Failed to recognize a character class. Use the simple | |
1543 * version that turns [abc] into 'a' OR 'b' OR 'c' | |
1544 */ | |
1545 startc = endc = oldstartc = -1; | |
1546 negated = FALSE; | |
1547 if (*regparse == '^') /* negated range */ | |
1548 { | |
1549 negated = TRUE; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1550 mb_ptr_adv(regparse); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1551 EMIT(NFA_START_NEG_COLL); |
4444 | 1552 } |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1553 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1554 EMIT(NFA_START_COLL); |
4444 | 1555 if (*regparse == '-') |
1556 { | |
1557 startc = '-'; | |
1558 EMIT(startc); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1559 EMIT(NFA_CONCAT); |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1560 mb_ptr_adv(regparse); |
4444 | 1561 } |
1562 /* Emit the OR branches for each character in the [] */ | |
1563 emit_range = FALSE; | |
1564 while (regparse < endp) | |
1565 { | |
1566 oldstartc = startc; | |
1567 startc = -1; | |
1568 got_coll_char = FALSE; | |
1569 if (*regparse == '[') | |
1570 { | |
1571 /* Check for [: :], [= =], [. .] */ | |
1572 equiclass = collclass = 0; | |
1573 charclass = get_char_class(®parse); | |
1574 if (charclass == CLASS_NONE) | |
1575 { | |
1576 equiclass = get_equi_class(®parse); | |
1577 if (equiclass == 0) | |
1578 collclass = get_coll_element(®parse); | |
1579 } | |
1580 | |
1581 /* Character class like [:alpha:] */ | |
1582 if (charclass != CLASS_NONE) | |
1583 { | |
1584 switch (charclass) | |
1585 { | |
1586 case CLASS_ALNUM: | |
1587 EMIT(NFA_CLASS_ALNUM); | |
1588 break; | |
1589 case CLASS_ALPHA: | |
1590 EMIT(NFA_CLASS_ALPHA); | |
1591 break; | |
1592 case CLASS_BLANK: | |
1593 EMIT(NFA_CLASS_BLANK); | |
1594 break; | |
1595 case CLASS_CNTRL: | |
1596 EMIT(NFA_CLASS_CNTRL); | |
1597 break; | |
1598 case CLASS_DIGIT: | |
1599 EMIT(NFA_CLASS_DIGIT); | |
1600 break; | |
1601 case CLASS_GRAPH: | |
1602 EMIT(NFA_CLASS_GRAPH); | |
1603 break; | |
1604 case CLASS_LOWER: | |
1605 EMIT(NFA_CLASS_LOWER); | |
1606 break; | |
1607 case CLASS_PRINT: | |
1608 EMIT(NFA_CLASS_PRINT); | |
1609 break; | |
1610 case CLASS_PUNCT: | |
1611 EMIT(NFA_CLASS_PUNCT); | |
1612 break; | |
1613 case CLASS_SPACE: | |
1614 EMIT(NFA_CLASS_SPACE); | |
1615 break; | |
1616 case CLASS_UPPER: | |
1617 EMIT(NFA_CLASS_UPPER); | |
1618 break; | |
1619 case CLASS_XDIGIT: | |
1620 EMIT(NFA_CLASS_XDIGIT); | |
1621 break; | |
1622 case CLASS_TAB: | |
1623 EMIT(NFA_CLASS_TAB); | |
1624 break; | |
1625 case CLASS_RETURN: | |
1626 EMIT(NFA_CLASS_RETURN); | |
1627 break; | |
1628 case CLASS_BACKSPACE: | |
1629 EMIT(NFA_CLASS_BACKSPACE); | |
1630 break; | |
1631 case CLASS_ESCAPE: | |
1632 EMIT(NFA_CLASS_ESCAPE); | |
1633 break; | |
1634 } | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1635 EMIT(NFA_CONCAT); |
4444 | 1636 continue; |
1637 } | |
1638 /* Try equivalence class [=a=] and the like */ | |
1639 if (equiclass != 0) | |
1640 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1641 result = nfa_emit_equi_class(equiclass); |
4444 | 1642 if (result == FAIL) |
1643 { | |
1644 /* should never happen */ | |
1645 EMSG_RET_FAIL(_("E868: Error building NFA with equivalence class!")); | |
1646 } | |
1647 continue; | |
1648 } | |
1649 /* Try collating class like [. .] */ | |
1650 if (collclass != 0) | |
1651 { | |
1652 startc = collclass; /* allow [.a.]-x as a range */ | |
1653 /* Will emit the proper atom at the end of the | |
1654 * while loop. */ | |
1655 } | |
1656 } | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1657 /* Try a range like 'a-x' or '\t-z'. Also allows '-' as a |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1658 * start character. */ |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1659 if (*regparse == '-' && oldstartc != -1) |
4444 | 1660 { |
1661 emit_range = TRUE; | |
1662 startc = oldstartc; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1663 mb_ptr_adv(regparse); |
4444 | 1664 continue; /* reading the end of the range */ |
1665 } | |
1666 | |
1667 /* Now handle simple and escaped characters. | |
1668 * Only "\]", "\^", "\]" and "\\" are special in Vi. Vim | |
1669 * accepts "\t", "\e", etc., but only when the 'l' flag in | |
1670 * 'cpoptions' is not included. | |
1671 * Posix doesn't recognize backslash at all. | |
1672 */ | |
1673 if (*regparse == '\\' | |
4744
a62695305e03
updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents:
4742
diff
changeset
|
1674 && !reg_cpo_bsl |
4444 | 1675 && regparse + 1 <= endp |
1676 && (vim_strchr(REGEXP_INRANGE, regparse[1]) != NULL | |
4744
a62695305e03
updated for version 7.3.1119
Bram Moolenaar <bram@vim.org>
parents:
4742
diff
changeset
|
1677 || (!reg_cpo_lit |
4444 | 1678 && vim_strchr(REGEXP_ABBR, regparse[1]) |
1679 != NULL) | |
1680 ) | |
1681 ) | |
1682 { | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1683 mb_ptr_adv(regparse); |
4444 | 1684 |
4507
9dbbddb2ed10
updated for version 7.3.1001
Bram Moolenaar <bram@vim.org>
parents:
4503
diff
changeset
|
1685 if (*regparse == 'n') |
4444 | 1686 startc = reg_string ? NL : NFA_NEWL; |
1687 else | |
1688 if (*regparse == 'd' | |
1689 || *regparse == 'o' | |
1690 || *regparse == 'x' | |
1691 || *regparse == 'u' | |
1692 || *regparse == 'U' | |
1693 ) | |
1694 { | |
1695 /* TODO(RE) This needs more testing */ | |
1696 startc = coll_get_char(); | |
1697 got_coll_char = TRUE; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1698 mb_ptr_back(old_regparse, regparse); |
4444 | 1699 } |
1700 else | |
1701 { | |
1702 /* \r,\t,\e,\b */ | |
1703 startc = backslash_trans(*regparse); | |
1704 } | |
1705 } | |
1706 | |
1707 /* Normal printable char */ | |
1708 if (startc == -1) | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1709 startc = PTR2CHAR(regparse); |
4444 | 1710 |
1711 /* Previous char was '-', so this char is end of range. */ | |
1712 if (emit_range) | |
1713 { | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1714 endc = startc; |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1715 startc = oldstartc; |
4444 | 1716 if (startc > endc) |
1717 EMSG_RET_FAIL(_(e_invrange)); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1718 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1719 if (endc > startc + 2) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1720 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1721 /* Emit a range instead of the sequence of |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1722 * individual characters. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1723 if (startc == 0) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1724 /* \x00 is translated to \x0a, start at \x01. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1725 EMIT(1); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1726 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1727 --post_ptr; /* remove NFA_CONCAT */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1728 EMIT(endc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1729 EMIT(NFA_RANGE); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1730 EMIT(NFA_CONCAT); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1731 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1732 else |
4444 | 1733 #ifdef FEAT_MBYTE |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1734 if (has_mbyte && ((*mb_char2len)(startc) > 1 |
4444 | 1735 || (*mb_char2len)(endc) > 1)) |
1736 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1737 /* Emit the characters in the range. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1738 * "startc" was already emitted, so skip it. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1739 * */ |
4444 | 1740 for (c = startc + 1; c <= endc; c++) |
1741 { | |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1742 EMIT(c); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1743 EMIT(NFA_CONCAT); |
4444 | 1744 } |
1745 } | |
1746 else | |
1747 #endif | |
1748 { | |
1749 #ifdef EBCDIC | |
1750 int alpha_only = FALSE; | |
1751 | |
1752 /* for alphabetical range skip the gaps | |
1753 * 'i'-'j', 'r'-'s', 'I'-'J' and 'R'-'S'. */ | |
1754 if (isalpha(startc) && isalpha(endc)) | |
1755 alpha_only = TRUE; | |
1756 #endif | |
1757 /* Emit the range. "startc" was already emitted, so | |
1758 * skip it. */ | |
1759 for (c = startc + 1; c <= endc; c++) | |
1760 #ifdef EBCDIC | |
1761 if (!alpha_only || isalpha(startc)) | |
1762 #endif | |
1763 { | |
1764 EMIT(c); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1765 EMIT(NFA_CONCAT); |
4444 | 1766 } |
1767 } | |
4677
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1768 emit_range = FALSE; |
c1622ff9ed8d
updated for version 7.3.1086
Bram Moolenaar <bram@vim.org>
parents:
4675
diff
changeset
|
1769 startc = -1; |
4444 | 1770 } |
1771 else | |
1772 { | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1773 /* This char (startc) is not part of a range. Just |
4444 | 1774 * emit it. |
1775 * Normally, simply emit startc. But if we get char | |
1776 * code=0 from a collating char, then replace it with | |
1777 * 0x0a. | |
1778 * This is needed to completely mimic the behaviour of | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1779 * the backtracking engine. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1780 if (startc == NFA_NEWL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1781 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1782 /* Line break can't be matched as part of the |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1783 * collection, add an OR below. But not for negated |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1784 * range. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1785 if (!negated) |
5296 | 1786 extra = NFA_ADD_NL; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1787 } |
4444 | 1788 else |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1789 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1790 if (got_coll_char == TRUE && startc == 0) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1791 EMIT(0x0a); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1792 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1793 EMIT(startc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1794 EMIT(NFA_CONCAT); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1795 } |
4444 | 1796 } |
1797 | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1798 mb_ptr_adv(regparse); |
4444 | 1799 } /* while (p < endp) */ |
1800 | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1801 mb_ptr_back(old_regparse, regparse); |
4444 | 1802 if (*regparse == '-') /* if last, '-' is just a char */ |
1803 { | |
1804 EMIT('-'); | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1805 EMIT(NFA_CONCAT); |
4444 | 1806 } |
1807 | |
1808 /* skip the trailing ] */ | |
1809 regparse = endp; | |
4573
37e444aeb33b
updated for version 7.3.1034
Bram Moolenaar <bram@vim.org>
parents:
4571
diff
changeset
|
1810 mb_ptr_adv(regparse); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1811 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1812 /* Mark end of the collection. */ |
4444 | 1813 if (negated == TRUE) |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1814 EMIT(NFA_END_NEG_COLL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1815 else |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
1816 EMIT(NFA_END_COLL); |
4615
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1817 |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1818 /* \_[] also matches \n but it's not negated */ |
5296 | 1819 if (extra == NFA_ADD_NL) |
4615
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1820 { |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1821 EMIT(reg_string ? NL : NFA_NEWL); |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1822 EMIT(NFA_OR); |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1823 } |
5679b8ddd8cc
updated for version 7.3.1055
Bram Moolenaar <bram@vim.org>
parents:
4583
diff
changeset
|
1824 |
4444 | 1825 return OK; |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1826 } /* if exists closing ] */ |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1827 |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1828 if (reg_strict) |
4444 | 1829 EMSG_RET_FAIL(_(e_missingbracket)); |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1830 /* FALLTHROUGH */ |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1831 |
4444 | 1832 default: |
1833 { | |
1834 #ifdef FEAT_MBYTE | |
1835 int plen; | |
1836 | |
1837 nfa_do_multibyte: | |
4543
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1838 /* plen is length of current char with composing chars */ |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1839 if (enc_utf8 && ((*mb_char2len)(c) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1840 != (plen = (*mb_ptr2len)(old_regparse)) |
08ac46980953
updated for version 7.3.1019
Bram Moolenaar <bram@vim.org>
parents:
4541
diff
changeset
|
1841 || utf_iscomposing(c))) |
4444 | 1842 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1843 int i = 0; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
1844 |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1845 /* A base character plus composing characters, or just one |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
1846 * or more composing characters. |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1847 * This requires creating a separate atom as if enclosing |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1848 * the characters in (), where NFA_COMPOSING is the ( and |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1849 * NFA_END_COMPOSING is the ). Note that right now we are |
4444 | 1850 * building the postfix form, not the NFA itself; |
1851 * a composing char could be: a, b, c, NFA_COMPOSING | |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1852 * where 'b' and 'c' are chars with codes > 256. */ |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1853 for (;;) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1854 { |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1855 EMIT(c); |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1856 if (i > 0) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1857 EMIT(NFA_CONCAT); |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
1858 if ((i += utf_char2len(c)) >= plen) |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1859 break; |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1860 c = utf_ptr2char(old_regparse + i); |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1861 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
1862 EMIT(NFA_COMPOSING); |
4444 | 1863 regparse = old_regparse + plen; |
1864 } | |
1865 else | |
1866 #endif | |
1867 { | |
1868 c = no_Magic(c); | |
1869 EMIT(c); | |
1870 } | |
1871 return OK; | |
1872 } | |
1873 } | |
1874 | |
1875 return OK; | |
1876 } | |
1877 | |
1878 /* | |
1879 * Parse something followed by possible [*+=]. | |
1880 * | |
1881 * A piece is an atom, possibly followed by a multi, an indication of how many | |
1882 * times the atom can be matched. Example: "a*" matches any sequence of "a" | |
1883 * characters: "", "a", "aa", etc. | |
1884 * | |
1885 * piece ::= atom | |
1886 * or atom multi | |
1887 */ | |
1888 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
1889 nfa_regpiece(void) |
4444 | 1890 { |
1891 int i; | |
1892 int op; | |
1893 int ret; | |
1894 long minval, maxval; | |
1895 int greedy = TRUE; /* Braces are prefixed with '-' ? */ | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1896 parse_state_T old_state; |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1897 parse_state_T new_state; |
4444 | 1898 int c2; |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
1899 int old_post_pos; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
1900 int my_post_start; |
4444 | 1901 int quest; |
1902 | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1903 /* Save the current parse state, so that we can use it if <atom>{m,n} is |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1904 * next. */ |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1905 save_parse_state(&old_state); |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1906 |
4444 | 1907 /* store current pos in the postfix form, for \{m,n} involving 0s */ |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
1908 my_post_start = (int)(post_ptr - post_start); |
4444 | 1909 |
1910 ret = nfa_regatom(); | |
1911 if (ret == FAIL) | |
1912 return FAIL; /* cascaded error */ | |
1913 | |
1914 op = peekchr(); | |
1915 if (re_multi_type(op) == NOT_MULTI) | |
1916 return OK; | |
1917 | |
1918 skipchr(); | |
1919 switch (op) | |
1920 { | |
1921 case Magic('*'): | |
1922 EMIT(NFA_STAR); | |
1923 break; | |
1924 | |
1925 case Magic('+'): | |
1926 /* | |
1927 * Trick: Normally, (a*)\+ would match the whole input "aaa". The | |
1928 * first and only submatch would be "aaa". But the backtracking | |
1929 * engine interprets the plus as "try matching one more time", and | |
1930 * a* matches a second time at the end of the input, the empty | |
1931 * string. | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
1932 * The submatch will be the empty string. |
4444 | 1933 * |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
1934 * In order to be consistent with the old engine, we replace |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
1935 * <atom>+ with <atom><atom>* |
4444 | 1936 */ |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
1937 restore_parse_state(&old_state); |
4444 | 1938 curchr = -1; |
1939 if (nfa_regatom() == FAIL) | |
1940 return FAIL; | |
1941 EMIT(NFA_STAR); | |
1942 EMIT(NFA_CONCAT); | |
1943 skipchr(); /* skip the \+ */ | |
1944 break; | |
1945 | |
1946 case Magic('@'): | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1947 c2 = getdecchrs(); |
4444 | 1948 op = no_Magic(getchr()); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1949 i = 0; |
4444 | 1950 switch(op) |
1951 { | |
1952 case '=': | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1953 /* \@= */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1954 i = NFA_PREV_ATOM_NO_WIDTH; |
4444 | 1955 break; |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
1956 case '!': |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1957 /* \@! */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1958 i = NFA_PREV_ATOM_NO_WIDTH_NEG; |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
1959 break; |
4444 | 1960 case '<': |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1961 op = no_Magic(getchr()); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1962 if (op == '=') |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1963 /* \@<= */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1964 i = NFA_PREV_ATOM_JUST_BEFORE; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1965 else if (op == '!') |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1966 /* \@<! */ |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1967 i = NFA_PREV_ATOM_JUST_BEFORE_NEG; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1968 break; |
4444 | 1969 case '>': |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
1970 /* \@> */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
1971 i = NFA_PREV_ATOM_LIKE_PATTERN; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
1972 break; |
4444 | 1973 } |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1974 if (i == 0) |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1975 { |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1976 EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1977 return FAIL; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1978 } |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1979 EMIT(i); |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1980 if (i == NFA_PREV_ATOM_JUST_BEFORE |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1981 || i == NFA_PREV_ATOM_JUST_BEFORE_NEG) |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
1982 EMIT(c2); |
4444 | 1983 break; |
1984 | |
1985 case Magic('?'): | |
1986 case Magic('='): | |
1987 EMIT(NFA_QUEST); | |
1988 break; | |
1989 | |
1990 case Magic('{'): | |
1991 /* a{2,5} will expand to 'aaa?a?a?' | |
1992 * a{-1,3} will expand to 'aa??a??', where ?? is the nongreedy | |
1993 * version of '?' | |
1994 * \v(ab){2,3} will expand to '(ab)(ab)(ab)?', where all the | |
1995 * parenthesis have the same id | |
1996 */ | |
1997 | |
1998 greedy = TRUE; | |
1999 c2 = peekchr(); | |
2000 if (c2 == '-' || c2 == Magic('-')) | |
2001 { | |
2002 skipchr(); | |
2003 greedy = FALSE; | |
2004 } | |
2005 if (!read_limits(&minval, &maxval)) | |
2006 EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits")); | |
4762
47906f888725
updated for version 7.3.1128
Bram Moolenaar <bram@vim.org>
parents:
4760
diff
changeset
|
2007 |
4444 | 2008 /* <atom>{0,inf}, <atom>{0,} and <atom>{} are equivalent to |
2009 * <atom>* */ | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2010 if (minval == 0 && maxval == MAX_LIMIT) |
4444 | 2011 { |
6533 | 2012 if (greedy) /* { { (match the braces) */ |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2013 /* \{}, \{0,} */ |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2014 EMIT(NFA_STAR); |
6533 | 2015 else /* { { (match the braces) */ |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2016 /* \{-}, \{-0,} */ |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2017 EMIT(NFA_STAR_NONGREEDY); |
4444 | 2018 break; |
2019 } | |
2020 | |
2021 /* Special case: x{0} or x{-0} */ | |
2022 if (maxval == 0) | |
2023 { | |
2024 /* Ignore result of previous call to nfa_regatom() */ | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2025 post_ptr = post_start + my_post_start; |
5370 | 2026 /* NFA_EMPTY is 0-length and works everywhere */ |
2027 EMIT(NFA_EMPTY); | |
4444 | 2028 return OK; |
2029 } | |
2030 | |
6533 | 2031 /* The engine is very inefficient (uses too many states) when the |
6594 | 2032 * maximum is much larger than the minimum and when the maximum is |
2033 * large. Bail out if we can use the other engine. */ | |
2034 if ((nfa_re_flags & RE_AUTO) | |
2035 && (maxval > minval + 200 || maxval > 500)) | |
6533 | 2036 return FAIL; |
2037 | |
4444 | 2038 /* Ignore previous call to nfa_regatom() */ |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2039 post_ptr = post_start + my_post_start; |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2040 /* Save parse state after the repeated atom and the \{} */ |
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2041 save_parse_state(&new_state); |
4444 | 2042 |
2043 quest = (greedy == TRUE? NFA_QUEST : NFA_QUEST_NONGREEDY); | |
2044 for (i = 0; i < maxval; i++) | |
2045 { | |
2046 /* Goto beginning of the repeated atom */ | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2047 restore_parse_state(&old_state); |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2048 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2049 if (nfa_regatom() == FAIL) |
2050 return FAIL; | |
2051 /* after "minval" times, atoms are optional */ | |
2052 if (i + 1 > minval) | |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2053 { |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2054 if (maxval == MAX_LIMIT) |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2055 { |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2056 if (greedy) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2057 EMIT(NFA_STAR); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2058 else |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2059 EMIT(NFA_STAR_NONGREEDY); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2060 } |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2061 else |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2062 EMIT(quest); |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2063 } |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2064 if (old_post_pos != my_post_start) |
4444 | 2065 EMIT(NFA_CONCAT); |
4673
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2066 if (i + 1 > minval && maxval == MAX_LIMIT) |
05d57d7c2d55
updated for version 7.3.1084
Bram Moolenaar <bram@vim.org>
parents:
4671
diff
changeset
|
2067 break; |
4444 | 2068 } |
2069 | |
2070 /* Go to just after the repeated atom and the \{} */ | |
4679
4d92b873acef
updated for version 7.3.1087
Bram Moolenaar <bram@vim.org>
parents:
4677
diff
changeset
|
2071 restore_parse_state(&new_state); |
4444 | 2072 curchr = -1; |
2073 | |
2074 break; | |
2075 | |
2076 | |
2077 default: | |
2078 break; | |
2079 } /* end switch */ | |
2080 | |
2081 if (re_multi_type(peekchr()) != NOT_MULTI) | |
2082 /* Can't have a multi follow a multi. */ | |
2083 EMSG_RET_FAIL(_("E871: (NFA regexp) Can't have a multi follow a multi !")); | |
2084 | |
2085 return OK; | |
2086 } | |
2087 | |
2088 /* | |
2089 * Parse one or more pieces, concatenated. It matches a match for the | |
2090 * first piece, followed by a match for the second piece, etc. Example: | |
2091 * "f[0-9]b", first matches "f", then a digit and then "b". | |
2092 * | |
2093 * concat ::= piece | |
2094 * or piece piece | |
2095 * or piece piece piece | |
2096 * etc. | |
2097 */ | |
2098 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2099 nfa_regconcat(void) |
4444 | 2100 { |
2101 int cont = TRUE; | |
2102 int first = TRUE; | |
2103 | |
2104 while (cont) | |
2105 { | |
2106 switch (peekchr()) | |
2107 { | |
2108 case NUL: | |
2109 case Magic('|'): | |
2110 case Magic('&'): | |
2111 case Magic(')'): | |
2112 cont = FALSE; | |
2113 break; | |
2114 | |
2115 case Magic('Z'): | |
2116 #ifdef FEAT_MBYTE | |
2117 regflags |= RF_ICOMBINE; | |
2118 #endif | |
2119 skipchr_keepstart(); | |
2120 break; | |
2121 case Magic('c'): | |
2122 regflags |= RF_ICASE; | |
2123 skipchr_keepstart(); | |
2124 break; | |
2125 case Magic('C'): | |
2126 regflags |= RF_NOICASE; | |
2127 skipchr_keepstart(); | |
2128 break; | |
2129 case Magic('v'): | |
2130 reg_magic = MAGIC_ALL; | |
2131 skipchr_keepstart(); | |
2132 curchr = -1; | |
2133 break; | |
2134 case Magic('m'): | |
2135 reg_magic = MAGIC_ON; | |
2136 skipchr_keepstart(); | |
2137 curchr = -1; | |
2138 break; | |
2139 case Magic('M'): | |
2140 reg_magic = MAGIC_OFF; | |
2141 skipchr_keepstart(); | |
2142 curchr = -1; | |
2143 break; | |
2144 case Magic('V'): | |
2145 reg_magic = MAGIC_NONE; | |
2146 skipchr_keepstart(); | |
2147 curchr = -1; | |
2148 break; | |
2149 | |
2150 default: | |
2151 if (nfa_regpiece() == FAIL) | |
2152 return FAIL; | |
2153 if (first == FALSE) | |
2154 EMIT(NFA_CONCAT); | |
2155 else | |
2156 first = FALSE; | |
2157 break; | |
2158 } | |
2159 } | |
2160 | |
2161 return OK; | |
2162 } | |
2163 | |
2164 /* | |
2165 * Parse a branch, one or more concats, separated by "\&". It matches the | |
2166 * last concat, but only if all the preceding concats also match at the same | |
2167 * position. Examples: | |
2168 * "foobeep\&..." matches "foo" in "foobeep". | |
2169 * ".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob" | |
2170 * | |
2171 * branch ::= concat | |
2172 * or concat \& concat | |
2173 * or concat \& concat \& concat | |
2174 * etc. | |
2175 */ | |
2176 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2177 nfa_regbranch(void) |
4444 | 2178 { |
2179 int ch; | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2180 int old_post_pos; |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2181 |
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2182 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2183 |
2184 /* First branch, possibly the only one */ | |
2185 if (nfa_regconcat() == FAIL) | |
2186 return FAIL; | |
2187 | |
2188 ch = peekchr(); | |
2189 /* Try next concats */ | |
2190 while (ch == Magic('&')) | |
2191 { | |
2192 skipchr(); | |
2193 EMIT(NFA_NOPEN); | |
2194 EMIT(NFA_PREV_ATOM_NO_WIDTH); | |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2195 old_post_pos = (int)(post_ptr - post_start); |
4444 | 2196 if (nfa_regconcat() == FAIL) |
2197 return FAIL; | |
5370 | 2198 /* if concat is empty do emit a node */ |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2199 if (old_post_pos == (int)(post_ptr - post_start)) |
5370 | 2200 EMIT(NFA_EMPTY); |
4444 | 2201 EMIT(NFA_CONCAT); |
2202 ch = peekchr(); | |
2203 } | |
2204 | |
5370 | 2205 /* if a branch is empty, emit one node for it */ |
4651
f10f63aaec5c
updated for version 7.3.1073
Bram Moolenaar <bram@vim.org>
parents:
4649
diff
changeset
|
2206 if (old_post_pos == (int)(post_ptr - post_start)) |
5370 | 2207 EMIT(NFA_EMPTY); |
4444 | 2208 |
2209 return OK; | |
2210 } | |
2211 | |
2212 /* | |
2213 * Parse a pattern, one or more branches, separated by "\|". It matches | |
2214 * anything that matches one of the branches. Example: "foo\|beep" matches | |
2215 * "foo" and matches "beep". If more than one branch matches, the first one | |
2216 * is used. | |
2217 * | |
2218 * pattern ::= branch | |
2219 * or branch \| branch | |
2220 * or branch \| branch \| branch | |
2221 * etc. | |
2222 */ | |
2223 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2224 nfa_reg( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2225 int paren) /* REG_NOPAREN, REG_PAREN, REG_NPAREN or REG_ZPAREN */ |
4444 | 2226 { |
2227 int parno = 0; | |
2228 | |
2229 if (paren == REG_PAREN) | |
2230 { | |
2231 if (regnpar >= NSUBEXP) /* Too many `(' */ | |
2232 EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('")); | |
2233 parno = regnpar++; | |
2234 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2235 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2236 else if (paren == REG_ZPAREN) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2237 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2238 /* Make a ZOPEN node. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2239 if (regnzpar >= NSUBEXP) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2240 EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z(")); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2241 parno = regnzpar++; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2242 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2243 #endif |
4444 | 2244 |
2245 if (nfa_regbranch() == FAIL) | |
2246 return FAIL; /* cascaded error */ | |
2247 | |
2248 while (peekchr() == Magic('|')) | |
2249 { | |
2250 skipchr(); | |
2251 if (nfa_regbranch() == FAIL) | |
2252 return FAIL; /* cascaded error */ | |
2253 EMIT(NFA_OR); | |
2254 } | |
2255 | |
2256 /* Check for proper termination. */ | |
2257 if (paren != REG_NOPAREN && getchr() != Magic(')')) | |
2258 { | |
2259 if (paren == REG_NPAREN) | |
2260 EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL); | |
2261 else | |
2262 EMSG2_RET_FAIL(_(e_unmatchedp), reg_magic == MAGIC_ALL); | |
2263 } | |
2264 else if (paren == REG_NOPAREN && peekchr() != NUL) | |
2265 { | |
2266 if (peekchr() == Magic(')')) | |
2267 EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL); | |
2268 else | |
2269 EMSG_RET_FAIL(_("E873: (NFA regexp) proper termination error")); | |
2270 } | |
2271 /* | |
2272 * Here we set the flag allowing back references to this set of | |
2273 * parentheses. | |
2274 */ | |
2275 if (paren == REG_PAREN) | |
2276 { | |
2277 had_endbrace[parno] = TRUE; /* have seen the close paren */ | |
2278 EMIT(NFA_MOPEN + parno); | |
2279 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2280 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2281 else if (paren == REG_ZPAREN) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2282 EMIT(NFA_ZOPEN + parno); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2283 #endif |
4444 | 2284 |
2285 return OK; | |
2286 } | |
2287 | |
2288 #ifdef DEBUG | |
2289 static char_u code[50]; | |
2290 | |
2291 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2292 nfa_set_code(int c) |
4444 | 2293 { |
2294 int addnl = FALSE; | |
2295 | |
2296 if (c >= NFA_FIRST_NL && c <= NFA_LAST_NL) | |
2297 { | |
2298 addnl = TRUE; | |
5296 | 2299 c -= NFA_ADD_NL; |
4444 | 2300 } |
2301 | |
2302 STRCPY(code, ""); | |
2303 switch (c) | |
2304 { | |
2305 case NFA_MATCH: STRCPY(code, "NFA_MATCH "); break; | |
2306 case NFA_SPLIT: STRCPY(code, "NFA_SPLIT "); break; | |
2307 case NFA_CONCAT: STRCPY(code, "NFA_CONCAT "); break; | |
2308 case NFA_NEWL: STRCPY(code, "NFA_NEWL "); break; | |
2309 case NFA_ZSTART: STRCPY(code, "NFA_ZSTART"); break; | |
2310 case NFA_ZEND: STRCPY(code, "NFA_ZEND"); break; | |
2311 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2312 case NFA_BACKREF1: STRCPY(code, "NFA_BACKREF1"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2313 case NFA_BACKREF2: STRCPY(code, "NFA_BACKREF2"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2314 case NFA_BACKREF3: STRCPY(code, "NFA_BACKREF3"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2315 case NFA_BACKREF4: STRCPY(code, "NFA_BACKREF4"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2316 case NFA_BACKREF5: STRCPY(code, "NFA_BACKREF5"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2317 case NFA_BACKREF6: STRCPY(code, "NFA_BACKREF6"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2318 case NFA_BACKREF7: STRCPY(code, "NFA_BACKREF7"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2319 case NFA_BACKREF8: STRCPY(code, "NFA_BACKREF8"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2320 case NFA_BACKREF9: STRCPY(code, "NFA_BACKREF9"); break; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2321 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2322 case NFA_ZREF1: STRCPY(code, "NFA_ZREF1"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2323 case NFA_ZREF2: STRCPY(code, "NFA_ZREF2"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2324 case NFA_ZREF3: STRCPY(code, "NFA_ZREF3"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2325 case NFA_ZREF4: STRCPY(code, "NFA_ZREF4"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2326 case NFA_ZREF5: STRCPY(code, "NFA_ZREF5"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2327 case NFA_ZREF6: STRCPY(code, "NFA_ZREF6"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2328 case NFA_ZREF7: STRCPY(code, "NFA_ZREF7"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2329 case NFA_ZREF8: STRCPY(code, "NFA_ZREF8"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2330 case NFA_ZREF9: STRCPY(code, "NFA_ZREF9"); break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2331 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2332 case NFA_SKIP: STRCPY(code, "NFA_SKIP"); break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
2333 |
4444 | 2334 case NFA_PREV_ATOM_NO_WIDTH: |
2335 STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH"); break; | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
2336 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
2337 STRCPY(code, "NFA_PREV_ATOM_NO_WIDTH_NEG"); break; |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2338 case NFA_PREV_ATOM_JUST_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2339 STRCPY(code, "NFA_PREV_ATOM_JUST_BEFORE"); break; |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2340 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2341 STRCPY(code, "NFA_PREV_ATOM_JUST_BEFORE_NEG"); break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2342 case NFA_PREV_ATOM_LIKE_PATTERN: |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2343 STRCPY(code, "NFA_PREV_ATOM_LIKE_PATTERN"); break; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2344 |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
2345 case NFA_NOPEN: STRCPY(code, "NFA_NOPEN"); break; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
2346 case NFA_NCLOSE: STRCPY(code, "NFA_NCLOSE"); break; |
4444 | 2347 case NFA_START_INVISIBLE: STRCPY(code, "NFA_START_INVISIBLE"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2348 case NFA_START_INVISIBLE_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2349 STRCPY(code, "NFA_START_INVISIBLE_FIRST"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2350 case NFA_START_INVISIBLE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2351 STRCPY(code, "NFA_START_INVISIBLE_NEG"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2352 case NFA_START_INVISIBLE_NEG_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2353 STRCPY(code, "NFA_START_INVISIBLE_NEG_FIRST"); break; |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2354 case NFA_START_INVISIBLE_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
2355 STRCPY(code, "NFA_START_INVISIBLE_BEFORE"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2356 case NFA_START_INVISIBLE_BEFORE_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2357 STRCPY(code, "NFA_START_INVISIBLE_BEFORE_FIRST"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2358 case NFA_START_INVISIBLE_BEFORE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2359 STRCPY(code, "NFA_START_INVISIBLE_BEFORE_NEG"); break; |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2360 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
2361 STRCPY(code, "NFA_START_INVISIBLE_BEFORE_NEG_FIRST"); break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2362 case NFA_START_PATTERN: STRCPY(code, "NFA_START_PATTERN"); break; |
4444 | 2363 case NFA_END_INVISIBLE: STRCPY(code, "NFA_END_INVISIBLE"); break; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2364 case NFA_END_INVISIBLE_NEG: STRCPY(code, "NFA_END_INVISIBLE_NEG"); break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
2365 case NFA_END_PATTERN: STRCPY(code, "NFA_END_PATTERN"); break; |
4444 | 2366 |
2367 case NFA_COMPOSING: STRCPY(code, "NFA_COMPOSING"); break; | |
2368 case NFA_END_COMPOSING: STRCPY(code, "NFA_END_COMPOSING"); break; | |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
2369 case NFA_OPT_CHARS: STRCPY(code, "NFA_OPT_CHARS"); break; |
4444 | 2370 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2371 case NFA_MOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2372 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2373 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2374 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2375 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2376 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2377 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2378 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2379 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2380 case NFA_MOPEN9: |
4444 | 2381 STRCPY(code, "NFA_MOPEN(x)"); |
2382 code[10] = c - NFA_MOPEN + '0'; | |
2383 break; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2384 case NFA_MCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2385 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2386 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2387 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2388 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2389 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2390 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2391 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2392 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2393 case NFA_MCLOSE9: |
4444 | 2394 STRCPY(code, "NFA_MCLOSE(x)"); |
2395 code[11] = c - NFA_MCLOSE + '0'; | |
2396 break; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2397 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2398 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2399 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2400 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2401 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2402 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2403 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2404 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2405 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2406 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2407 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2408 STRCPY(code, "NFA_ZOPEN(x)"); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2409 code[10] = c - NFA_ZOPEN + '0'; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2410 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2411 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2412 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2413 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2414 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2415 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2416 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2417 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2418 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2419 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2420 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2421 STRCPY(code, "NFA_ZCLOSE(x)"); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2422 code[11] = c - NFA_ZCLOSE + '0'; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2423 break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
2424 #endif |
4444 | 2425 case NFA_EOL: STRCPY(code, "NFA_EOL "); break; |
2426 case NFA_BOL: STRCPY(code, "NFA_BOL "); break; | |
2427 case NFA_EOW: STRCPY(code, "NFA_EOW "); break; | |
2428 case NFA_BOW: STRCPY(code, "NFA_BOW "); break; | |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
2429 case NFA_EOF: STRCPY(code, "NFA_EOF "); break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
2430 case NFA_BOF: STRCPY(code, "NFA_BOF "); break; |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2431 case NFA_LNUM: STRCPY(code, "NFA_LNUM "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2432 case NFA_LNUM_GT: STRCPY(code, "NFA_LNUM_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2433 case NFA_LNUM_LT: STRCPY(code, "NFA_LNUM_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2434 case NFA_COL: STRCPY(code, "NFA_COL "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2435 case NFA_COL_GT: STRCPY(code, "NFA_COL_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2436 case NFA_COL_LT: STRCPY(code, "NFA_COL_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2437 case NFA_VCOL: STRCPY(code, "NFA_VCOL "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2438 case NFA_VCOL_GT: STRCPY(code, "NFA_VCOL_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2439 case NFA_VCOL_LT: STRCPY(code, "NFA_VCOL_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2440 case NFA_MARK: STRCPY(code, "NFA_MARK "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2441 case NFA_MARK_GT: STRCPY(code, "NFA_MARK_GT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2442 case NFA_MARK_LT: STRCPY(code, "NFA_MARK_LT "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2443 case NFA_CURSOR: STRCPY(code, "NFA_CURSOR "); break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2444 case NFA_VISUAL: STRCPY(code, "NFA_VISUAL "); break; |
5901 | 2445 case NFA_ANY_COMPOSING: STRCPY(code, "NFA_ANY_COMPOSING "); break; |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
2446 |
4444 | 2447 case NFA_STAR: STRCPY(code, "NFA_STAR "); break; |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2448 case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2449 case NFA_QUEST: STRCPY(code, "NFA_QUEST"); break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
2450 case NFA_QUEST_NONGREEDY: STRCPY(code, "NFA_QUEST_NON_GREEDY"); break; |
5370 | 2451 case NFA_EMPTY: STRCPY(code, "NFA_EMPTY"); break; |
4444 | 2452 case NFA_OR: STRCPY(code, "NFA_OR"); break; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2453 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2454 case NFA_START_COLL: STRCPY(code, "NFA_START_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2455 case NFA_END_COLL: STRCPY(code, "NFA_END_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2456 case NFA_START_NEG_COLL: STRCPY(code, "NFA_START_NEG_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2457 case NFA_END_NEG_COLL: STRCPY(code, "NFA_END_NEG_COLL"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2458 case NFA_RANGE: STRCPY(code, "NFA_RANGE"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2459 case NFA_RANGE_MIN: STRCPY(code, "NFA_RANGE_MIN"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2460 case NFA_RANGE_MAX: STRCPY(code, "NFA_RANGE_MAX"); break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2461 |
4444 | 2462 case NFA_CLASS_ALNUM: STRCPY(code, "NFA_CLASS_ALNUM"); break; |
2463 case NFA_CLASS_ALPHA: STRCPY(code, "NFA_CLASS_ALPHA"); break; | |
2464 case NFA_CLASS_BLANK: STRCPY(code, "NFA_CLASS_BLANK"); break; | |
2465 case NFA_CLASS_CNTRL: STRCPY(code, "NFA_CLASS_CNTRL"); break; | |
2466 case NFA_CLASS_DIGIT: STRCPY(code, "NFA_CLASS_DIGIT"); break; | |
2467 case NFA_CLASS_GRAPH: STRCPY(code, "NFA_CLASS_GRAPH"); break; | |
2468 case NFA_CLASS_LOWER: STRCPY(code, "NFA_CLASS_LOWER"); break; | |
2469 case NFA_CLASS_PRINT: STRCPY(code, "NFA_CLASS_PRINT"); break; | |
2470 case NFA_CLASS_PUNCT: STRCPY(code, "NFA_CLASS_PUNCT"); break; | |
2471 case NFA_CLASS_SPACE: STRCPY(code, "NFA_CLASS_SPACE"); break; | |
2472 case NFA_CLASS_UPPER: STRCPY(code, "NFA_CLASS_UPPER"); break; | |
2473 case NFA_CLASS_XDIGIT: STRCPY(code, "NFA_CLASS_XDIGIT"); break; | |
2474 case NFA_CLASS_TAB: STRCPY(code, "NFA_CLASS_TAB"); break; | |
2475 case NFA_CLASS_RETURN: STRCPY(code, "NFA_CLASS_RETURN"); break; | |
2476 case NFA_CLASS_BACKSPACE: STRCPY(code, "NFA_CLASS_BACKSPACE"); break; | |
2477 case NFA_CLASS_ESCAPE: STRCPY(code, "NFA_CLASS_ESCAPE"); break; | |
2478 | |
2479 case NFA_ANY: STRCPY(code, "NFA_ANY"); break; | |
2480 case NFA_IDENT: STRCPY(code, "NFA_IDENT"); break; | |
2481 case NFA_SIDENT:STRCPY(code, "NFA_SIDENT"); break; | |
2482 case NFA_KWORD: STRCPY(code, "NFA_KWORD"); break; | |
2483 case NFA_SKWORD:STRCPY(code, "NFA_SKWORD"); break; | |
2484 case NFA_FNAME: STRCPY(code, "NFA_FNAME"); break; | |
2485 case NFA_SFNAME:STRCPY(code, "NFA_SFNAME"); break; | |
2486 case NFA_PRINT: STRCPY(code, "NFA_PRINT"); break; | |
2487 case NFA_SPRINT:STRCPY(code, "NFA_SPRINT"); break; | |
2488 case NFA_WHITE: STRCPY(code, "NFA_WHITE"); break; | |
2489 case NFA_NWHITE:STRCPY(code, "NFA_NWHITE"); break; | |
2490 case NFA_DIGIT: STRCPY(code, "NFA_DIGIT"); break; | |
2491 case NFA_NDIGIT:STRCPY(code, "NFA_NDIGIT"); break; | |
2492 case NFA_HEX: STRCPY(code, "NFA_HEX"); break; | |
2493 case NFA_NHEX: STRCPY(code, "NFA_NHEX"); break; | |
2494 case NFA_OCTAL: STRCPY(code, "NFA_OCTAL"); break; | |
2495 case NFA_NOCTAL:STRCPY(code, "NFA_NOCTAL"); break; | |
2496 case NFA_WORD: STRCPY(code, "NFA_WORD"); break; | |
2497 case NFA_NWORD: STRCPY(code, "NFA_NWORD"); break; | |
2498 case NFA_HEAD: STRCPY(code, "NFA_HEAD"); break; | |
2499 case NFA_NHEAD: STRCPY(code, "NFA_NHEAD"); break; | |
2500 case NFA_ALPHA: STRCPY(code, "NFA_ALPHA"); break; | |
2501 case NFA_NALPHA:STRCPY(code, "NFA_NALPHA"); break; | |
2502 case NFA_LOWER: STRCPY(code, "NFA_LOWER"); break; | |
2503 case NFA_NLOWER:STRCPY(code, "NFA_NLOWER"); break; | |
2504 case NFA_UPPER: STRCPY(code, "NFA_UPPER"); break; | |
2505 case NFA_NUPPER:STRCPY(code, "NFA_NUPPER"); break; | |
5296 | 2506 case NFA_LOWER_IC: STRCPY(code, "NFA_LOWER_IC"); break; |
2507 case NFA_NLOWER_IC: STRCPY(code, "NFA_NLOWER_IC"); break; | |
2508 case NFA_UPPER_IC: STRCPY(code, "NFA_UPPER_IC"); break; | |
2509 case NFA_NUPPER_IC: STRCPY(code, "NFA_NUPPER_IC"); break; | |
4444 | 2510 |
2511 default: | |
2512 STRCPY(code, "CHAR(x)"); | |
2513 code[5] = c; | |
2514 } | |
2515 | |
2516 if (addnl == TRUE) | |
2517 STRCAT(code, " + NEWLINE "); | |
2518 | |
2519 } | |
2520 | |
2521 #ifdef ENABLE_LOG | |
2522 static FILE *log_fd; | |
2523 | |
2524 /* | |
2525 * Print the postfix notation of the current regexp. | |
2526 */ | |
2527 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2528 nfa_postfix_dump(char_u *expr, int retval) |
4444 | 2529 { |
2530 int *p; | |
2531 FILE *f; | |
2532 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2533 f = fopen(NFA_REGEXP_DUMP_LOG, "a"); |
4444 | 2534 if (f != NULL) |
2535 { | |
2536 fprintf(f, "\n-------------------------\n"); | |
2537 if (retval == FAIL) | |
2538 fprintf(f, ">>> NFA engine failed ... \n"); | |
2539 else if (retval == OK) | |
2540 fprintf(f, ">>> NFA engine succeeded !\n"); | |
2541 fprintf(f, "Regexp: \"%s\"\nPostfix notation (char): \"", expr); | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2542 for (p = post_start; *p && p < post_ptr; p++) |
4444 | 2543 { |
2544 nfa_set_code(*p); | |
2545 fprintf(f, "%s, ", code); | |
2546 } | |
2547 fprintf(f, "\"\nPostfix notation (int): "); | |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
2548 for (p = post_start; *p && p < post_ptr; p++) |
4444 | 2549 fprintf(f, "%d ", *p); |
2550 fprintf(f, "\n\n"); | |
2551 fclose(f); | |
2552 } | |
2553 } | |
2554 | |
2555 /* | |
2556 * Print the NFA starting with a root node "state". | |
2557 */ | |
2558 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2559 nfa_print_state(FILE *debugf, nfa_state_T *state) |
4444 | 2560 { |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2561 garray_T indent; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2562 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2563 ga_init2(&indent, 1, 64); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2564 ga_append(&indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2565 nfa_print_state2(debugf, state, &indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2566 ga_clear(&indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2567 } |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2568 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2569 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2570 nfa_print_state2(FILE *debugf, nfa_state_T *state, garray_T *indent) |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2571 { |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2572 char_u *p; |
4444 | 2573 |
2574 if (state == NULL) | |
2575 return; | |
2576 | |
2577 fprintf(debugf, "(%2d)", abs(state->id)); | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2578 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2579 /* Output indent */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2580 p = (char_u *)indent->ga_data; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2581 if (indent->ga_len >= 3) |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2582 { |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2583 int last = indent->ga_len - 3; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2584 char_u save[2]; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2585 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2586 STRNCPY(save, &p[last], 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2587 STRNCPY(&p[last], "+-", 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2588 fprintf(debugf, " %s", p); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2589 STRNCPY(&p[last], save, 2); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2590 } |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2591 else |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2592 fprintf(debugf, " %s", p); |
4444 | 2593 |
2594 nfa_set_code(state->c); | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
2595 fprintf(debugf, "%s (%d) (id=%d) val=%d\n", |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2596 code, |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2597 state->c, |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2598 abs(state->id), |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2599 state->val); |
4444 | 2600 if (state->id < 0) |
2601 return; | |
2602 | |
2603 state->id = abs(state->id) * -1; | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2604 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2605 /* grow indent for state->out */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2606 indent->ga_len -= 1; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2607 if (state->out1) |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2608 ga_concat(indent, (char_u *)"| "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2609 else |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2610 ga_concat(indent, (char_u *)" "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2611 ga_append(indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2612 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2613 nfa_print_state2(debugf, state->out, indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2614 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2615 /* replace last part of indent for state->out1 */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2616 indent->ga_len -= 3; |
4537
5cc98a5898cf
updated for version 7.3.1016
Bram Moolenaar <bram@vim.org>
parents:
4535
diff
changeset
|
2617 ga_concat(indent, (char_u *)" "); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2618 ga_append(indent, '\0'); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2619 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2620 nfa_print_state2(debugf, state->out1, indent); |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2621 |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2622 /* shrink indent */ |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2623 indent->ga_len -= 3; |
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2624 ga_append(indent, '\0'); |
4444 | 2625 } |
2626 | |
2627 /* | |
2628 * Print the NFA state machine. | |
2629 */ | |
2630 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2631 nfa_dump(nfa_regprog_T *prog) |
4444 | 2632 { |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2633 FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a"); |
4444 | 2634 |
2635 if (debugf != NULL) | |
2636 { | |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
2637 nfa_print_state(debugf, prog->start); |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
2638 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2639 if (prog->reganch) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2640 fprintf(debugf, "reganch: %d\n", prog->reganch); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2641 if (prog->regstart != NUL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2642 fprintf(debugf, "regstart: %c (decimal: %d)\n", |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2643 prog->regstart, prog->regstart); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2644 if (prog->match_text != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
2645 fprintf(debugf, "match_text: \"%s\"\n", prog->match_text); |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
2646 |
4444 | 2647 fclose(debugf); |
2648 } | |
2649 } | |
2650 #endif /* ENABLE_LOG */ | |
2651 #endif /* DEBUG */ | |
2652 | |
2653 /* | |
2654 * Parse r.e. @expr and convert it into postfix form. | |
2655 * Return the postfix string on success, NULL otherwise. | |
2656 */ | |
2657 static int * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2658 re2post(void) |
4444 | 2659 { |
2660 if (nfa_reg(REG_NOPAREN) == FAIL) | |
2661 return NULL; | |
2662 EMIT(NFA_MOPEN); | |
2663 return post_start; | |
2664 } | |
2665 | |
2666 /* NB. Some of the code below is inspired by Russ's. */ | |
2667 | |
2668 /* | |
2669 * Represents an NFA state plus zero or one or two arrows exiting. | |
2670 * if c == MATCH, no arrows out; matching state. | |
2671 * If c == SPLIT, unlabeled arrows to out and out1 (if != NULL). | |
2672 * If c < 256, labeled arrow with character c to out. | |
2673 */ | |
2674 | |
2675 static nfa_state_T *state_ptr; /* points to nfa_prog->state */ | |
2676 | |
2677 /* | |
2678 * Allocate and initialize nfa_state_T. | |
2679 */ | |
2680 static nfa_state_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2681 alloc_state(int c, nfa_state_T *out, nfa_state_T *out1) |
4444 | 2682 { |
2683 nfa_state_T *s; | |
2684 | |
2685 if (istate >= nstate) | |
2686 return NULL; | |
2687 | |
2688 s = &state_ptr[istate++]; | |
2689 | |
2690 s->c = c; | |
2691 s->out = out; | |
2692 s->out1 = out1; | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
2693 s->val = 0; |
4444 | 2694 |
2695 s->id = istate; | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
2696 s->lastlist[0] = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
2697 s->lastlist[1] = 0; |
4444 | 2698 |
2699 return s; | |
2700 } | |
2701 | |
2702 /* | |
2703 * A partially built NFA without the matching state filled in. | |
2704 * Frag_T.start points at the start state. | |
2705 * Frag_T.out is a list of places that need to be set to the | |
2706 * next state for this fragment. | |
2707 */ | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2708 |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2709 /* Since the out pointers in the list are always |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2710 * uninitialized, we use the pointers themselves |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2711 * as storage for the Ptrlists. */ |
4444 | 2712 typedef union Ptrlist Ptrlist; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2713 union Ptrlist |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2714 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2715 Ptrlist *next; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2716 nfa_state_T *s; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2717 }; |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2718 |
4444 | 2719 struct Frag |
2720 { | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
2721 nfa_state_T *start; |
4444 | 2722 Ptrlist *out; |
2723 }; | |
2724 typedef struct Frag Frag_T; | |
2725 | |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2726 static Frag_T frag(nfa_state_T *start, Ptrlist *out); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2727 static Ptrlist *list1(nfa_state_T **outp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2728 static void patch(Ptrlist *l, nfa_state_T *s); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2729 static Ptrlist *append(Ptrlist *l1, Ptrlist *l2); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2730 static void st_push(Frag_T s, Frag_T **p, Frag_T *stack_end); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
2731 static Frag_T st_pop(Frag_T **p, Frag_T *stack); |
4444 | 2732 |
2733 /* | |
4456 | 2734 * Initialize a Frag_T struct and return it. |
4444 | 2735 */ |
2736 static Frag_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2737 frag(nfa_state_T *start, Ptrlist *out) |
4444 | 2738 { |
4456 | 2739 Frag_T n; |
2740 | |
2741 n.start = start; | |
2742 n.out = out; | |
4444 | 2743 return n; |
2744 } | |
2745 | |
2746 /* | |
2747 * Create singleton list containing just outp. | |
2748 */ | |
2749 static Ptrlist * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2750 list1( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2751 nfa_state_T **outp) |
4444 | 2752 { |
2753 Ptrlist *l; | |
2754 | |
2755 l = (Ptrlist *)outp; | |
2756 l->next = NULL; | |
2757 return l; | |
2758 } | |
2759 | |
2760 /* | |
2761 * Patch the list of states at out to point to start. | |
2762 */ | |
2763 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2764 patch(Ptrlist *l, nfa_state_T *s) |
4444 | 2765 { |
2766 Ptrlist *next; | |
2767 | |
2768 for (; l; l = next) | |
2769 { | |
2770 next = l->next; | |
2771 l->s = s; | |
2772 } | |
2773 } | |
2774 | |
2775 | |
2776 /* | |
2777 * Join the two lists l1 and l2, returning the combination. | |
2778 */ | |
2779 static Ptrlist * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2780 append(Ptrlist *l1, Ptrlist *l2) |
4444 | 2781 { |
2782 Ptrlist *oldl1; | |
2783 | |
2784 oldl1 = l1; | |
2785 while (l1->next) | |
2786 l1 = l1->next; | |
2787 l1->next = l2; | |
2788 return oldl1; | |
2789 } | |
2790 | |
2791 /* | |
2792 * Stack used for transforming postfix form into NFA. | |
2793 */ | |
2794 static Frag_T empty; | |
2795 | |
2796 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2797 st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED) |
4444 | 2798 { |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2799 #ifdef NFA_REGEXP_ERROR_LOG |
4444 | 2800 FILE *df; |
2801 int *p2; | |
2802 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2803 df = fopen(NFA_REGEXP_ERROR_LOG, "a"); |
4444 | 2804 if (df) |
2805 { | |
2806 fprintf(df, "Error popping the stack!\n"); | |
2807 #ifdef DEBUG | |
2808 fprintf(df, "Current regexp is \"%s\"\n", nfa_regengine.expr); | |
2809 #endif | |
2810 fprintf(df, "Postfix form is: "); | |
2811 #ifdef DEBUG | |
2812 for (p2 = postfix; p2 < end; p2++) | |
2813 { | |
2814 nfa_set_code(*p2); | |
2815 fprintf(df, "%s, ", code); | |
2816 } | |
2817 nfa_set_code(*p); | |
2818 fprintf(df, "\nCurrent position is: "); | |
2819 for (p2 = postfix; p2 <= p; p2 ++) | |
2820 { | |
2821 nfa_set_code(*p2); | |
2822 fprintf(df, "%s, ", code); | |
2823 } | |
2824 #else | |
2825 for (p2 = postfix; p2 < end; p2++) | |
2826 { | |
2827 fprintf(df, "%d, ", *p2); | |
2828 } | |
2829 fprintf(df, "\nCurrent position is: "); | |
2830 for (p2 = postfix; p2 <= p; p2 ++) | |
2831 { | |
2832 fprintf(df, "%d, ", *p2); | |
2833 } | |
2834 #endif | |
2835 fprintf(df, "\n--------------------------\n"); | |
2836 fclose(df); | |
2837 } | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
2838 #endif |
4444 | 2839 EMSG(_("E874: (NFA) Could not pop the stack !")); |
2840 } | |
2841 | |
2842 /* | |
2843 * Push an item onto the stack. | |
2844 */ | |
2845 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2846 st_push(Frag_T s, Frag_T **p, Frag_T *stack_end) |
4444 | 2847 { |
2848 Frag_T *stackp = *p; | |
2849 | |
2850 if (stackp >= stack_end) | |
2851 return; | |
2852 *stackp = s; | |
2853 *p = *p + 1; | |
2854 } | |
2855 | |
2856 /* | |
2857 * Pop an item from the stack. | |
2858 */ | |
2859 static Frag_T | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2860 st_pop(Frag_T **p, Frag_T *stack) |
4444 | 2861 { |
2862 Frag_T *stackp; | |
2863 | |
2864 *p = *p - 1; | |
2865 stackp = *p; | |
2866 if (stackp < stack) | |
2867 return empty; | |
2868 return **p; | |
2869 } | |
2870 | |
2871 /* | |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2872 * Estimate the maximum byte length of anything matching "state". |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2873 * When unknown or unlimited return -1. |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2874 */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2875 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
2876 nfa_max_width(nfa_state_T *startstate, int depth) |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2877 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2878 int l, r; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2879 nfa_state_T *state = startstate; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2880 int len = 0; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2881 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2882 /* detect looping in a NFA_SPLIT */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2883 if (depth > 4) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2884 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2885 |
4958
0a379dea13c9
updated for version 7.3.1224
Bram Moolenaar <bram@vim.org>
parents:
4944
diff
changeset
|
2886 while (state != NULL) |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2887 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2888 switch (state->c) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2889 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2890 case NFA_END_INVISIBLE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2891 case NFA_END_INVISIBLE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2892 /* the end, return what we have */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2893 return len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2894 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2895 case NFA_SPLIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2896 /* two alternatives, use the maximum */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2897 l = nfa_max_width(state->out, depth + 1); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2898 r = nfa_max_width(state->out1, depth + 1); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2899 if (l < 0 || r < 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2900 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2901 return len + (l > r ? l : r); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2902 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2903 case NFA_ANY: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2904 case NFA_START_COLL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2905 case NFA_START_NEG_COLL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2906 /* matches some character, including composing chars */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2907 #ifdef FEAT_MBYTE |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2908 if (enc_utf8) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2909 len += MB_MAXBYTES; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2910 else if (has_mbyte) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2911 len += 2; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2912 else |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2913 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2914 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2915 if (state->c != NFA_ANY) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2916 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2917 /* skip over the characters */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2918 state = state->out1->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2919 continue; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2920 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2921 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2922 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2923 case NFA_DIGIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2924 case NFA_WHITE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2925 case NFA_HEX: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2926 case NFA_OCTAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2927 /* ascii */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2928 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2929 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2930 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2931 case NFA_IDENT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2932 case NFA_SIDENT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2933 case NFA_KWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2934 case NFA_SKWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2935 case NFA_FNAME: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2936 case NFA_SFNAME: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2937 case NFA_PRINT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2938 case NFA_SPRINT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2939 case NFA_NWHITE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2940 case NFA_NDIGIT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2941 case NFA_NHEX: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2942 case NFA_NOCTAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2943 case NFA_WORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2944 case NFA_NWORD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2945 case NFA_HEAD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2946 case NFA_NHEAD: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2947 case NFA_ALPHA: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2948 case NFA_NALPHA: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2949 case NFA_LOWER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2950 case NFA_NLOWER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2951 case NFA_UPPER: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2952 case NFA_NUPPER: |
5296 | 2953 case NFA_LOWER_IC: |
2954 case NFA_NLOWER_IC: | |
2955 case NFA_UPPER_IC: | |
2956 case NFA_NUPPER_IC: | |
5901 | 2957 case NFA_ANY_COMPOSING: |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2958 /* possibly non-ascii */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2959 #ifdef FEAT_MBYTE |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2960 if (has_mbyte) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2961 len += 3; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2962 else |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2963 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2964 ++len; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2965 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2966 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2967 case NFA_START_INVISIBLE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2968 case NFA_START_INVISIBLE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2969 case NFA_START_INVISIBLE_BEFORE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2970 case NFA_START_INVISIBLE_BEFORE_NEG: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2971 /* zero-width, out1 points to the END state */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2972 state = state->out1->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2973 continue; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2974 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2975 case NFA_BACKREF1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2976 case NFA_BACKREF2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2977 case NFA_BACKREF3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2978 case NFA_BACKREF4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2979 case NFA_BACKREF5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2980 case NFA_BACKREF6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2981 case NFA_BACKREF7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2982 case NFA_BACKREF8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2983 case NFA_BACKREF9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2984 #ifdef FEAT_SYN_HL |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2985 case NFA_ZREF1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2986 case NFA_ZREF2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2987 case NFA_ZREF3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2988 case NFA_ZREF4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2989 case NFA_ZREF5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2990 case NFA_ZREF6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2991 case NFA_ZREF7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2992 case NFA_ZREF8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2993 case NFA_ZREF9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2994 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2995 case NFA_NEWL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2996 case NFA_SKIP: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2997 /* unknown width */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2998 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
2999 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3000 case NFA_BOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3001 case NFA_EOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3002 case NFA_BOF: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3003 case NFA_EOF: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3004 case NFA_BOW: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3005 case NFA_EOW: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3006 case NFA_MOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3007 case NFA_MOPEN1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3008 case NFA_MOPEN2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3009 case NFA_MOPEN3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3010 case NFA_MOPEN4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3011 case NFA_MOPEN5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3012 case NFA_MOPEN6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3013 case NFA_MOPEN7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3014 case NFA_MOPEN8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3015 case NFA_MOPEN9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3016 #ifdef FEAT_SYN_HL |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3017 case NFA_ZOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3018 case NFA_ZOPEN1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3019 case NFA_ZOPEN2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3020 case NFA_ZOPEN3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3021 case NFA_ZOPEN4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3022 case NFA_ZOPEN5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3023 case NFA_ZOPEN6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3024 case NFA_ZOPEN7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3025 case NFA_ZOPEN8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3026 case NFA_ZOPEN9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3027 case NFA_ZCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3028 case NFA_ZCLOSE1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3029 case NFA_ZCLOSE2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3030 case NFA_ZCLOSE3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3031 case NFA_ZCLOSE4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3032 case NFA_ZCLOSE5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3033 case NFA_ZCLOSE6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3034 case NFA_ZCLOSE7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3035 case NFA_ZCLOSE8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3036 case NFA_ZCLOSE9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3037 #endif |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3038 case NFA_MCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3039 case NFA_MCLOSE1: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3040 case NFA_MCLOSE2: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3041 case NFA_MCLOSE3: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3042 case NFA_MCLOSE4: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3043 case NFA_MCLOSE5: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3044 case NFA_MCLOSE6: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3045 case NFA_MCLOSE7: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3046 case NFA_MCLOSE8: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3047 case NFA_MCLOSE9: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3048 case NFA_NOPEN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3049 case NFA_NCLOSE: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3050 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3051 case NFA_LNUM_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3052 case NFA_LNUM_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3053 case NFA_COL_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3054 case NFA_COL_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3055 case NFA_VCOL_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3056 case NFA_VCOL_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3057 case NFA_MARK_GT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3058 case NFA_MARK_LT: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3059 case NFA_VISUAL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3060 case NFA_LNUM: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3061 case NFA_CURSOR: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3062 case NFA_COL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3063 case NFA_VCOL: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3064 case NFA_MARK: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3065 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3066 case NFA_ZSTART: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3067 case NFA_ZEND: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3068 case NFA_OPT_CHARS: |
5370 | 3069 case NFA_EMPTY: |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3070 case NFA_START_PATTERN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3071 case NFA_END_PATTERN: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3072 case NFA_COMPOSING: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3073 case NFA_END_COMPOSING: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3074 /* zero-width */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3075 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3076 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3077 default: |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3078 if (state->c < 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3079 /* don't know what this is */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3080 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3081 /* normal character */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3082 len += MB_CHAR2LEN(state->c); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3083 break; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3084 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3085 |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3086 /* normal way to continue */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3087 state = state->out; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3088 } |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3089 |
4958
0a379dea13c9
updated for version 7.3.1224
Bram Moolenaar <bram@vim.org>
parents:
4944
diff
changeset
|
3090 /* unrecognized, "cannot happen" */ |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3091 return -1; |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3092 } |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
3093 |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3094 /* |
4444 | 3095 * Convert a postfix form into its equivalent NFA. |
3096 * Return the NFA start state on success, NULL otherwise. | |
3097 */ | |
3098 static nfa_state_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3099 post2nfa(int *postfix, int *end, int nfa_calc_size) |
4444 | 3100 { |
3101 int *p; | |
3102 int mopen; | |
3103 int mclose; | |
3104 Frag_T *stack = NULL; | |
3105 Frag_T *stackp = NULL; | |
3106 Frag_T *stack_end = NULL; | |
3107 Frag_T e1; | |
3108 Frag_T e2; | |
3109 Frag_T e; | |
3110 nfa_state_T *s; | |
3111 nfa_state_T *s1; | |
3112 nfa_state_T *matchstate; | |
4484 | 3113 nfa_state_T *ret = NULL; |
4444 | 3114 |
3115 if (postfix == NULL) | |
3116 return NULL; | |
3117 | |
4456 | 3118 #define PUSH(s) st_push((s), &stackp, stack_end) |
4444 | 3119 #define POP() st_pop(&stackp, stack); \ |
3120 if (stackp < stack) \ | |
3121 { \ | |
3122 st_error(postfix, end, p); \ | |
6747 | 3123 vim_free(stack); \ |
4444 | 3124 return NULL; \ |
3125 } | |
3126 | |
3127 if (nfa_calc_size == FALSE) | |
3128 { | |
3129 /* Allocate space for the stack. Max states on the stack : nstate */ | |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3130 stack = (Frag_T *)lalloc((nstate + 1) * sizeof(Frag_T), TRUE); |
4444 | 3131 stackp = stack; |
4462 | 3132 stack_end = stack + (nstate + 1); |
4444 | 3133 } |
3134 | |
3135 for (p = postfix; p < end; ++p) | |
3136 { | |
3137 switch (*p) | |
3138 { | |
3139 case NFA_CONCAT: | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3140 /* Concatenation. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3141 * Pay attention: this operator does not exist in the r.e. itself |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3142 * (it is implicit, really). It is added when r.e. is translated |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3143 * to postfix form in re2post(). */ |
4444 | 3144 if (nfa_calc_size == TRUE) |
3145 { | |
4458 | 3146 /* nstate += 0; */ |
4444 | 3147 break; |
3148 } | |
3149 e2 = POP(); | |
3150 e1 = POP(); | |
3151 patch(e1.out, e2.start); | |
3152 PUSH(frag(e1.start, e2.out)); | |
3153 break; | |
3154 | |
3155 case NFA_OR: | |
3156 /* Alternation */ | |
3157 if (nfa_calc_size == TRUE) | |
3158 { | |
4458 | 3159 nstate++; |
4444 | 3160 break; |
3161 } | |
3162 e2 = POP(); | |
3163 e1 = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3164 s = alloc_state(NFA_SPLIT, e1.start, e2.start); |
4444 | 3165 if (s == NULL) |
4484 | 3166 goto theend; |
4444 | 3167 PUSH(frag(s, append(e1.out, e2.out))); |
3168 break; | |
3169 | |
3170 case NFA_STAR: | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3171 /* Zero or more, prefer more */ |
4444 | 3172 if (nfa_calc_size == TRUE) |
3173 { | |
4458 | 3174 nstate++; |
4444 | 3175 break; |
3176 } | |
3177 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3178 s = alloc_state(NFA_SPLIT, e.start, NULL); |
4444 | 3179 if (s == NULL) |
4484 | 3180 goto theend; |
4444 | 3181 patch(e.out, s); |
3182 PUSH(frag(s, list1(&s->out1))); | |
3183 break; | |
3184 | |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3185 case NFA_STAR_NONGREEDY: |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3186 /* Zero or more, prefer zero */ |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3187 if (nfa_calc_size == TRUE) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3188 { |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3189 nstate++; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3190 break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3191 } |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3192 e = POP(); |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3193 s = alloc_state(NFA_SPLIT, NULL, e.start); |
4675
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3194 if (s == NULL) |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3195 goto theend; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3196 patch(e.out, s); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3197 PUSH(frag(s, list1(&s->out))); |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3198 break; |
811a4c9b51d8
updated for version 7.3.1085
Bram Moolenaar <bram@vim.org>
parents:
4673
diff
changeset
|
3199 |
4444 | 3200 case NFA_QUEST: |
3201 /* one or zero atoms=> greedy match */ | |
3202 if (nfa_calc_size == TRUE) | |
3203 { | |
4458 | 3204 nstate++; |
4444 | 3205 break; |
3206 } | |
3207 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3208 s = alloc_state(NFA_SPLIT, e.start, NULL); |
4444 | 3209 if (s == NULL) |
4484 | 3210 goto theend; |
4444 | 3211 PUSH(frag(s, append(e.out, list1(&s->out1)))); |
3212 break; | |
3213 | |
3214 case NFA_QUEST_NONGREEDY: | |
3215 /* zero or one atoms => non-greedy match */ | |
3216 if (nfa_calc_size == TRUE) | |
3217 { | |
4458 | 3218 nstate++; |
4444 | 3219 break; |
3220 } | |
3221 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3222 s = alloc_state(NFA_SPLIT, NULL, e.start); |
4444 | 3223 if (s == NULL) |
4484 | 3224 goto theend; |
4444 | 3225 PUSH(frag(s, append(e.out, list1(&s->out)))); |
3226 break; | |
3227 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3228 case NFA_END_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3229 case NFA_END_NEG_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3230 /* On the stack is the sequence starting with NFA_START_COLL or |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3231 * NFA_START_NEG_COLL and all possible characters. Patch it to |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3232 * add the output to the start. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3233 if (nfa_calc_size == TRUE) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3234 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3235 nstate++; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3236 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3237 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3238 e = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3239 s = alloc_state(NFA_END_COLL, NULL, NULL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3240 if (s == NULL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3241 goto theend; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3242 patch(e.out, s); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3243 e.start->out1 = s; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3244 PUSH(frag(e.start, list1(&s->out))); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3245 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3246 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3247 case NFA_RANGE: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3248 /* Before this are two characters, the low and high end of a |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3249 * range. Turn them into two states with MIN and MAX. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3250 if (nfa_calc_size == TRUE) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3251 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3252 /* nstate += 0; */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3253 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3254 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3255 e2 = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3256 e1 = POP(); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3257 e2.start->val = e2.start->c; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3258 e2.start->c = NFA_RANGE_MAX; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3259 e1.start->val = e1.start->c; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3260 e1.start->c = NFA_RANGE_MIN; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3261 patch(e1.out, e2.start); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3262 PUSH(frag(e1.start, e2.out)); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3263 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3264 |
5370 | 3265 case NFA_EMPTY: |
3266 /* 0-length, used in a repetition with max/min count of 0 */ | |
4444 | 3267 if (nfa_calc_size == TRUE) |
3268 { | |
4458 | 3269 nstate++; |
4444 | 3270 break; |
3271 } | |
5370 | 3272 s = alloc_state(NFA_EMPTY, NULL, NULL); |
4444 | 3273 if (s == NULL) |
4484 | 3274 goto theend; |
4444 | 3275 PUSH(frag(s, list1(&s->out))); |
3276 break; | |
3277 | |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3278 case NFA_OPT_CHARS: |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3279 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3280 int n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3281 |
5255
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3282 /* \%[abc] implemented as: |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3283 * NFA_SPLIT |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3284 * +-CHAR(a) |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3285 * | +-NFA_SPLIT |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3286 * | +-CHAR(b) |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3287 * | | +-NFA_SPLIT |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3288 * | | +-CHAR(c) |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3289 * | | | +-next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3290 * | | +- next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3291 * | +- next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3292 * +- next |
3c6e2b89875f
updated for version 7.4b.004
Bram Moolenaar <bram@vim.org>
parents:
5253
diff
changeset
|
3293 */ |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3294 n = *++p; /* get number of characters */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3295 if (nfa_calc_size == TRUE) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3296 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3297 nstate += n; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3298 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3299 } |
4758
b25a1b2e3175
updated for version 7.3.1126
Bram Moolenaar <bram@vim.org>
parents:
4756
diff
changeset
|
3300 s = NULL; /* avoid compiler warning */ |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3301 e1.out = NULL; /* stores list with out1's */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3302 s1 = NULL; /* previous NFA_SPLIT to connect to */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3303 while (n-- > 0) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3304 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3305 e = POP(); /* get character */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3306 s = alloc_state(NFA_SPLIT, e.start, NULL); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3307 if (s == NULL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3308 goto theend; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3309 if (e1.out == NULL) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3310 e1 = e; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3311 patch(e.out, s1); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3312 append(e1.out, list1(&s->out1)); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3313 s1 = s; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3314 } |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3315 PUSH(frag(s, e1.out)); |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3316 break; |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3317 } |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3318 |
4444 | 3319 case NFA_PREV_ATOM_NO_WIDTH: |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
3320 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3321 case NFA_PREV_ATOM_JUST_BEFORE: |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3322 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3323 case NFA_PREV_ATOM_LIKE_PATTERN: |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3324 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3325 int before = (*p == NFA_PREV_ATOM_JUST_BEFORE |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3326 || *p == NFA_PREV_ATOM_JUST_BEFORE_NEG); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3327 int pattern = (*p == NFA_PREV_ATOM_LIKE_PATTERN); |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3328 int start_state; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3329 int end_state; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3330 int n = 0; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3331 nfa_state_T *zend; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3332 nfa_state_T *skip; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3333 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3334 switch (*p) |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3335 { |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3336 case NFA_PREV_ATOM_NO_WIDTH: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3337 start_state = NFA_START_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3338 end_state = NFA_END_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3339 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3340 case NFA_PREV_ATOM_NO_WIDTH_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3341 start_state = NFA_START_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3342 end_state = NFA_END_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3343 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3344 case NFA_PREV_ATOM_JUST_BEFORE: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3345 start_state = NFA_START_INVISIBLE_BEFORE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3346 end_state = NFA_END_INVISIBLE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3347 break; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3348 case NFA_PREV_ATOM_JUST_BEFORE_NEG: |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3349 start_state = NFA_START_INVISIBLE_BEFORE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3350 end_state = NFA_END_INVISIBLE_NEG; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3351 break; |
4819
8c4324e6f477
updated for version 7.3.1156
Bram Moolenaar <bram@vim.org>
parents:
4815
diff
changeset
|
3352 default: /* NFA_PREV_ATOM_LIKE_PATTERN: */ |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3353 start_state = NFA_START_PATTERN; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3354 end_state = NFA_END_PATTERN; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
3355 break; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3356 } |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3357 |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3358 if (before) |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3359 n = *++p; /* get the count */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3360 |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
3361 /* The \@= operator: match the preceding atom with zero width. |
4661
0dce3d812e7a
updated for version 7.3.1078
Bram Moolenaar <bram@vim.org>
parents:
4657
diff
changeset
|
3362 * The \@! operator: no match for the preceding atom. |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3363 * The \@<= operator: match for the preceding atom. |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3364 * The \@<! operator: no match for the preceding atom. |
4444 | 3365 * Surrounds the preceding atom with START_INVISIBLE and |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
3366 * END_INVISIBLE, similarly to MOPEN. */ |
4444 | 3367 |
3368 if (nfa_calc_size == TRUE) | |
3369 { | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3370 nstate += pattern ? 4 : 2; |
4444 | 3371 break; |
3372 } | |
3373 e = POP(); | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3374 s1 = alloc_state(end_state, NULL, NULL); |
4444 | 3375 if (s1 == NULL) |
4484 | 3376 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3377 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3378 s = alloc_state(start_state, e.start, s1); |
4444 | 3379 if (s == NULL) |
4484 | 3380 goto theend; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3381 if (pattern) |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3382 { |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3383 /* NFA_ZEND -> NFA_END_PATTERN -> NFA_SKIP -> what follows. */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3384 skip = alloc_state(NFA_SKIP, NULL, NULL); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3385 zend = alloc_state(NFA_ZEND, s1, NULL); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3386 s1->out= skip; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3387 patch(e.out, zend); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3388 PUSH(frag(s, list1(&skip->out))); |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
3389 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3390 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3391 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3392 patch(e.out, s1); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3393 PUSH(frag(s, list1(&s1->out))); |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3394 if (before) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3395 { |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3396 if (n <= 0) |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3397 /* See if we can guess the maximum width, it avoids a |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3398 * lot of pointless tries. */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3399 n = nfa_max_width(e.start, 0); |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3400 s->val = n; /* store the count */ |
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
3401 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3402 } |
4444 | 3403 break; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3404 } |
4444 | 3405 |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3406 #ifdef FEAT_MBYTE |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3407 case NFA_COMPOSING: /* char with composing char */ |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3408 #if 0 |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3409 /* TODO */ |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3410 if (regflags & RF_ICOMBINE) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3411 { |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
3412 /* use the base character only */ |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3413 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3414 #endif |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3415 /* FALLTHROUGH */ |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3416 #endif |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3417 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3418 case NFA_MOPEN: /* \( \) Submatch */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3419 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3420 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3421 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3422 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3423 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3424 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3425 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3426 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3427 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3428 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3429 case NFA_ZOPEN: /* \z( \) Submatch */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3430 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3431 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3432 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3433 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3434 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3435 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3436 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3437 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3438 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3439 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3440 case NFA_NOPEN: /* \%( \) "Invisible Submatch" */ |
4444 | 3441 if (nfa_calc_size == TRUE) |
3442 { | |
3443 nstate += 2; | |
3444 break; | |
3445 } | |
3446 | |
3447 mopen = *p; | |
3448 switch (*p) | |
3449 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3450 case NFA_NOPEN: mclose = NFA_NCLOSE; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3451 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3452 case NFA_ZOPEN: mclose = NFA_ZCLOSE; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3453 case NFA_ZOPEN1: mclose = NFA_ZCLOSE1; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3454 case NFA_ZOPEN2: mclose = NFA_ZCLOSE2; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3455 case NFA_ZOPEN3: mclose = NFA_ZCLOSE3; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3456 case NFA_ZOPEN4: mclose = NFA_ZCLOSE4; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3457 case NFA_ZOPEN5: mclose = NFA_ZCLOSE5; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3458 case NFA_ZOPEN6: mclose = NFA_ZCLOSE6; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3459 case NFA_ZOPEN7: mclose = NFA_ZCLOSE7; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3460 case NFA_ZOPEN8: mclose = NFA_ZCLOSE8; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3461 case NFA_ZOPEN9: mclose = NFA_ZCLOSE9; break; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3462 #endif |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3463 #ifdef FEAT_MBYTE |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3464 case NFA_COMPOSING: mclose = NFA_END_COMPOSING; break; |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3465 #endif |
4444 | 3466 default: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3467 /* NFA_MOPEN, NFA_MOPEN1 .. NFA_MOPEN9 */ |
4444 | 3468 mclose = *p + NSUBEXP; |
3469 break; | |
3470 } | |
3471 | |
3472 /* Allow "NFA_MOPEN" as a valid postfix representation for | |
3473 * the empty regexp "". In this case, the NFA will be | |
3474 * NFA_MOPEN -> NFA_MCLOSE. Note that this also allows | |
3475 * empty groups of parenthesis, and empty mbyte chars */ | |
3476 if (stackp == stack) | |
3477 { | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3478 s = alloc_state(mopen, NULL, NULL); |
4444 | 3479 if (s == NULL) |
4484 | 3480 goto theend; |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3481 s1 = alloc_state(mclose, NULL, NULL); |
4444 | 3482 if (s1 == NULL) |
4484 | 3483 goto theend; |
4444 | 3484 patch(list1(&s->out), s1); |
3485 PUSH(frag(s, list1(&s1->out))); | |
3486 break; | |
3487 } | |
3488 | |
3489 /* At least one node was emitted before NFA_MOPEN, so | |
3490 * at least one node will be between NFA_MOPEN and NFA_MCLOSE */ | |
3491 e = POP(); | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3492 s = alloc_state(mopen, e.start, NULL); /* `(' */ |
4444 | 3493 if (s == NULL) |
4484 | 3494 goto theend; |
4444 | 3495 |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3496 s1 = alloc_state(mclose, NULL, NULL); /* `)' */ |
4444 | 3497 if (s1 == NULL) |
4484 | 3498 goto theend; |
4444 | 3499 patch(e.out, s1); |
3500 | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3501 #ifdef FEAT_MBYTE |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3502 if (mopen == NFA_COMPOSING) |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
3503 /* COMPOSING->out1 = END_COMPOSING */ |
4444 | 3504 patch(list1(&s->out1), s1); |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
3505 #endif |
4444 | 3506 |
3507 PUSH(frag(s, list1(&s1->out))); | |
3508 break; | |
3509 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3510 case NFA_BACKREF1: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3511 case NFA_BACKREF2: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3512 case NFA_BACKREF3: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3513 case NFA_BACKREF4: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3514 case NFA_BACKREF5: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3515 case NFA_BACKREF6: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3516 case NFA_BACKREF7: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3517 case NFA_BACKREF8: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3518 case NFA_BACKREF9: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3519 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3520 case NFA_ZREF1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3521 case NFA_ZREF2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3522 case NFA_ZREF3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3523 case NFA_ZREF4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3524 case NFA_ZREF5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3525 case NFA_ZREF6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3526 case NFA_ZREF7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3527 case NFA_ZREF8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3528 case NFA_ZREF9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3529 #endif |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3530 if (nfa_calc_size == TRUE) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3531 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3532 nstate += 2; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3533 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3534 } |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3535 s = alloc_state(*p, NULL, NULL); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3536 if (s == NULL) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3537 goto theend; |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3538 s1 = alloc_state(NFA_SKIP, NULL, NULL); |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3539 if (s1 == NULL) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3540 goto theend; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3541 patch(list1(&s->out), s1); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3542 PUSH(frag(s, list1(&s1->out))); |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3543 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3544 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3545 case NFA_LNUM: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3546 case NFA_LNUM_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3547 case NFA_LNUM_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3548 case NFA_VCOL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3549 case NFA_VCOL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3550 case NFA_VCOL_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3551 case NFA_COL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3552 case NFA_COL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3553 case NFA_COL_LT: |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3554 case NFA_MARK: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3555 case NFA_MARK_GT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
3556 case NFA_MARK_LT: |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3557 { |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3558 int n = *++p; /* lnum, col or mark name */ |
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3559 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3560 if (nfa_calc_size == TRUE) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3561 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3562 nstate += 1; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3563 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3564 } |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3565 s = alloc_state(p[-1], NULL, NULL); |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3566 if (s == NULL) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3567 goto theend; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3568 s->val = n; |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3569 PUSH(frag(s, list1(&s->out))); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3570 break; |
4740
97560c16ca99
updated for version 7.3.1117
Bram Moolenaar <bram@vim.org>
parents:
4738
diff
changeset
|
3571 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
3572 |
4444 | 3573 case NFA_ZSTART: |
3574 case NFA_ZEND: | |
3575 default: | |
3576 /* Operands */ | |
3577 if (nfa_calc_size == TRUE) | |
3578 { | |
4458 | 3579 nstate++; |
4444 | 3580 break; |
3581 } | |
4696
ed4e689bbea1
updated for version 7.3.1095
Bram Moolenaar <bram@vim.org>
parents:
4694
diff
changeset
|
3582 s = alloc_state(*p, NULL, NULL); |
4444 | 3583 if (s == NULL) |
4484 | 3584 goto theend; |
4444 | 3585 PUSH(frag(s, list1(&s->out))); |
3586 break; | |
3587 | |
3588 } /* switch(*p) */ | |
3589 | |
3590 } /* for(p = postfix; *p; ++p) */ | |
3591 | |
3592 if (nfa_calc_size == TRUE) | |
3593 { | |
4458 | 3594 nstate++; |
4484 | 3595 goto theend; /* Return value when counting size is ignored anyway */ |
4444 | 3596 } |
3597 | |
3598 e = POP(); | |
3599 if (stackp != stack) | |
6747 | 3600 { |
3601 vim_free(stack); | |
4444 | 3602 EMSG_RET_NULL(_("E875: (NFA regexp) (While converting from postfix to NFA), too many states left on stack")); |
6747 | 3603 } |
4444 | 3604 |
3605 if (istate >= nstate) | |
6747 | 3606 { |
3607 vim_free(stack); | |
4444 | 3608 EMSG_RET_NULL(_("E876: (NFA regexp) Not enough space to store the whole NFA ")); |
6747 | 3609 } |
4444 | 3610 |
3611 matchstate = &state_ptr[istate++]; /* the match state */ | |
3612 matchstate->c = NFA_MATCH; | |
3613 matchstate->out = matchstate->out1 = NULL; | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
3614 matchstate->id = 0; |
4444 | 3615 |
3616 patch(e.out, matchstate); | |
4484 | 3617 ret = e.start; |
3618 | |
3619 theend: | |
3620 vim_free(stack); | |
3621 return ret; | |
4444 | 3622 |
3623 #undef POP1 | |
3624 #undef PUSH1 | |
3625 #undef POP2 | |
3626 #undef PUSH2 | |
3627 #undef POP | |
3628 #undef PUSH | |
3629 } | |
3630 | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3631 /* |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3632 * After building the NFA program, inspect it to add optimization hints. |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3633 */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3634 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3635 nfa_postprocess(nfa_regprog_T *prog) |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3636 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3637 int i; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3638 int c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3639 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3640 for (i = 0; i < prog->nstate; ++i) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3641 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3642 c = prog->state[i].c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3643 if (c == NFA_START_INVISIBLE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3644 || c == NFA_START_INVISIBLE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3645 || c == NFA_START_INVISIBLE_BEFORE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3646 || c == NFA_START_INVISIBLE_BEFORE_NEG) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3647 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3648 int directly; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3649 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3650 /* Do it directly when what follows is possibly the end of the |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3651 * match. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3652 if (match_follows(prog->state[i].out1->out, 0)) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3653 directly = TRUE; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3654 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3655 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3656 int ch_invisible = failure_chance(prog->state[i].out, 0); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3657 int ch_follows = failure_chance(prog->state[i].out1->out, 0); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3658 |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3659 /* Postpone when the invisible match is expensive or has a |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3660 * lower chance of failing. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3661 if (c == NFA_START_INVISIBLE_BEFORE |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3662 || c == NFA_START_INVISIBLE_BEFORE_NEG) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3663 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3664 /* "before" matches are very expensive when |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3665 * unbounded, always prefer what follows then, |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3666 * unless what follows will always match. |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3667 * Otherwise strongly prefer what follows. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3668 if (prog->state[i].val <= 0 && ch_follows > 0) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3669 directly = FALSE; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3670 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3671 directly = ch_follows * 10 < ch_invisible; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3672 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3673 else |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3674 { |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3675 /* normal invisible, first do the one with the |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3676 * highest failure chance */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3677 directly = ch_follows < ch_invisible; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3678 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3679 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3680 if (directly) |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3681 /* switch to the _FIRST state */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3682 ++prog->state[i].c; |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3683 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3684 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3685 } |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
3686 |
4444 | 3687 /**************************************************************** |
3688 * NFA execution code. | |
3689 ****************************************************************/ | |
3690 | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3691 typedef struct |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3692 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3693 int in_use; /* number of subexpr with useful info */ |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3694 |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3695 /* When REG_MULTI is TRUE list.multi is used, otherwise list.line. */ |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3696 union |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3697 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3698 struct multipos |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3699 { |
6547 | 3700 linenr_T start_lnum; |
3701 linenr_T end_lnum; | |
3702 colnr_T start_col; | |
3703 colnr_T end_col; | |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3704 } multi[NSUBEXP]; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3705 struct linepos |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3706 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3707 char_u *start; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3708 char_u *end; |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3709 } line[NSUBEXP]; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
3710 } list; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3711 } regsub_T; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
3712 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3713 typedef struct |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3714 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3715 regsub_T norm; /* \( .. \) matches */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3716 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3717 regsub_T synt; /* \z( .. \) matches */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3718 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3719 } regsubs_T; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3720 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3721 /* nfa_pim_T stores a Postponed Invisible Match. */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3722 typedef struct nfa_pim_S nfa_pim_T; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3723 struct nfa_pim_S |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3724 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3725 int result; /* NFA_PIM_*, see below */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3726 nfa_state_T *state; /* the invisible match start state */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3727 regsubs_T subs; /* submatch info, only party used */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3728 union |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3729 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3730 lpos_T pos; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3731 char_u *ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3732 } end; /* where the match must end */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3733 }; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3734 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3735 /* Values for done in nfa_pim_T. */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3736 #define NFA_PIM_UNUSED 0 /* pim not used */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3737 #define NFA_PIM_TODO 1 /* pim not done yet */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3738 #define NFA_PIM_MATCH 2 /* pim executed, matches */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3739 #define NFA_PIM_NOMATCH 3 /* pim executed, no match */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3740 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
3741 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3742 /* nfa_thread_T contains execution information of a NFA state */ |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3743 typedef struct |
4444 | 3744 { |
3745 nfa_state_T *state; | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3746 int count; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3747 nfa_pim_T pim; /* if pim.result != NFA_PIM_UNUSED: postponed |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3748 * invisible match */ |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3749 regsubs_T subs; /* submatch info, only party used */ |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3750 } nfa_thread_T; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3751 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3752 /* nfa_list_T contains the alternative NFA execution states. */ |
4444 | 3753 typedef struct |
3754 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3755 nfa_thread_T *t; /* allocated array of states */ |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3756 int n; /* nr of states currently in "t" */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3757 int len; /* max nr of states in "t" */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3758 int id; /* ID of the list */ |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
3759 int has_pim; /* TRUE when any state has a PIM */ |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3760 } nfa_list_T; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
3761 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3762 #ifdef ENABLE_LOG |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3763 static void log_subsexpr(regsubs_T *subs); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3764 static void log_subexpr(regsub_T *sub); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3765 static char *pim_info(nfa_pim_T *pim); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3766 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3767 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3768 log_subsexpr(regsubs_T *subs) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3769 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3770 log_subexpr(&subs->norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3771 # ifdef FEAT_SYN_HL |
4770
b20dbf3a5370
updated for version 7.3.1132
Bram Moolenaar <bram@vim.org>
parents:
4768
diff
changeset
|
3772 if (nfa_has_zsubexpr) |
b20dbf3a5370
updated for version 7.3.1132
Bram Moolenaar <bram@vim.org>
parents:
4768
diff
changeset
|
3773 log_subexpr(&subs->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3774 # endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3775 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3776 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3777 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3778 log_subexpr(regsub_T *sub) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3779 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3780 int j; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3781 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3782 for (j = 0; j < sub->in_use; j++) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3783 if (REG_MULTI) |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3784 fprintf(log_fd, "*** group %d, start: c=%d, l=%d, end: c=%d, l=%d\n", |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3785 j, |
6547 | 3786 sub->list.multi[j].start_col, |
3787 (int)sub->list.multi[j].start_lnum, | |
3788 sub->list.multi[j].end_col, | |
3789 (int)sub->list.multi[j].end_lnum); | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3790 else |
4746
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3791 { |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3792 char *s = (char *)sub->list.line[j].start; |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3793 char *e = (char *)sub->list.line[j].end; |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3794 |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
3795 fprintf(log_fd, "*** group %d, start: \"%s\", end: \"%s\"\n", |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3796 j, |
4746
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3797 s == NULL ? "NULL" : s, |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3798 e == NULL ? "NULL" : e); |
d1376091d18b
updated for version 7.3.1120
Bram Moolenaar <bram@vim.org>
parents:
4744
diff
changeset
|
3799 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3800 } |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3801 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3802 static char * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3803 pim_info(nfa_pim_T *pim) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3804 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3805 static char buf[30]; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3806 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3807 if (pim == NULL || pim->result == NFA_PIM_UNUSED) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3808 buf[0] = NUL; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3809 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3810 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3811 sprintf(buf, " PIM col %d", REG_MULTI ? (int)pim->end.pos.col |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3812 : (int)(pim->end.ptr - reginput)); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3813 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3814 return buf; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3815 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3816 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3817 #endif |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
3818 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3819 /* Used during execution: whether a match has been found. */ |
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3820 static int nfa_match; |
6573 | 3821 #ifdef FEAT_RELTIME |
3822 static proftime_T *nfa_time_limit; | |
3823 static int nfa_time_count; | |
3824 #endif | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
3825 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3826 static void copy_pim(nfa_pim_T *to, nfa_pim_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3827 static void clear_sub(regsub_T *sub); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3828 static void copy_sub(regsub_T *to, regsub_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3829 static void copy_sub_off(regsub_T *to, regsub_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3830 static void copy_ze_off(regsub_T *to, regsub_T *from); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3831 static int sub_equal(regsub_T *sub1, regsub_T *sub2); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3832 static int match_backref(regsub_T *sub, int subidx, int *bytelen); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3833 static int has_state_with_pos(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3834 static int pim_equal(nfa_pim_T *one, nfa_pim_T *two); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3835 static int state_in_list(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3836 static regsubs_T *addstate(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs_arg, nfa_pim_T *pim, int off); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
3837 static void addstate_here(nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim, int *ip); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3838 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3839 /* |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3840 * Copy postponed invisible match info from "from" to "to". |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3841 */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3842 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3843 copy_pim(nfa_pim_T *to, nfa_pim_T *from) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3844 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3845 to->result = from->result; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3846 to->state = from->state; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3847 copy_sub(&to->subs.norm, &from->subs.norm); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3848 #ifdef FEAT_SYN_HL |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3849 if (nfa_has_zsubexpr) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3850 copy_sub(&to->subs.synt, &from->subs.synt); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3851 #endif |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3852 to->end = from->end; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3853 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
3854 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3855 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3856 clear_sub(regsub_T *sub) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3857 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3858 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3859 /* Use 0xff to set lnum to -1 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3860 vim_memset(sub->list.multi, 0xff, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3861 sizeof(struct multipos) * nfa_nsubexpr); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3862 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3863 vim_memset(sub->list.line, 0, sizeof(struct linepos) * nfa_nsubexpr); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3864 sub->in_use = 0; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3865 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3866 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3867 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3868 * Copy the submatches from "from" to "to". |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3869 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3870 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3871 copy_sub(regsub_T *to, regsub_T *from) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3872 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3873 to->in_use = from->in_use; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3874 if (from->in_use > 0) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3875 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3876 /* Copy the match start and end positions. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3877 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3878 mch_memmove(&to->list.multi[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3879 &from->list.multi[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3880 sizeof(struct multipos) * from->in_use); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3881 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3882 mch_memmove(&to->list.line[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3883 &from->list.line[0], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3884 sizeof(struct linepos) * from->in_use); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3885 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3886 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3887 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3888 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3889 * Like copy_sub() but exclude the main match. |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3890 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3891 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3892 copy_sub_off(regsub_T *to, regsub_T *from) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3893 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3894 if (to->in_use < from->in_use) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3895 to->in_use = from->in_use; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3896 if (from->in_use > 1) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3897 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3898 /* Copy the match start and end positions. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3899 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3900 mch_memmove(&to->list.multi[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3901 &from->list.multi[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3902 sizeof(struct multipos) * (from->in_use - 1)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3903 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3904 mch_memmove(&to->list.line[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3905 &from->list.line[1], |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3906 sizeof(struct linepos) * (from->in_use - 1)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3907 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
3908 } |
4444 | 3909 |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3910 /* |
5372 | 3911 * Like copy_sub() but only do the end of the main match if \ze is present. |
3912 */ | |
3913 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3914 copy_ze_off(regsub_T *to, regsub_T *from) |
5372 | 3915 { |
3916 if (nfa_has_zend) | |
3917 { | |
3918 if (REG_MULTI) | |
3919 { | |
6547 | 3920 if (from->list.multi[0].end_lnum >= 0) |
3921 { | |
3922 to->list.multi[0].end_lnum = from->list.multi[0].end_lnum; | |
3923 to->list.multi[0].end_col = from->list.multi[0].end_col; | |
3924 } | |
5372 | 3925 } |
3926 else | |
3927 { | |
3928 if (from->list.line[0].end != NULL) | |
3929 to->list.line[0].end = from->list.line[0].end; | |
3930 } | |
3931 } | |
3932 } | |
3933 | |
3934 /* | |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3935 * Return TRUE if "sub1" and "sub2" have the same start positions. |
5893 | 3936 * When using back-references also check the end position. |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3937 */ |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3938 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
3939 sub_equal(regsub_T *sub1, regsub_T *sub2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3940 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3941 int i; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3942 int todo; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3943 linenr_T s1; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3944 linenr_T s2; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3945 char_u *sp1; |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3946 char_u *sp2; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3947 |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3948 todo = sub1->in_use > sub2->in_use ? sub1->in_use : sub2->in_use; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3949 if (REG_MULTI) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3950 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3951 for (i = 0; i < todo; ++i) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3952 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3953 if (i < sub1->in_use) |
6547 | 3954 s1 = sub1->list.multi[i].start_lnum; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3955 else |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
3956 s1 = -1; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3957 if (i < sub2->in_use) |
6547 | 3958 s2 = sub2->list.multi[i].start_lnum; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3959 else |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
3960 s2 = -1; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3961 if (s1 != s2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3962 return FALSE; |
6547 | 3963 if (s1 != -1 && sub1->list.multi[i].start_col |
3964 != sub2->list.multi[i].start_col) | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3965 return FALSE; |
5893 | 3966 |
3967 if (nfa_has_backref) | |
3968 { | |
3969 if (i < sub1->in_use) | |
6547 | 3970 s1 = sub1->list.multi[i].end_lnum; |
5893 | 3971 else |
3972 s1 = -1; | |
3973 if (i < sub2->in_use) | |
6547 | 3974 s2 = sub2->list.multi[i].end_lnum; |
5893 | 3975 else |
3976 s2 = -1; | |
3977 if (s1 != s2) | |
3978 return FALSE; | |
6547 | 3979 if (s1 != -1 && sub1->list.multi[i].end_col |
3980 != sub2->list.multi[i].end_col) | |
5893 | 3981 return FALSE; |
3982 } | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3983 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3984 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3985 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3986 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3987 for (i = 0; i < todo; ++i) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3988 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3989 if (i < sub1->in_use) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3990 sp1 = sub1->list.line[i].start; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3991 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3992 sp1 = NULL; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3993 if (i < sub2->in_use) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3994 sp2 = sub2->list.line[i].start; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3995 else |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3996 sp2 = NULL; |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
3997 if (sp1 != sp2) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
3998 return FALSE; |
5893 | 3999 if (nfa_has_backref) |
4000 { | |
4001 if (i < sub1->in_use) | |
4002 sp1 = sub1->list.line[i].end; | |
4003 else | |
4004 sp1 = NULL; | |
4005 if (i < sub2->in_use) | |
4006 sp2 = sub2->list.line[i].end; | |
4007 else | |
4008 sp2 = NULL; | |
4009 if (sp1 != sp2) | |
4010 return FALSE; | |
4011 } | |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4012 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4013 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4014 |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4015 return TRUE; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4016 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4017 |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4018 #ifdef ENABLE_LOG |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4019 static void |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4020 report_state(char *action, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4021 regsub_T *sub, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4022 nfa_state_T *state, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4023 int lid, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4024 nfa_pim_T *pim) |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4025 { |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4026 int col; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4027 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4028 if (sub->in_use <= 0) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4029 col = -1; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4030 else if (REG_MULTI) |
6547 | 4031 col = sub->list.multi[0].start_col; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4032 else |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4033 col = (int)(sub->list.line[0].start - regline); |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4034 nfa_set_code(state->c); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4035 fprintf(log_fd, "> %s state %d to list %d. char %d: %s (start col %d)%s\n", |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4036 action, abs(state->id), lid, state->c, code, col, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4037 pim_info(pim)); |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4038 } |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4039 #endif |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4040 |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4041 /* |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4042 * Return TRUE if the same state is already in list "l" with the same |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4043 * positions as "subs". |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4044 */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4045 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4046 has_state_with_pos( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4047 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4048 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4049 regsubs_T *subs, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4050 nfa_pim_T *pim) /* postponed match or NULL */ |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4051 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4052 nfa_thread_T *thread; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4053 int i; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4054 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4055 for (i = 0; i < l->n; ++i) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4056 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4057 thread = &l->t[i]; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4058 if (thread->state->id == state->id |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4059 && sub_equal(&thread->subs.norm, &subs->norm) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4060 #ifdef FEAT_SYN_HL |
4893
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4061 && (!nfa_has_zsubexpr |
07b9c48a30e9
updated for version 7.3.1192
Bram Moolenaar <bram@vim.org>
parents:
4891
diff
changeset
|
4062 || sub_equal(&thread->subs.synt, &subs->synt)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4063 #endif |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4064 && pim_equal(&thread->pim, pim)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4065 return TRUE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4066 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4067 return FALSE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4068 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4069 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4070 /* |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4071 * Return TRUE if "one" and "two" are equal. That includes when both are not |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4072 * set. |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4073 */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4074 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4075 pim_equal(nfa_pim_T *one, nfa_pim_T *two) |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4076 { |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4077 int one_unused = (one == NULL || one->result == NFA_PIM_UNUSED); |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4078 int two_unused = (two == NULL || two->result == NFA_PIM_UNUSED); |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4079 |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4080 if (one_unused) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4081 /* one is unused: equal when two is also unused */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4082 return two_unused; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4083 if (two_unused) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4084 /* one is used and two is not: not equal */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4085 return FALSE; |
5298 | 4086 /* compare the state id */ |
4087 if (one->state->id != two->state->id) | |
4088 return FALSE; | |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4089 /* compare the position */ |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4090 if (REG_MULTI) |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4091 return one->end.pos.lnum == two->end.pos.lnum |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4092 && one->end.pos.col == two->end.pos.col; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4093 return one->end.ptr == two->end.ptr; |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4094 } |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4095 |
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4096 /* |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4097 * Return TRUE if "state" leads to a NFA_MATCH without advancing the input. |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4098 */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4099 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4100 match_follows(nfa_state_T *startstate, int depth) |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4101 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4102 nfa_state_T *state = startstate; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4103 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4104 /* avoid too much recursion */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4105 if (depth > 10) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4106 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4107 |
5184
c6dd0c545e5c
updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents:
5074
diff
changeset
|
4108 while (state != NULL) |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4109 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4110 switch (state->c) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4111 { |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4112 case NFA_MATCH: |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4113 case NFA_MCLOSE: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4114 case NFA_END_INVISIBLE: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4115 case NFA_END_INVISIBLE_NEG: |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4116 case NFA_END_PATTERN: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4117 return TRUE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4118 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4119 case NFA_SPLIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4120 return match_follows(state->out, depth + 1) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4121 || match_follows(state->out1, depth + 1); |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4122 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4123 case NFA_START_INVISIBLE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4124 case NFA_START_INVISIBLE_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4125 case NFA_START_INVISIBLE_BEFORE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4126 case NFA_START_INVISIBLE_BEFORE_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4127 case NFA_START_INVISIBLE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4128 case NFA_START_INVISIBLE_NEG_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4129 case NFA_START_INVISIBLE_BEFORE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4130 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4131 case NFA_COMPOSING: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4132 /* skip ahead to next state */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4133 state = state->out1->out; |
5184
c6dd0c545e5c
updated for version 7.4a.018
Bram Moolenaar <bram@vim.org>
parents:
5074
diff
changeset
|
4134 continue; |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4135 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4136 case NFA_ANY: |
5901 | 4137 case NFA_ANY_COMPOSING: |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4138 case NFA_IDENT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4139 case NFA_SIDENT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4140 case NFA_KWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4141 case NFA_SKWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4142 case NFA_FNAME: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4143 case NFA_SFNAME: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4144 case NFA_PRINT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4145 case NFA_SPRINT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4146 case NFA_WHITE: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4147 case NFA_NWHITE: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4148 case NFA_DIGIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4149 case NFA_NDIGIT: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4150 case NFA_HEX: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4151 case NFA_NHEX: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4152 case NFA_OCTAL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4153 case NFA_NOCTAL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4154 case NFA_WORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4155 case NFA_NWORD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4156 case NFA_HEAD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4157 case NFA_NHEAD: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4158 case NFA_ALPHA: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4159 case NFA_NALPHA: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4160 case NFA_LOWER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4161 case NFA_NLOWER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4162 case NFA_UPPER: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4163 case NFA_NUPPER: |
5296 | 4164 case NFA_LOWER_IC: |
4165 case NFA_NLOWER_IC: | |
4166 case NFA_UPPER_IC: | |
4167 case NFA_NUPPER_IC: | |
4809
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4168 case NFA_START_COLL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4169 case NFA_START_NEG_COLL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4170 case NFA_NEWL: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4171 /* state will advance input */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4172 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4173 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4174 default: |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4175 if (state->c > 0) |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4176 /* state will advance input */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4177 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4178 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4179 /* Others: zero-width or possibly zero-width, might still find |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4180 * a match at the same position, keep looking. */ |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4181 break; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4182 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4183 state = state->out; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4184 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4185 return FALSE; |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4186 } |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4187 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4188 |
4d7e3df04256
updated for version 7.3.1151
Bram Moolenaar <bram@vim.org>
parents:
4807
diff
changeset
|
4189 /* |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4190 * Return TRUE if "state" is already in list "l". |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4191 */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4192 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4193 state_in_list( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4194 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4195 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4196 regsubs_T *subs) /* pointers to subexpressions */ |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4197 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4198 if (state->lastlist[nfa_ll_index] == l->id) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4199 { |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4200 if (!nfa_has_backref || has_state_with_pos(l, state, subs, NULL)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4201 return TRUE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4202 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4203 return FALSE; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4204 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4205 |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4206 /* |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4207 * Add "state" and possibly what follows to state list ".". |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4208 * Returns "subs_arg", possibly copied into temp_subs. |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4209 */ |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4210 static regsubs_T * |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4211 addstate( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4212 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4213 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4214 regsubs_T *subs_arg, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4215 nfa_pim_T *pim, /* postponed look-behind match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4216 int off) /* byte offset, when -1 go to next line */ |
4444 | 4217 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4218 int subidx; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4219 nfa_thread_T *thread; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4220 lpos_T save_lpos; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4221 int save_in_use; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4222 char_u *save_ptr; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4223 int i; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4224 regsub_T *sub; |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4225 regsubs_T *subs = subs_arg; |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4226 static regsubs_T temp_subs; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4227 #ifdef ENABLE_LOG |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4228 int did_print = FALSE; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4229 #endif |
4444 | 4230 |
4231 switch (state->c) | |
4232 { | |
4233 case NFA_NCLOSE: | |
4234 case NFA_MCLOSE: | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4235 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4236 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4237 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4238 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4239 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4240 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4241 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4242 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4243 case NFA_MCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4244 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4245 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4246 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4247 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4248 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4249 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4250 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4251 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4252 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4253 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4254 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4255 #endif |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4256 case NFA_MOPEN: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
4257 case NFA_ZEND: |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4258 case NFA_SPLIT: |
5370 | 4259 case NFA_EMPTY: |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4260 /* These nodes are not added themselves but their "out" and/or |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4261 * "out1" may be added below. */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4262 break; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4263 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4264 case NFA_BOL: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4265 case NFA_BOF: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4266 /* "^" won't match past end-of-line, don't bother trying. |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4267 * Except when at the end of the line, or when we are going to the |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4268 * next line for a look-behind match. */ |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4269 if (reginput > regline |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4270 && *reginput != NUL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4271 && (nfa_endp == NULL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4272 || !REG_MULTI |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4273 || reglnum == nfa_endp->se_u.pos.lnum)) |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4274 goto skip_add; |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4275 /* FALLTHROUGH */ |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4276 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4277 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4278 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4279 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4280 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4281 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4282 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4283 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4284 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4285 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4286 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4287 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4288 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4289 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4290 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4291 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4292 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4293 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4294 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4295 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4296 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4297 #endif |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4298 case NFA_NOPEN: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
4299 case NFA_ZSTART: |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4300 /* These nodes need to be added so that we can bail out when it |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4301 * was added to this list before at the same position to avoid an |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
4302 * endless loop for "\(\)*" */ |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
4303 |
4444 | 4304 default: |
5502 | 4305 if (state->lastlist[nfa_ll_index] == l->id && state->c != NFA_SKIP) |
4444 | 4306 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4307 /* This state is already in the list, don't add it again, |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4308 * unless it is an MOPEN that is used for a backreference or |
5895 | 4309 * when there is a PIM. For NFA_MATCH check the position, |
4310 * lower position is preferred. */ | |
4311 if (!nfa_has_backref && pim == NULL && !l->has_pim | |
4312 && state->c != NFA_MATCH) | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4313 { |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4314 skip_add: |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4315 #ifdef ENABLE_LOG |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4316 nfa_set_code(state->c); |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4317 fprintf(log_fd, "> Not adding state %d to list %d. char %d: %s\n", |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4318 abs(state->id), l->id, state->c, code); |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4319 #endif |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4320 return subs; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4321 } |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4322 |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4323 /* Do not add the state again when it exists with the same |
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4324 * positions. */ |
5212
2741b46e96bf
updated for version 7.4a.032
Bram Moolenaar <bram@vim.org>
parents:
5210
diff
changeset
|
4325 if (has_state_with_pos(l, state, subs, pim)) |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
4326 goto skip_add; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4327 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4328 |
5006
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4329 /* When there are backreferences or PIMs the number of states may |
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4330 * be (a lot) bigger than anticipated. */ |
f451d60ab8ec
updated for version 7.3.1247
Bram Moolenaar <bram@vim.org>
parents:
4997
diff
changeset
|
4331 if (l->n == l->len) |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4332 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4333 int newlen = l->len * 3 / 2 + 50; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4334 |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4335 if (subs != &temp_subs) |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4336 { |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4337 /* "subs" may point into the current array, need to make a |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4338 * copy before it becomes invalid. */ |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4339 copy_sub(&temp_subs.norm, &subs->norm); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4340 #ifdef FEAT_SYN_HL |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4341 if (nfa_has_zsubexpr) |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4342 copy_sub(&temp_subs.synt, &subs->synt); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4343 #endif |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4344 subs = &temp_subs; |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4345 } |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4346 |
6594 | 4347 /* TODO: check for vim_realloc() returning NULL. */ |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4348 l->t = vim_realloc(l->t, newlen * sizeof(nfa_thread_T)); |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4349 l->len = newlen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4350 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4351 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4352 /* add the state to the list */ |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4353 state->lastlist[nfa_ll_index] = l->id; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4354 thread = &l->t[l->n++]; |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4355 thread->state = state; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4356 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4357 thread->pim.result = NFA_PIM_UNUSED; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4358 else |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4359 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4360 copy_pim(&thread->pim, pim); |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4361 l->has_pim = TRUE; |
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
4362 } |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4363 copy_sub(&thread->subs.norm, &subs->norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4364 #ifdef FEAT_SYN_HL |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4365 if (nfa_has_zsubexpr) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4366 copy_sub(&thread->subs.synt, &subs->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4367 #endif |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4368 #ifdef ENABLE_LOG |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4369 report_state("Adding", &thread->subs.norm, state, l->id, pim); |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4370 did_print = TRUE; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4371 #endif |
4444 | 4372 } |
4373 | |
4374 #ifdef ENABLE_LOG | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
4375 if (!did_print) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4376 report_state("Processing", &subs->norm, state, l->id, pim); |
4444 | 4377 #endif |
4378 switch (state->c) | |
4379 { | |
4380 case NFA_MATCH: | |
4381 break; | |
4382 | |
4383 case NFA_SPLIT: | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4384 /* order matters here */ |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4385 subs = addstate(l, state->out, subs, pim, off); |
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4386 subs = addstate(l, state->out1, subs, pim, off); |
4444 | 4387 break; |
4388 | |
5370 | 4389 case NFA_EMPTY: |
4444 | 4390 case NFA_NOPEN: |
4391 case NFA_NCLOSE: | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4392 subs = addstate(l, state->out, subs, pim, off); |
4444 | 4393 break; |
4394 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4395 case NFA_MOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4396 case NFA_MOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4397 case NFA_MOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4398 case NFA_MOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4399 case NFA_MOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4400 case NFA_MOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4401 case NFA_MOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4402 case NFA_MOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4403 case NFA_MOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4404 case NFA_MOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4405 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4406 case NFA_ZOPEN: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4407 case NFA_ZOPEN1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4408 case NFA_ZOPEN2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4409 case NFA_ZOPEN3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4410 case NFA_ZOPEN4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4411 case NFA_ZOPEN5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4412 case NFA_ZOPEN6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4413 case NFA_ZOPEN7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4414 case NFA_ZOPEN8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4415 case NFA_ZOPEN9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4416 #endif |
4444 | 4417 case NFA_ZSTART: |
4418 if (state->c == NFA_ZSTART) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4419 { |
4444 | 4420 subidx = 0; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4421 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4422 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4423 #ifdef FEAT_SYN_HL |
5300 | 4424 else if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4425 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4426 subidx = state->c - NFA_ZOPEN; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4427 sub = &subs->synt; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4428 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4429 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4430 else |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4431 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4432 subidx = state->c - NFA_MOPEN; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4433 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4434 } |
4444 | 4435 |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4436 /* avoid compiler warnings */ |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4437 save_ptr = NULL; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4438 save_lpos.lnum = 0; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4439 save_lpos.col = 0; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4440 |
4815
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4441 /* Set the position (with "off" added) in the subexpression. Save |
6419ee8098c8
updated for version 7.3.1154
Bram Moolenaar <bram@vim.org>
parents:
4813
diff
changeset
|
4442 * and restore it when it was in use. Otherwise fill any gap. */ |
4444 | 4443 if (REG_MULTI) |
4444 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4445 if (subidx < sub->in_use) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4446 { |
6547 | 4447 save_lpos.lnum = sub->list.multi[subidx].start_lnum; |
4448 save_lpos.col = sub->list.multi[subidx].start_col; | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4449 save_in_use = -1; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4450 } |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4451 else |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4452 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4453 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4454 for (i = sub->in_use; i < subidx; ++i) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4455 { |
6547 | 4456 sub->list.multi[i].start_lnum = -1; |
4457 sub->list.multi[i].end_lnum = -1; | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4458 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4459 sub->in_use = subidx + 1; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4460 } |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4461 if (off == -1) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4462 { |
6547 | 4463 sub->list.multi[subidx].start_lnum = reglnum + 1; |
4464 sub->list.multi[subidx].start_col = 0; | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4465 } |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4466 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4467 { |
6547 | 4468 sub->list.multi[subidx].start_lnum = reglnum; |
4469 sub->list.multi[subidx].start_col = | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4470 (colnr_T)(reginput - regline + off); |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4471 } |
7152
cbdc02d71a18
commit https://github.com/vim/vim/commit/c2b717ebd6719e722dcb5f10e4c74033a53ff7c7
Christian Brabandt <cb@256bit.org>
parents:
6914
diff
changeset
|
4472 sub->list.multi[subidx].end_lnum = -1; |
4444 | 4473 } |
4474 else | |
4475 { | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4476 if (subidx < sub->in_use) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4477 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4478 save_ptr = sub->list.line[subidx].start; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4479 save_in_use = -1; |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4480 } |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4481 else |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4482 { |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4483 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4484 for (i = sub->in_use; i < subidx; ++i) |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4485 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4486 sub->list.line[i].start = NULL; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4487 sub->list.line[i].end = NULL; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4488 } |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4489 sub->in_use = subidx + 1; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4490 } |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4491 sub->list.line[subidx].start = reginput + off; |
4444 | 4492 } |
4493 | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4494 subs = addstate(l, state->out, subs, pim, off); |
5300 | 4495 /* "subs" may have changed, need to set "sub" again */ |
4496 #ifdef FEAT_SYN_HL | |
4497 if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) | |
4498 sub = &subs->synt; | |
4499 else | |
4500 #endif | |
4501 sub = &subs->norm; | |
4444 | 4502 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4503 if (save_in_use == -1) |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4504 { |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4505 if (REG_MULTI) |
6547 | 4506 { |
4507 sub->list.multi[subidx].start_lnum = save_lpos.lnum; | |
4508 sub->list.multi[subidx].start_col = save_lpos.col; | |
4509 } | |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4510 else |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4511 sub->list.line[subidx].start = save_ptr; |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4512 } |
4444 | 4513 else |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4514 sub->in_use = save_in_use; |
4444 | 4515 break; |
4516 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4517 case NFA_MCLOSE: |
5336 | 4518 if (nfa_has_zend && (REG_MULTI |
6547 | 4519 ? subs->norm.list.multi[0].end_lnum >= 0 |
5336 | 4520 : subs->norm.list.line[0].end != NULL)) |
4444 | 4521 { |
5336 | 4522 /* Do not overwrite the position set by \ze. */ |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4523 subs = addstate(l, state->out, subs, pim, off); |
4444 | 4524 break; |
4525 } | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4526 case NFA_MCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4527 case NFA_MCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4528 case NFA_MCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4529 case NFA_MCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4530 case NFA_MCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4531 case NFA_MCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4532 case NFA_MCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4533 case NFA_MCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4534 case NFA_MCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4535 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4536 case NFA_ZCLOSE: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4537 case NFA_ZCLOSE1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4538 case NFA_ZCLOSE2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4539 case NFA_ZCLOSE3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4540 case NFA_ZCLOSE4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4541 case NFA_ZCLOSE5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4542 case NFA_ZCLOSE6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4543 case NFA_ZCLOSE7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4544 case NFA_ZCLOSE8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4545 case NFA_ZCLOSE9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4546 #endif |
4444 | 4547 case NFA_ZEND: |
4548 if (state->c == NFA_ZEND) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4549 { |
4444 | 4550 subidx = 0; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4551 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4552 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4553 #ifdef FEAT_SYN_HL |
5300 | 4554 else if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4555 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4556 subidx = state->c - NFA_ZCLOSE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4557 sub = &subs->synt; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4558 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4559 #endif |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4560 else |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4561 { |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4562 subidx = state->c - NFA_MCLOSE; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4563 sub = &subs->norm; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4564 } |
4444 | 4565 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4566 /* We don't fill in gaps here, there must have been an MOPEN that |
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4567 * has done that. */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4568 save_in_use = sub->in_use; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4569 if (sub->in_use <= subidx) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4570 sub->in_use = subidx + 1; |
4444 | 4571 if (REG_MULTI) |
4572 { | |
6547 | 4573 save_lpos.lnum = sub->list.multi[subidx].end_lnum; |
4574 save_lpos.col = sub->list.multi[subidx].end_col; | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4575 if (off == -1) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4576 { |
6547 | 4577 sub->list.multi[subidx].end_lnum = reglnum + 1; |
4578 sub->list.multi[subidx].end_col = 0; | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4579 } |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4580 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4581 { |
6547 | 4582 sub->list.multi[subidx].end_lnum = reglnum; |
4583 sub->list.multi[subidx].end_col = | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
4584 (colnr_T)(reginput - regline + off); |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
4585 } |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4586 /* avoid compiler warnings */ |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4587 save_ptr = NULL; |
4444 | 4588 } |
4589 else | |
4590 { | |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4591 save_ptr = sub->list.line[subidx].end; |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4592 sub->list.line[subidx].end = reginput + off; |
5210
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4593 /* avoid compiler warnings */ |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4594 save_lpos.lnum = 0; |
839ebe7c1b2f
updated for version 7.4a.031
Bram Moolenaar <bram@vim.org>
parents:
5188
diff
changeset
|
4595 save_lpos.col = 0; |
4444 | 4596 } |
4597 | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4598 subs = addstate(l, state->out, subs, pim, off); |
5300 | 4599 /* "subs" may have changed, need to set "sub" again */ |
4600 #ifdef FEAT_SYN_HL | |
4601 if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) | |
4602 sub = &subs->synt; | |
4603 else | |
4604 #endif | |
4605 sub = &subs->norm; | |
4444 | 4606 |
4607 if (REG_MULTI) | |
6547 | 4608 { |
4609 sub->list.multi[subidx].end_lnum = save_lpos.lnum; | |
4610 sub->list.multi[subidx].end_col = save_lpos.col; | |
4611 } | |
4444 | 4612 else |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4613 sub->list.line[subidx].end = save_ptr; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4614 sub->in_use = save_in_use; |
4444 | 4615 break; |
4616 } | |
5074
1cacf785299e
updated for version 7.3.1280
Bram Moolenaar <bram@vim.org>
parents:
5058
diff
changeset
|
4617 return subs; |
4444 | 4618 } |
4619 | |
4620 /* | |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4621 * Like addstate(), but the new state(s) are put at position "*ip". |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4622 * Used for zero-width matches, next state to use is the added one. |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4623 * This makes sure the order of states to be tried does not change, which |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4624 * matters for alternatives. |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4625 */ |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4626 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4627 addstate_here( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4628 nfa_list_T *l, /* runtime state list */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4629 nfa_state_T *state, /* state to update */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4630 regsubs_T *subs, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4631 nfa_pim_T *pim, /* postponed look-behind match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4632 int *ip) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4633 { |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4634 int tlen = l->n; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4635 int count; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4636 int listidx = *ip; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4637 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4638 /* first add the state(s) at the end, so that we know how many there are */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4639 addstate(l, state, subs, pim, 0); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4640 |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4641 /* when "*ip" was at the end of the list, nothing to do */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4642 if (listidx + 1 == tlen) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4643 return; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4644 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4645 /* re-order to put the new state at the current position */ |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4646 count = l->n - tlen; |
4924
6ae32a64e153
updated for version 7.3.1207
Bram Moolenaar <bram@vim.org>
parents:
4897
diff
changeset
|
4647 if (count == 0) |
6ae32a64e153
updated for version 7.3.1207
Bram Moolenaar <bram@vim.org>
parents:
4897
diff
changeset
|
4648 return; /* no state got added */ |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4649 if (count == 1) |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4650 { |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4651 /* overwrite the current state */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4652 l->t[listidx] = l->t[l->n - 1]; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4653 } |
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
4654 else if (count > 1) |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4655 { |
5058
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4656 if (l->n + count - 1 >= l->len) |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4657 { |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4658 /* not enough space to move the new states, reallocate the list |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4659 * and move the states to the right position */ |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4660 nfa_thread_T *newl; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4661 |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4662 l->len = l->len * 3 / 2 + 50; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4663 newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4664 if (newl == NULL) |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4665 return; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4666 mch_memmove(&(newl[0]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4667 &(l->t[0]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4668 sizeof(nfa_thread_T) * listidx); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4669 mch_memmove(&(newl[listidx]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4670 &(l->t[l->n - count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4671 sizeof(nfa_thread_T) * count); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4672 mch_memmove(&(newl[listidx + count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4673 &(l->t[listidx + 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4674 sizeof(nfa_thread_T) * (l->n - count - listidx - 1)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4675 vim_free(l->t); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4676 l->t = newl; |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4677 } |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4678 else |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4679 { |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4680 /* make space for new states, then move them from the |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4681 * end to the current position */ |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4682 mch_memmove(&(l->t[listidx + count]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4683 &(l->t[listidx + 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4684 sizeof(nfa_thread_T) * (l->n - listidx - 1)); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4685 mch_memmove(&(l->t[listidx]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4686 &(l->t[l->n - 1]), |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4687 sizeof(nfa_thread_T) * count); |
a00cd1839ac4
updated for version 7.3.1272
Bram Moolenaar <bram@vim.org>
parents:
5029
diff
changeset
|
4688 } |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4689 } |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4690 --l->n; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
4691 *ip = listidx - 1; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4692 } |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4693 |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
4694 /* |
4444 | 4695 * Check character class "class" against current character c. |
4696 */ | |
4697 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4698 check_char_class(int class, int c) |
4444 | 4699 { |
4700 switch (class) | |
4701 { | |
4702 case NFA_CLASS_ALNUM: | |
4464 | 4703 if (c >= 1 && c <= 255 && isalnum(c)) |
4444 | 4704 return OK; |
4705 break; | |
4706 case NFA_CLASS_ALPHA: | |
4464 | 4707 if (c >= 1 && c <= 255 && isalpha(c)) |
4444 | 4708 return OK; |
4709 break; | |
4710 case NFA_CLASS_BLANK: | |
4711 if (c == ' ' || c == '\t') | |
4712 return OK; | |
4713 break; | |
4714 case NFA_CLASS_CNTRL: | |
4464 | 4715 if (c >= 1 && c <= 255 && iscntrl(c)) |
4444 | 4716 return OK; |
4717 break; | |
4718 case NFA_CLASS_DIGIT: | |
4719 if (VIM_ISDIGIT(c)) | |
4720 return OK; | |
4721 break; | |
4722 case NFA_CLASS_GRAPH: | |
4464 | 4723 if (c >= 1 && c <= 255 && isgraph(c)) |
4444 | 4724 return OK; |
4725 break; | |
4726 case NFA_CLASS_LOWER: | |
4727 if (MB_ISLOWER(c)) | |
4728 return OK; | |
4729 break; | |
4730 case NFA_CLASS_PRINT: | |
4731 if (vim_isprintc(c)) | |
4732 return OK; | |
4733 break; | |
4734 case NFA_CLASS_PUNCT: | |
4464 | 4735 if (c >= 1 && c <= 255 && ispunct(c)) |
4444 | 4736 return OK; |
4737 break; | |
4738 case NFA_CLASS_SPACE: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
4739 if ((c >= 9 && c <= 13) || (c == ' ')) |
4444 | 4740 return OK; |
4741 break; | |
4742 case NFA_CLASS_UPPER: | |
4743 if (MB_ISUPPER(c)) | |
4744 return OK; | |
4745 break; | |
4746 case NFA_CLASS_XDIGIT: | |
4747 if (vim_isxdigit(c)) | |
4748 return OK; | |
4749 break; | |
4750 case NFA_CLASS_TAB: | |
4751 if (c == '\t') | |
4752 return OK; | |
4753 break; | |
4754 case NFA_CLASS_RETURN: | |
4755 if (c == '\r') | |
4756 return OK; | |
4757 break; | |
4758 case NFA_CLASS_BACKSPACE: | |
4759 if (c == '\b') | |
4760 return OK; | |
4761 break; | |
4762 case NFA_CLASS_ESCAPE: | |
4763 if (c == '\033') | |
4764 return OK; | |
4765 break; | |
4766 | |
4767 default: | |
4768 /* should not be here :P */ | |
5511 | 4769 EMSGN(_(e_ill_char_class), class); |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
4770 return FAIL; |
4444 | 4771 } |
4772 return FAIL; | |
4773 } | |
4774 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4775 /* |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4776 * Check for a match with subexpression "subidx". |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4777 * Return TRUE if it matches. |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4778 */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4779 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4780 match_backref( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4781 regsub_T *sub, /* pointers to subexpressions */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4782 int subidx, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4783 int *bytelen) /* out: length of match in bytes */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4784 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4785 int len; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4786 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4787 if (sub->in_use <= subidx) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4788 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4789 retempty: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4790 /* backref was not set, match an empty string */ |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4791 *bytelen = 0; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4792 return TRUE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4793 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4794 |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4795 if (REG_MULTI) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4796 { |
6547 | 4797 if (sub->list.multi[subidx].start_lnum < 0 |
4798 || sub->list.multi[subidx].end_lnum < 0) | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4799 goto retempty; |
6547 | 4800 if (sub->list.multi[subidx].start_lnum == reglnum |
4801 && sub->list.multi[subidx].end_lnum == reglnum) | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4802 { |
6547 | 4803 len = sub->list.multi[subidx].end_col |
4804 - sub->list.multi[subidx].start_col; | |
4805 if (cstrncmp(regline + sub->list.multi[subidx].start_col, | |
4891
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4806 reginput, &len) == 0) |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4807 { |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4808 *bytelen = len; |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4809 return TRUE; |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4810 } |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4811 } |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4812 else |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4813 { |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4814 if (match_with_backref( |
6547 | 4815 sub->list.multi[subidx].start_lnum, |
4816 sub->list.multi[subidx].start_col, | |
4817 sub->list.multi[subidx].end_lnum, | |
4818 sub->list.multi[subidx].end_col, | |
4891
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4819 bytelen) == RA_MATCH) |
4c42efb4c098
updated for version 7.3.1191
Bram Moolenaar <bram@vim.org>
parents:
4887
diff
changeset
|
4820 return TRUE; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4821 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4822 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4823 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4824 { |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4825 if (sub->list.line[subidx].start == NULL |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4826 || sub->list.line[subidx].end == NULL) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4827 goto retempty; |
4577
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4828 len = (int)(sub->list.line[subidx].end - sub->list.line[subidx].start); |
b22bff1a6af8
updated for version 7.3.1036
Bram Moolenaar <bram@vim.org>
parents:
4573
diff
changeset
|
4829 if (cstrncmp(sub->list.line[subidx].start, reginput, &len) == 0) |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4830 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4831 *bytelen = len; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4832 return TRUE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4833 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4834 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4835 return FALSE; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4836 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
4837 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4838 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4839 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
4840 static int match_zref(int subidx, int *bytelen); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4841 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4842 /* |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4843 * Check for a match with \z subexpression "subidx". |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4844 * Return TRUE if it matches. |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4845 */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4846 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4847 match_zref( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4848 int subidx, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4849 int *bytelen) /* out: length of match in bytes */ |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4850 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4851 int len; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4852 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4853 cleanup_zsubexpr(); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4854 if (re_extmatch_in == NULL || re_extmatch_in->matches[subidx] == NULL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4855 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4856 /* backref was not set, match an empty string */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4857 *bytelen = 0; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4858 return TRUE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4859 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4860 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4861 len = (int)STRLEN(re_extmatch_in->matches[subidx]); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4862 if (cstrncmp(re_extmatch_in->matches[subidx], reginput, &len) == 0) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4863 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4864 *bytelen = len; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4865 return TRUE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4866 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4867 return FALSE; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4868 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4869 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
4870 |
4444 | 4871 /* |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4872 * Save list IDs for all NFA states of "prog" into "list". |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4873 * Also reset the IDs to zero. |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4874 * Only used for the recursive value lastlist[1]. |
4444 | 4875 */ |
4876 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4877 nfa_save_listids(nfa_regprog_T *prog, int *list) |
4444 | 4878 { |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4879 int i; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4880 nfa_state_T *p; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4881 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4882 /* Order in the list is reverse, it's a bit faster that way. */ |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4883 p = &prog->state[0]; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4884 for (i = prog->nstate; --i >= 0; ) |
4444 | 4885 { |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4886 list[i] = p->lastlist[1]; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4887 p->lastlist[1] = 0; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4888 ++p; |
4444 | 4889 } |
4890 } | |
4891 | |
4892 /* | |
4893 * Restore list IDs from "list" to all NFA states. | |
4894 */ | |
4895 static void | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4896 nfa_restore_listids(nfa_regprog_T *prog, int *list) |
4444 | 4897 { |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4898 int i; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4899 nfa_state_T *p; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4900 |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4901 p = &prog->state[0]; |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4902 for (i = prog->nstate; --i >= 0; ) |
4444 | 4903 { |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4904 p->lastlist[1] = list[i]; |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
4905 ++p; |
4444 | 4906 } |
4907 } | |
4908 | |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4909 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4910 nfa_re_num_cmp(long_u val, int op, long_u pos) |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4911 { |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4912 if (op == 1) return pos > val; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4913 if (op == 2) return pos < val; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4914 return val == pos; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4915 } |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
4916 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
4917 static int recursive_regmatch(nfa_state_T *state, nfa_pim_T *pim, nfa_regprog_T *prog, regsubs_T *submatch, regsubs_T *m, int **listids); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
4918 static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *submatch, regsubs_T *m); |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
4919 |
4444 | 4920 /* |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4921 * Recursively call nfa_regmatch() |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4922 * "pim" is NULL or contains info about a Postponed Invisible Match (start |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4923 * position). |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4924 */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4925 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4926 recursive_regmatch( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4927 nfa_state_T *state, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4928 nfa_pim_T *pim, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4929 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4930 regsubs_T *submatch, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4931 regsubs_T *m, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
4932 int **listids) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4933 { |
4887
dc78a26f6f64
updated for version 7.3.1189
Bram Moolenaar <bram@vim.org>
parents:
4879
diff
changeset
|
4934 int save_reginput_col = (int)(reginput - regline); |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4935 int save_reglnum = reglnum; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4936 int save_nfa_match = nfa_match; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4937 int save_nfa_listid = nfa_listid; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4938 save_se_T *save_nfa_endp = nfa_endp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4939 save_se_T endpos; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4940 save_se_T *endposp = NULL; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4941 int result; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
4942 int need_restore = FALSE; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4943 |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4944 if (pim != NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4945 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4946 /* start at the position where the postponed match was */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4947 if (REG_MULTI) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4948 reginput = regline + pim->end.pos.col; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4949 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4950 reginput = pim->end.ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4951 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4952 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
4953 if (state->c == NFA_START_INVISIBLE_BEFORE |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4954 || state->c == NFA_START_INVISIBLE_BEFORE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4955 || state->c == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
4956 || state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4957 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4958 /* The recursive match must end at the current position. When "pim" is |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4959 * not NULL it specifies the current position. */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4960 endposp = &endpos; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4961 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4962 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4963 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4964 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4965 endpos.se_u.pos.col = (int)(reginput - regline); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4966 endpos.se_u.pos.lnum = reglnum; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4967 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4968 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4969 endpos.se_u.pos = pim->end.pos; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4970 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4971 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4972 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4973 if (pim == NULL) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4974 endpos.se_u.ptr = reginput; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4975 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4976 endpos.se_u.ptr = pim->end.ptr; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
4977 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4978 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4979 /* Go back the specified number of bytes, or as far as the |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4980 * start of the previous line, to try matching "\@<=" or |
5188
fa76be660fa9
updated for version 7.4a.020
Bram Moolenaar <bram@vim.org>
parents:
5184
diff
changeset
|
4981 * not matching "\@<!". This is very inefficient, limit the number of |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
4982 * bytes if possible. */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4983 if (state->val <= 0) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4984 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4985 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4986 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4987 regline = reg_getline(--reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4988 if (regline == NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4989 /* can't go before the first line */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4990 regline = reg_getline(++reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4991 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4992 reginput = regline; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4993 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4994 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4995 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4996 if (REG_MULTI && (int)(reginput - regline) < state->val) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4997 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4998 /* Not enough bytes in this line, go to end of |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
4999 * previous line. */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5000 regline = reg_getline(--reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5001 if (regline == NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5002 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5003 /* can't go before the first line */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5004 regline = reg_getline(++reglnum); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5005 reginput = regline; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5006 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5007 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5008 reginput = regline + STRLEN(regline); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5009 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5010 if ((int)(reginput - regline) >= state->val) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5011 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5012 reginput -= state->val; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5013 #ifdef FEAT_MBYTE |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5014 if (has_mbyte) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5015 reginput -= mb_head_off(regline, reginput); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5016 #endif |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5017 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5018 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5019 reginput = regline; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5020 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5021 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5022 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5023 #ifdef ENABLE_LOG |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5024 if (log_fd != stderr) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5025 fclose(log_fd); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5026 log_fd = NULL; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5027 #endif |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5028 /* Have to clear the lastlist field of the NFA nodes, so that |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5029 * nfa_regmatch() and addstate() can run properly after recursion. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5030 if (nfa_ll_index == 1) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5031 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5032 /* Already calling nfa_regmatch() recursively. Save the lastlist[1] |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5033 * values and clear them. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5034 if (*listids == NULL) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5035 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5036 *listids = (int *)lalloc(sizeof(int) * nstate, TRUE); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5037 if (*listids == NULL) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5038 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5039 EMSG(_("E878: (NFA) Could not allocate memory for branch traversal!")); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5040 return 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5041 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5042 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5043 nfa_save_listids(prog, *listids); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5044 need_restore = TRUE; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5045 /* any value of nfa_listid will do */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5046 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5047 else |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5048 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5049 /* First recursive nfa_regmatch() call, switch to the second lastlist |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5050 * entry. Make sure nfa_listid is different from a previous recursive |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5051 * call, because some states may still have this ID. */ |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5052 ++nfa_ll_index; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5053 if (nfa_listid <= nfa_alt_listid) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5054 nfa_listid = nfa_alt_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5055 } |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5056 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5057 /* Call nfa_regmatch() to check if the current concat matches at this |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5058 * position. The concat ends with the node NFA_END_INVISIBLE */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5059 nfa_endp = endposp; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5060 result = nfa_regmatch(prog, state->out, submatch, m); |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5061 |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5062 if (need_restore) |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5063 nfa_restore_listids(prog, *listids); |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5064 else |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5065 { |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5066 --nfa_ll_index; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5067 nfa_alt_listid = nfa_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5068 } |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5069 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5070 /* restore position in input text */ |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5071 reglnum = save_reglnum; |
4877
9e36c6b1ebf4
updated for version 7.3.1184
Bram Moolenaar <bram@vim.org>
parents:
4845
diff
changeset
|
5072 if (REG_MULTI) |
9e36c6b1ebf4
updated for version 7.3.1184
Bram Moolenaar <bram@vim.org>
parents:
4845
diff
changeset
|
5073 regline = reg_getline(reglnum); |
4887
dc78a26f6f64
updated for version 7.3.1189
Bram Moolenaar <bram@vim.org>
parents:
4879
diff
changeset
|
5074 reginput = regline + save_reginput_col; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5075 nfa_match = save_nfa_match; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5076 nfa_endp = save_nfa_endp; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5077 nfa_listid = save_nfa_listid; |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5078 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5079 #ifdef ENABLE_LOG |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5080 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5081 if (log_fd != NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5082 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5083 fprintf(log_fd, "****************************\n"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5084 fprintf(log_fd, "FINISHED RUNNING nfa_regmatch() recursively\n"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5085 fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5086 fprintf(log_fd, "****************************\n"); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5087 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5088 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5089 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5090 EMSG(_("Could not open temporary log file for writing, displaying on stderr ... ")); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5091 log_fd = stderr; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5092 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5093 #endif |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5094 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5095 return result; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5096 } |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5097 |
7805
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5098 static int skip_to_start(int c, colnr_T *colp); |
0b6c37dd858d
commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents:
7258
diff
changeset
|
5099 static long find_match_text(colnr_T startcol, int regstart, char_u *match_text); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5100 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5101 /* |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5102 * Estimate the chance of a match with "state" failing. |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5103 * empty match: 0 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5104 * NFA_ANY: 1 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5105 * specific character: 99 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5106 */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5107 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5108 failure_chance(nfa_state_T *state, int depth) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5109 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5110 int c = state->c; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5111 int l, r; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5112 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5113 /* detect looping */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5114 if (depth > 4) |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5115 return 1; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5116 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5117 switch (c) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5118 { |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5119 case NFA_SPLIT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5120 if (state->out->c == NFA_SPLIT || state->out1->c == NFA_SPLIT) |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5121 /* avoid recursive stuff */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5122 return 1; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5123 /* two alternatives, use the lowest failure chance */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5124 l = failure_chance(state->out, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5125 r = failure_chance(state->out1, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5126 return l < r ? l : r; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5127 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5128 case NFA_ANY: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5129 /* matches anything, unlikely to fail */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5130 return 1; |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5131 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5132 case NFA_MATCH: |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5133 case NFA_MCLOSE: |
5901 | 5134 case NFA_ANY_COMPOSING: |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5135 /* empty match works always */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5136 return 0; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5137 |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5138 case NFA_START_INVISIBLE: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5139 case NFA_START_INVISIBLE_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5140 case NFA_START_INVISIBLE_NEG: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5141 case NFA_START_INVISIBLE_NEG_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5142 case NFA_START_INVISIBLE_BEFORE: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5143 case NFA_START_INVISIBLE_BEFORE_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5144 case NFA_START_INVISIBLE_BEFORE_NEG: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5145 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5146 case NFA_START_PATTERN: |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5147 /* recursive regmatch is expensive, use low failure chance */ |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5148 return 5; |
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5149 |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5150 case NFA_BOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5151 case NFA_EOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5152 case NFA_BOF: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5153 case NFA_EOF: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5154 case NFA_NEWL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5155 return 99; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5156 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5157 case NFA_BOW: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5158 case NFA_EOW: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5159 return 90; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5160 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5161 case NFA_MOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5162 case NFA_MOPEN1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5163 case NFA_MOPEN2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5164 case NFA_MOPEN3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5165 case NFA_MOPEN4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5166 case NFA_MOPEN5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5167 case NFA_MOPEN6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5168 case NFA_MOPEN7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5169 case NFA_MOPEN8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5170 case NFA_MOPEN9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5171 #ifdef FEAT_SYN_HL |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5172 case NFA_ZOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5173 case NFA_ZOPEN1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5174 case NFA_ZOPEN2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5175 case NFA_ZOPEN3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5176 case NFA_ZOPEN4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5177 case NFA_ZOPEN5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5178 case NFA_ZOPEN6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5179 case NFA_ZOPEN7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5180 case NFA_ZOPEN8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5181 case NFA_ZOPEN9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5182 case NFA_ZCLOSE: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5183 case NFA_ZCLOSE1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5184 case NFA_ZCLOSE2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5185 case NFA_ZCLOSE3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5186 case NFA_ZCLOSE4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5187 case NFA_ZCLOSE5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5188 case NFA_ZCLOSE6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5189 case NFA_ZCLOSE7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5190 case NFA_ZCLOSE8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5191 case NFA_ZCLOSE9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5192 #endif |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5193 case NFA_NOPEN: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5194 case NFA_MCLOSE1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5195 case NFA_MCLOSE2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5196 case NFA_MCLOSE3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5197 case NFA_MCLOSE4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5198 case NFA_MCLOSE5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5199 case NFA_MCLOSE6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5200 case NFA_MCLOSE7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5201 case NFA_MCLOSE8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5202 case NFA_MCLOSE9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5203 case NFA_NCLOSE: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5204 return failure_chance(state->out, depth + 1); |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5205 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5206 case NFA_BACKREF1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5207 case NFA_BACKREF2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5208 case NFA_BACKREF3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5209 case NFA_BACKREF4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5210 case NFA_BACKREF5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5211 case NFA_BACKREF6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5212 case NFA_BACKREF7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5213 case NFA_BACKREF8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5214 case NFA_BACKREF9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5215 #ifdef FEAT_SYN_HL |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5216 case NFA_ZREF1: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5217 case NFA_ZREF2: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5218 case NFA_ZREF3: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5219 case NFA_ZREF4: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5220 case NFA_ZREF5: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5221 case NFA_ZREF6: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5222 case NFA_ZREF7: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5223 case NFA_ZREF8: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5224 case NFA_ZREF9: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5225 #endif |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5226 /* backreferences don't match in many places */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5227 return 94; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5228 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5229 case NFA_LNUM_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5230 case NFA_LNUM_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5231 case NFA_COL_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5232 case NFA_COL_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5233 case NFA_VCOL_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5234 case NFA_VCOL_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5235 case NFA_MARK_GT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5236 case NFA_MARK_LT: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5237 case NFA_VISUAL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5238 /* before/after positions don't match very often */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5239 return 85; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5240 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5241 case NFA_LNUM: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5242 return 90; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5243 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5244 case NFA_CURSOR: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5245 case NFA_COL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5246 case NFA_VCOL: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5247 case NFA_MARK: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5248 /* specific positions rarely match */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5249 return 98; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5250 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5251 case NFA_COMPOSING: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5252 return 95; |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5253 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5254 default: |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5255 if (c > 0) |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5256 /* character match fails often */ |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5257 return 95; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5258 } |
4742
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5259 |
6a706ca7a889
updated for version 7.3.1118
Bram Moolenaar <bram@vim.org>
parents:
4740
diff
changeset
|
5260 /* something else, includes character classes */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5261 return 50; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5262 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5263 |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5264 /* |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5265 * Skip until the char "c" we know a match must start with. |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5266 */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5267 static int |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5268 skip_to_start(int c, colnr_T *colp) |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5269 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5270 char_u *s; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5271 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5272 /* Used often, do some work to avoid call overhead. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5273 if (!ireg_ic |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5274 #ifdef FEAT_MBYTE |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5275 && !has_mbyte |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5276 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5277 ) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5278 s = vim_strbyte(regline + *colp, c); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5279 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5280 s = cstrchr(regline + *colp, c); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5281 if (s == NULL) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5282 return FAIL; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5283 *colp = (int)(s - regline); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5284 return OK; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5285 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5286 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
5287 /* |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5288 * Check for a match with match_text. |
4807
3dbd251777de
updated for version 7.3.1150
Bram Moolenaar <bram@vim.org>
parents:
4805
diff
changeset
|
5289 * Called after skip_to_start() has found regstart. |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5290 * Returns zero for no match, 1 for a match. |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5291 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5292 static long |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5293 find_match_text(colnr_T startcol, int regstart, char_u *match_text) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5294 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5295 colnr_T col = startcol; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5296 int c1, c2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5297 int len1, len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5298 int match; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5299 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5300 for (;;) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5301 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5302 match = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5303 len2 = MB_CHAR2LEN(regstart); /* skip regstart */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5304 for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1)) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5305 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5306 c1 = PTR2CHAR(match_text + len1); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5307 c2 = PTR2CHAR(regline + col + len2); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5308 if (c1 != c2 && (!ireg_ic || MB_TOLOWER(c1) != MB_TOLOWER(c2))) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5309 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5310 match = FALSE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5311 break; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5312 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5313 len2 += MB_CHAR2LEN(c2); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5314 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5315 if (match |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5316 #ifdef FEAT_MBYTE |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5317 /* check that no composing char follows */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5318 && !(enc_utf8 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5319 && utf_iscomposing(PTR2CHAR(regline + col + len2))) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5320 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5321 ) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5322 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5323 cleanup_subexpr(); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5324 if (REG_MULTI) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5325 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5326 reg_startpos[0].lnum = reglnum; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5327 reg_startpos[0].col = col; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5328 reg_endpos[0].lnum = reglnum; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5329 reg_endpos[0].col = col + len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5330 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5331 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5332 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5333 reg_startp[0] = regline + col; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5334 reg_endp[0] = regline + col + len2; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5335 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5336 return 1L; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5337 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5338 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5339 /* Try finding regstart after the current match. */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5340 col += MB_CHAR2LEN(regstart); /* skip regstart */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5341 if (skip_to_start(regstart, &col) == FAIL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5342 break; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5343 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5344 return 0L; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5345 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5346 |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
5347 /* |
4444 | 5348 * Main matching routine. |
5349 * | |
5350 * Run NFA to determine whether it matches reginput. | |
5351 * | |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
5352 * When "nfa_endp" is not NULL it is a required end-of-match position. |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5353 * |
4444 | 5354 * Return TRUE if there is a match, FALSE otherwise. |
5372 | 5355 * When there is a match "submatch" contains the positions. |
4444 | 5356 * Note: Caller must ensure that: start != NULL. |
5357 */ | |
5358 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5359 nfa_regmatch( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5360 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5361 nfa_state_T *start, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5362 regsubs_T *submatch, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
5363 regsubs_T *m) |
4444 | 5364 { |
5365 int result; | |
6545 | 5366 size_t size = 0; |
4444 | 5367 int flag = 0; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5368 int go_to_nextline = FALSE; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5369 nfa_thread_T *t; |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5370 nfa_list_T list[2]; |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5371 int listidx; |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5372 nfa_list_T *thislist; |
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5373 nfa_list_T *nextlist; |
4444 | 5374 int *listids = NULL; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5375 nfa_state_T *add_state; |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5376 int add_here; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5377 int add_count; |
4819
8c4324e6f477
updated for version 7.3.1156
Bram Moolenaar <bram@vim.org>
parents:
4815
diff
changeset
|
5378 int add_off = 0; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5379 int toplevel = start->c == NFA_MOPEN; |
4460 | 5380 #ifdef NFA_REGEXP_DEBUG_LOG |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5381 FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); |
4444 | 5382 |
5383 if (debug == NULL) | |
5384 { | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5385 EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG); |
4444 | 5386 return FALSE; |
5387 } | |
5388 #endif | |
5310 | 5389 /* Some patterns may take a long time to match, especially when using |
5390 * recursive_regmatch(). Allow interrupting them with CTRL-C. */ | |
5391 fast_breakcheck(); | |
5392 if (got_int) | |
5393 return FALSE; | |
6573 | 5394 #ifdef FEAT_RELTIME |
5395 if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit)) | |
5396 return FALSE; | |
5397 #endif | |
5310 | 5398 |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
5399 nfa_match = FALSE; |
4444 | 5400 |
4563
e7016af0cbf9
updated for version 7.3.1029
Bram Moolenaar <bram@vim.org>
parents:
4561
diff
changeset
|
5401 /* Allocate memory for the lists of nodes. */ |
4539
532c2e850256
updated for version 7.3.1017
Bram Moolenaar <bram@vim.org>
parents:
4537
diff
changeset
|
5402 size = (nstate + 1) * sizeof(nfa_thread_T); |
6547 | 5403 |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5404 list[0].t = (nfa_thread_T *)lalloc(size, TRUE); |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
5405 list[0].len = nstate + 1; |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5406 list[1].t = (nfa_thread_T *)lalloc(size, TRUE); |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
5407 list[1].len = nstate + 1; |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5408 if (list[0].t == NULL || list[1].t == NULL) |
4444 | 5409 goto theend; |
5410 | |
5411 #ifdef ENABLE_LOG | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5412 log_fd = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 5413 if (log_fd != NULL) |
5414 { | |
5415 fprintf(log_fd, "**********************************\n"); | |
5416 nfa_set_code(start->c); | |
5417 fprintf(log_fd, " RUNNING nfa_regmatch() starting with state %d, code %s\n", | |
5418 abs(start->id), code); | |
5419 fprintf(log_fd, "**********************************\n"); | |
5420 } | |
5421 else | |
5422 { | |
5423 EMSG(_("Could not open temporary log file for writing, displaying on stderr ... ")); | |
5424 log_fd = stderr; | |
5425 } | |
5426 #endif | |
5427 | |
5428 thislist = &list[0]; | |
5429 thislist->n = 0; | |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5430 thislist->has_pim = FALSE; |
4444 | 5431 nextlist = &list[1]; |
5432 nextlist->n = 0; | |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5433 nextlist->has_pim = FALSE; |
4444 | 5434 #ifdef ENABLE_LOG |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5435 fprintf(log_fd, "(---) STARTSTATE first\n"); |
4444 | 5436 #endif |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5437 thislist->id = nfa_listid + 1; |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5438 |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5439 /* Inline optimized code for addstate(thislist, start, m, 0) if we know |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5440 * it's the first MOPEN. */ |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5441 if (toplevel) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5442 { |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5443 if (REG_MULTI) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5444 { |
6547 | 5445 m->norm.list.multi[0].start_lnum = reglnum; |
5446 m->norm.list.multi[0].start_col = (colnr_T)(reginput - regline); | |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5447 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5448 else |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5449 m->norm.list.line[0].start = reginput; |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5450 m->norm.in_use = 1; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5451 addstate(thislist, start->out, m, NULL, 0); |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5452 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
5453 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5454 addstate(thislist, start, m, NULL, 0); |
4444 | 5455 |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5456 #define ADD_STATE_IF_MATCH(state) \ |
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5457 if (result) { \ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5458 add_state = state->out; \ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5459 add_off = clen; \ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5460 } |
4444 | 5461 |
5462 /* | |
5463 * Run for each character. | |
5464 */ | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5465 for (;;) |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5466 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5467 int curc; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5468 int clen; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5469 |
4444 | 5470 #ifdef FEAT_MBYTE |
5471 if (has_mbyte) | |
5472 { | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5473 curc = (*mb_ptr2char)(reginput); |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5474 clen = (*mb_ptr2len)(reginput); |
4444 | 5475 } |
5476 else | |
5477 #endif | |
5478 { | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5479 curc = *reginput; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5480 clen = 1; |
4444 | 5481 } |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5482 if (curc == NUL) |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5483 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5484 clen = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5485 go_to_nextline = FALSE; |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5486 } |
4444 | 5487 |
5488 /* swap lists */ | |
5489 thislist = &list[flag]; | |
5490 nextlist = &list[flag ^= 1]; | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
5491 nextlist->n = 0; /* clear nextlist */ |
5227
a08fa2919f2b
updated for version 7.4a.039
Bram Moolenaar <bram@vim.org>
parents:
5221
diff
changeset
|
5492 nextlist->has_pim = FALSE; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5493 ++nfa_listid; |
6328 | 5494 if (prog->re_engine == AUTOMATIC_ENGINE && nfa_listid >= NFA_MAX_STATES) |
5495 { | |
5496 /* too many states, retry with old engine */ | |
5497 nfa_match = NFA_TOO_EXPENSIVE; | |
5498 goto theend; | |
5499 } | |
5500 | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5501 thislist->id = nfa_listid; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
5502 nextlist->id = nfa_listid + 1; |
4444 | 5503 |
5504 #ifdef ENABLE_LOG | |
5505 fprintf(log_fd, "------------------------------------------\n"); | |
5506 fprintf(log_fd, ">>> Reginput is \"%s\"\n", reginput); | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5507 fprintf(log_fd, ">>> Advanced one character ... Current char is %c (code %d) \n", curc, (int)curc); |
4444 | 5508 fprintf(log_fd, ">>> Thislist has %d states available: ", thislist->n); |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5509 { |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5510 int i; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5511 |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5512 for (i = 0; i < thislist->n; i++) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5513 fprintf(log_fd, "%d ", abs(thislist->t[i].state->id)); |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5514 } |
4444 | 5515 fprintf(log_fd, "\n"); |
5516 #endif | |
5517 | |
4460 | 5518 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 5519 fprintf(debug, "\n-------------------\n"); |
5520 #endif | |
4480 | 5521 /* |
5522 * If the state lists are empty we can stop. | |
5523 */ | |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5524 if (thislist->n == 0) |
4480 | 5525 break; |
4444 | 5526 |
5527 /* compute nextlist */ | |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5528 for (listidx = 0; listidx < thislist->n; ++listidx) |
4444 | 5529 { |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5530 t = &thislist->t[listidx]; |
4444 | 5531 |
4460 | 5532 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 5533 nfa_set_code(t->state->c); |
5534 fprintf(debug, "%s, ", code); | |
5535 #endif | |
5536 #ifdef ENABLE_LOG | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5537 { |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5538 int col; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5539 |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
5540 if (t->subs.norm.in_use <= 0) |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5541 col = -1; |
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5542 else if (REG_MULTI) |
6547 | 5543 col = t->subs.norm.list.multi[0].start_col; |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5544 else |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
5545 col = (int)(t->subs.norm.list.line[0].start - regline); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5546 nfa_set_code(t->state->c); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5547 fprintf(log_fd, "(%d) char %d %s (start col %d)%s ... \n", |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5548 abs(t->state->id), (int)t->state->c, code, col, |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5549 pim_info(&t->pim)); |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5550 } |
4444 | 5551 #endif |
5552 | |
5553 /* | |
5554 * Handle the possible codes of the current state. | |
5555 * The most important is NFA_MATCH. | |
5556 */ | |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5557 add_state = NULL; |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5558 add_here = FALSE; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5559 add_count = 0; |
4444 | 5560 switch (t->state->c) |
5561 { | |
5562 case NFA_MATCH: | |
4567
96c1a7850097
updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents:
4565
diff
changeset
|
5563 { |
5901 | 5564 #ifdef FEAT_MBYTE |
5565 /* If the match ends before a composing characters and | |
5566 * ireg_icombine is not set, that is not really a match. */ | |
5567 if (enc_utf8 && !ireg_icombine && utf_iscomposing(curc)) | |
5568 break; | |
5569 #endif | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
5570 nfa_match = TRUE; |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5571 copy_sub(&submatch->norm, &t->subs.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5572 #ifdef FEAT_SYN_HL |
4712
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5573 if (nfa_has_zsubexpr) |
832bf8136d86
updated for version 7.3.1103
Bram Moolenaar <bram@vim.org>
parents:
4696
diff
changeset
|
5574 copy_sub(&submatch->synt, &t->subs.synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5575 #endif |
4444 | 5576 #ifdef ENABLE_LOG |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5577 log_subsexpr(&t->subs); |
4444 | 5578 #endif |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5579 /* Found the left-most longest match, do not look at any other |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5580 * states at this position. When the list of states is going |
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5581 * to be empty quit without advancing, so that "reginput" is |
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5582 * correct. */ |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
5583 if (nextlist->n == 0) |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
5584 clen = 0; |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
5585 goto nextchar; |
4567
96c1a7850097
updated for version 7.3.1031
Bram Moolenaar <bram@vim.org>
parents:
4565
diff
changeset
|
5586 } |
4444 | 5587 |
5588 case NFA_END_INVISIBLE: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5589 case NFA_END_INVISIBLE_NEG: |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5590 case NFA_END_PATTERN: |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5591 /* |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5592 * This is only encountered after a NFA_START_INVISIBLE or |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5593 * NFA_START_INVISIBLE_BEFORE node. |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5594 * They surround a zero-width group, used with "\@=", "\&", |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5595 * "\@!", "\@<=" and "\@<!". |
4444 | 5596 * If we got here, it means that the current "invisible" group |
5597 * finished successfully, so return control to the parent | |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5598 * nfa_regmatch(). For a look-behind match only when it ends |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5599 * in the position in "nfa_endp". |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5600 * Submatches are stored in *m, and used in the parent call. |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5601 */ |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5602 #ifdef ENABLE_LOG |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5603 if (nfa_endp != NULL) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5604 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5605 if (REG_MULTI) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5606 fprintf(log_fd, "Current lnum: %d, endp lnum: %d; current col: %d, endp col: %d\n", |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5607 (int)reglnum, |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5608 (int)nfa_endp->se_u.pos.lnum, |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5609 (int)(reginput - regline), |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5610 nfa_endp->se_u.pos.col); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5611 else |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5612 fprintf(log_fd, "Current col: %d, endp col: %d\n", |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5613 (int)(reginput - regline), |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5614 (int)(nfa_endp->se_u.ptr - reginput)); |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5615 } |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5616 #endif |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5617 /* If "nfa_endp" is set it's only a match if it ends at |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5618 * "nfa_endp" */ |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5619 if (nfa_endp != NULL && (REG_MULTI |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5620 ? (reglnum != nfa_endp->se_u.pos.lnum |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5621 || (int)(reginput - regline) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5622 != nfa_endp->se_u.pos.col) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5623 : reginput != nfa_endp->se_u.ptr)) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5624 break; |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5625 |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5626 /* do not set submatches for \@! */ |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5627 if (t->state->c != NFA_END_INVISIBLE_NEG) |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5628 { |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5629 copy_sub(&m->norm, &t->subs.norm); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5630 #ifdef FEAT_SYN_HL |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5631 if (nfa_has_zsubexpr) |
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5632 copy_sub(&m->synt, &t->subs.synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5633 #endif |
4444 | 5634 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5635 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5636 fprintf(log_fd, "Match found:\n"); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5637 log_subsexpr(m); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5638 #endif |
4716
a804309e7327
updated for version 7.3.1105
Bram Moolenaar <bram@vim.org>
parents:
4714
diff
changeset
|
5639 nfa_match = TRUE; |
5334 | 5640 /* See comment above at "goto nextchar". */ |
5641 if (nextlist->n == 0) | |
5642 clen = 0; | |
5643 goto nextchar; | |
4444 | 5644 |
5645 case NFA_START_INVISIBLE: | |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5646 case NFA_START_INVISIBLE_FIRST: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5647 case NFA_START_INVISIBLE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5648 case NFA_START_INVISIBLE_NEG_FIRST: |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
5649 case NFA_START_INVISIBLE_BEFORE: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5650 case NFA_START_INVISIBLE_BEFORE_FIRST: |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5651 case NFA_START_INVISIBLE_BEFORE_NEG: |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5652 case NFA_START_INVISIBLE_BEFORE_NEG_FIRST: |
4444 | 5653 { |
4821
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5654 #ifdef ENABLE_LOG |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5655 fprintf(log_fd, "Failure chance invisible: %d, what follows: %d\n", |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5656 failure_chance(t->state->out, 0), |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5657 failure_chance(t->state->out1->out, 0)); |
2f1ee97f5f23
updated for version 7.3.1157
Bram Moolenaar <bram@vim.org>
parents:
4819
diff
changeset
|
5658 #endif |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5659 /* Do it directly if there already is a PIM or when |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5660 * nfa_postprocess() detected it will work better. */ |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5661 if (t->pim.result != NFA_PIM_UNUSED |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5662 || t->state->c == NFA_START_INVISIBLE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5663 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5664 || t->state->c == NFA_START_INVISIBLE_BEFORE_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5665 || t->state->c == NFA_START_INVISIBLE_BEFORE_NEG_FIRST) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5666 { |
5029
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
5667 int in_use = m->norm.in_use; |
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
5668 |
5370 | 5669 /* Copy submatch info for the recursive call, opposite |
5670 * of what happens on success below. */ | |
4997
8a7d3a73adab
updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents:
4958
diff
changeset
|
5671 copy_sub_off(&m->norm, &t->subs.norm); |
5370 | 5672 #ifdef FEAT_SYN_HL |
5673 if (nfa_has_zsubexpr) | |
5674 copy_sub_off(&m->synt, &t->subs.synt); | |
5675 #endif | |
4997
8a7d3a73adab
updated for version 7.3.1243
Bram Moolenaar <bram@vim.org>
parents:
4958
diff
changeset
|
5676 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5677 /* |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5678 * First try matching the invisible match, then what |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5679 * follows. |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5680 */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5681 result = recursive_regmatch(t->state, NULL, prog, |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5682 submatch, m, &listids); |
6328 | 5683 if (result == NFA_TOO_EXPENSIVE) |
5684 { | |
5685 nfa_match = result; | |
5686 goto theend; | |
5687 } | |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5688 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5689 /* for \@! and \@<! it is a match when the result is |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5690 * FALSE */ |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5691 if (result != (t->state->c == NFA_START_INVISIBLE_NEG |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5692 || t->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5693 || t->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5694 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5695 || t->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
5696 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5697 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5698 /* Copy submatch info from the recursive call */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5699 copy_sub_off(&t->subs.norm, &m->norm); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5700 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5701 if (nfa_has_zsubexpr) |
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5702 copy_sub_off(&t->subs.synt, &m->synt); |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
5703 #endif |
5372 | 5704 /* If the pattern has \ze and it matched in the |
5705 * sub pattern, use it. */ | |
5706 copy_ze_off(&t->subs.norm, &m->norm); | |
4657
93b7ed814bec
updated for version 7.3.1076
Bram Moolenaar <bram@vim.org>
parents:
4655
diff
changeset
|
5707 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5708 /* t->state->out1 is the corresponding |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5709 * END_INVISIBLE node; Add its out to the current |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5710 * list (zero-width match). */ |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5711 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5712 add_state = t->state->out1->out; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5713 } |
5029
c9e2ccc53f2e
updated for version 7.3.1258
Bram Moolenaar <bram@vim.org>
parents:
5006
diff
changeset
|
5714 m->norm.in_use = in_use; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5715 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5716 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5717 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5718 nfa_pim_T pim; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5719 |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5720 /* |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5721 * First try matching what follows. Only if a match |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5722 * is found verify the invisible match matches. Add a |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5723 * nfa_pim_T to the following states, it contains info |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5724 * about the invisible match. |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5725 */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5726 pim.state = t->state; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5727 pim.result = NFA_PIM_TODO; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5728 pim.subs.norm.in_use = 0; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5729 #ifdef FEAT_SYN_HL |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5730 pim.subs.synt.in_use = 0; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5731 #endif |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5732 if (REG_MULTI) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5733 { |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5734 pim.end.pos.col = (int)(reginput - regline); |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5735 pim.end.pos.lnum = reglnum; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5736 } |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5737 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5738 pim.end.ptr = reginput; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5739 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5740 /* t->state->out1 is the corresponding END_INVISIBLE |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5741 * node; Add its out to the current list (zero-width |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5742 * match). */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5743 addstate_here(thislist, t->state->out1->out, &t->subs, |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5744 &pim, &listidx); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
5745 } |
4444 | 5746 } |
5747 break; | |
5748 | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5749 case NFA_START_PATTERN: |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5750 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5751 nfa_state_T *skip = NULL; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5752 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5753 int skip_lid = 0; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5754 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5755 |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5756 /* There is no point in trying to match the pattern if the |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5757 * output state is not going to be added to the list. */ |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5758 if (state_in_list(nextlist, t->state->out1->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5759 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5760 skip = t->state->out1->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5761 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5762 skip_lid = nextlist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5763 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5764 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5765 else if (state_in_list(nextlist, |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5766 t->state->out1->out->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5767 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5768 skip = t->state->out1->out->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5769 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5770 skip_lid = nextlist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5771 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5772 } |
4897
91136a41f83f
updated for version 7.3.1194
Bram Moolenaar <bram@vim.org>
parents:
4893
diff
changeset
|
5773 else if (state_in_list(thislist, |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5774 t->state->out1->out->out, &t->subs)) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5775 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5776 skip = t->state->out1->out->out; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5777 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5778 skip_lid = thislist->id; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5779 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5780 } |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5781 if (skip != NULL) |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5782 { |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5783 #ifdef ENABLE_LOG |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5784 nfa_set_code(skip->c); |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5785 fprintf(log_fd, "> Not trying to match pattern, output state %d is already in list %d. char %d: %s\n", |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5786 abs(skip->id), skip_lid, skip->c, code); |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5787 #endif |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5788 break; |
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5789 } |
5370 | 5790 /* Copy submatch info to the recursive call, opposite of what |
5791 * happens afterwards. */ | |
5792 copy_sub_off(&m->norm, &t->subs.norm); | |
5793 #ifdef FEAT_SYN_HL | |
5794 if (nfa_has_zsubexpr) | |
5795 copy_sub_off(&m->synt, &t->subs.synt); | |
5796 #endif | |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5797 |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5798 /* First try matching the pattern. */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
5799 result = recursive_regmatch(t->state, NULL, prog, |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5800 submatch, m, &listids); |
6328 | 5801 if (result == NFA_TOO_EXPENSIVE) |
5802 { | |
5803 nfa_match = result; | |
5804 goto theend; | |
5805 } | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5806 if (result) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5807 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5808 int bytelen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5809 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5810 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5811 fprintf(log_fd, "NFA_START_PATTERN matches:\n"); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5812 log_subsexpr(m); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5813 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5814 /* Copy submatch info from the recursive call */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5815 copy_sub_off(&t->subs.norm, &m->norm); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5816 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5817 if (nfa_has_zsubexpr) |
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
5818 copy_sub_off(&t->subs.synt, &m->synt); |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5819 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5820 /* Now we need to skip over the matched text and then |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5821 * continue with what follows. */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5822 if (REG_MULTI) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5823 /* TODO: multi-line match */ |
6547 | 5824 bytelen = m->norm.list.multi[0].end_col |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5825 - (int)(reginput - regline); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5826 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5827 bytelen = (int)(m->norm.list.line[0].end - reginput); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5828 |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5829 #ifdef ENABLE_LOG |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5830 fprintf(log_fd, "NFA_START_PATTERN length: %d\n", bytelen); |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5831 #endif |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5832 if (bytelen == 0) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5833 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5834 /* empty match, output of corresponding |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5835 * NFA_END_PATTERN/NFA_SKIP to be used at current |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5836 * position */ |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5837 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5838 add_state = t->state->out1->out->out; |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5839 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5840 else if (bytelen <= clen) |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5841 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5842 /* match current character, output of corresponding |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5843 * NFA_END_PATTERN to be used at next position. */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5844 add_state = t->state->out1->out->out; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5845 add_off = clen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5846 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5847 else |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5848 { |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5849 /* skip over the matched characters, set character |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5850 * count in NFA_SKIP */ |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5851 add_state = t->state->out1->out; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5852 add_off = bytelen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5853 add_count = bytelen - clen; |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5854 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5855 } |
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5856 break; |
4787
7fde662e1db2
updated for version 7.3.1140
Bram Moolenaar <bram@vim.org>
parents:
4785
diff
changeset
|
5857 } |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
5858 |
4444 | 5859 case NFA_BOL: |
5860 if (reginput == regline) | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5861 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5862 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5863 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5864 } |
4444 | 5865 break; |
5866 | |
5867 case NFA_EOL: | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5868 if (curc == NUL) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5869 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5870 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5871 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5872 } |
4444 | 5873 break; |
5874 | |
5875 case NFA_BOW: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5876 result = TRUE; |
4444 | 5877 |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5878 if (curc == NUL) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5879 result = FALSE; |
4444 | 5880 #ifdef FEAT_MBYTE |
5881 else if (has_mbyte) | |
5882 { | |
5883 int this_class; | |
5884 | |
5885 /* Get class of current and previous char (if it exists). */ | |
4503 | 5886 this_class = mb_get_class_buf(reginput, reg_buf); |
4444 | 5887 if (this_class <= 1) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5888 result = FALSE; |
4444 | 5889 else if (reg_prev_class() == this_class) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5890 result = FALSE; |
4444 | 5891 } |
5892 #endif | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5893 else if (!vim_iswordc_buf(curc, reg_buf) |
4503 | 5894 || (reginput > regline |
5895 && vim_iswordc_buf(reginput[-1], reg_buf))) | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5896 result = FALSE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5897 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5898 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5899 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5900 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5901 } |
4444 | 5902 break; |
5903 | |
5904 case NFA_EOW: | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5905 result = TRUE; |
4444 | 5906 if (reginput == regline) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5907 result = FALSE; |
4444 | 5908 #ifdef FEAT_MBYTE |
5909 else if (has_mbyte) | |
5910 { | |
5911 int this_class, prev_class; | |
5912 | |
5913 /* Get class of current and previous char (if it exists). */ | |
4503 | 5914 this_class = mb_get_class_buf(reginput, reg_buf); |
4444 | 5915 prev_class = reg_prev_class(); |
5916 if (this_class == prev_class | |
5917 || prev_class == 0 || prev_class == 1) | |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5918 result = FALSE; |
4444 | 5919 } |
5920 #endif | |
4503 | 5921 else if (!vim_iswordc_buf(reginput[-1], reg_buf) |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5922 || (reginput[0] != NUL |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5923 && vim_iswordc_buf(curc, reg_buf))) |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5924 result = FALSE; |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
5925 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5926 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5927 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5928 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5929 } |
4444 | 5930 break; |
5931 | |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5932 case NFA_BOF: |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5933 if (reglnum == 0 && reginput == regline |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5934 && (!REG_MULTI || reg_firstlnum == 1)) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5935 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5936 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5937 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5938 } |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5939 break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5940 |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5941 case NFA_EOF: |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5942 if (reglnum == reg_maxline && curc == NUL) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5943 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5944 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5945 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
5946 } |
4671
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5947 break; |
b3c59716e700
updated for version 7.3.1083
Bram Moolenaar <bram@vim.org>
parents:
4669
diff
changeset
|
5948 |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
5949 #ifdef FEAT_MBYTE |
4444 | 5950 case NFA_COMPOSING: |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
5951 { |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5952 int mc = curc; |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5953 int len = 0; |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5954 nfa_state_T *end; |
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
5955 nfa_state_T *sta; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5956 int cchars[MAX_MCO]; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5957 int ccount = 0; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5958 int j; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5959 |
4444 | 5960 sta = t->state->out; |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
5961 len = 0; |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5962 if (utf_iscomposing(sta->c)) |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5963 { |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5964 /* Only match composing character(s), ignore base |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5965 * character. Used for ".{composing}" and "{composing}" |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5966 * (no preceding character). */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5967 len += mb_char2len(mc); |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5968 } |
4551
f0c37f5cf4ea
updated for version 7.3.1023
Bram Moolenaar <bram@vim.org>
parents:
4549
diff
changeset
|
5969 if (ireg_icombine && len == 0) |
4444 | 5970 { |
4535
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5971 /* If \Z was present, then ignore composing characters. |
45f97c349537
updated for version 7.3.1015
Bram Moolenaar <bram@vim.org>
parents:
4533
diff
changeset
|
5972 * When ignoring the base character this always matches. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5973 if (len == 0 && sta->c != curc) |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5974 result = FAIL; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5975 else |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5976 result = OK; |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5977 while (sta->c != NFA_END_COMPOSING) |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5978 sta = sta->out; |
4444 | 5979 } |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5980 |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5981 /* Check base character matches first, unless ignored. */ |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5982 else if (len > 0 || mc == sta->c) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5983 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5984 if (len == 0) |
4529
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5985 { |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5986 len += mb_char2len(mc); |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5987 sta = sta->out; |
432a6b8c7d93
updated for version 7.3.1012
Bram Moolenaar <bram@vim.org>
parents:
4527
diff
changeset
|
5988 } |
4444 | 5989 |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5990 /* We don't care about the order of composing characters. |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5991 * Get them into cchars[] first. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
5992 while (len < clen) |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5993 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5994 mc = mb_ptr2char(reginput + len); |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5995 cchars[ccount++] = mc; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5996 len += mb_char2len(mc); |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5997 if (ccount == MAX_MCO) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5998 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
5999 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6000 |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6001 /* Check that each composing char in the pattern matches a |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6002 * composing char in the text. We do not check if all |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6003 * composing chars are matched. */ |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6004 result = OK; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6005 while (sta->c != NFA_END_COMPOSING) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6006 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6007 for (j = 0; j < ccount; ++j) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6008 if (cchars[j] == sta->c) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6009 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6010 if (j == ccount) |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6011 { |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6012 result = FAIL; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6013 break; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6014 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6015 sta = sta->out; |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6016 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6017 } |
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6018 else |
4525
36ddcf4cecbc
updated for version 7.3.1010
Bram Moolenaar <bram@vim.org>
parents:
4517
diff
changeset
|
6019 result = FAIL; |
4547
fc997f05cbc7
updated for version 7.3.1021
Bram Moolenaar <bram@vim.org>
parents:
4543
diff
changeset
|
6020 |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6021 end = t->state->out1; /* NFA_END_COMPOSING */ |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6022 ADD_STATE_IF_MATCH(end); |
4444 | 6023 break; |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6024 } |
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6025 #endif |
4444 | 6026 |
6027 case NFA_NEWL: | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6028 if (curc == NUL && !reg_line_lbr && REG_MULTI |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6029 && reglnum <= reg_maxline) |
4444 | 6030 { |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6031 go_to_nextline = TRUE; |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6032 /* Pass -1 for the offset, which means taking the position |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6033 * at the start of the next line. */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6034 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6035 add_off = -1; |
4444 | 6036 } |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6037 else if (curc == '\n' && reg_line_lbr) |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6038 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6039 /* match \n as if it is an ordinary character */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6040 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6041 add_off = 1; |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
6042 } |
4444 | 6043 break; |
6044 | |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6045 case NFA_START_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6046 case NFA_START_NEG_COLL: |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6047 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6048 /* What follows is a list of characters, until NFA_END_COLL. |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6049 * One of them must match or none of them must match. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6050 nfa_state_T *state; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6051 int result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6052 int c1, c2; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6053 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6054 /* Never match EOL. If it's part of the collection it is added |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6055 * as a separate state with an OR. */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6056 if (curc == NUL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6057 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6058 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6059 state = t->state->out; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6060 result_if_matched = (t->state->c == NFA_START_COLL); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6061 for (;;) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6062 { |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6063 if (state->c == NFA_END_COLL) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6064 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6065 result = !result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6066 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6067 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6068 if (state->c == NFA_RANGE_MIN) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6069 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6070 c1 = state->val; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6071 state = state->out; /* advance to NFA_RANGE_MAX */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6072 c2 = state->val; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6073 #ifdef ENABLE_LOG |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6074 fprintf(log_fd, "NFA_RANGE_MIN curc=%d c1=%d c2=%d\n", |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6075 curc, c1, c2); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6076 #endif |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6077 if (curc >= c1 && curc <= c2) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6078 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6079 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6080 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6081 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6082 if (ireg_ic) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6083 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6084 int curc_low = MB_TOLOWER(curc); |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6085 int done = FALSE; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6086 |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6087 for ( ; c1 <= c2; ++c1) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6088 if (MB_TOLOWER(c1) == curc_low) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6089 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6090 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6091 done = TRUE; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6092 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6093 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6094 if (done) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6095 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6096 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6097 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6098 else if (state->c < 0 ? check_char_class(state->c, curc) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6099 : (curc == state->c |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6100 || (ireg_ic && MB_TOLOWER(curc) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6101 == MB_TOLOWER(state->c)))) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6102 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6103 result = result_if_matched; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6104 break; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6105 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6106 state = state->out; |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6107 } |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6108 if (result) |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6109 { |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6110 /* next state is in out of the NFA_END_COLL, out1 of |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6111 * START points to the END state */ |
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6112 add_state = t->state->out1->out; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6113 add_off = clen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6114 } |
4444 | 6115 break; |
4781
c02c7df9bdc9
updated for version 7.3.1137
Bram Moolenaar <bram@vim.org>
parents:
4772
diff
changeset
|
6116 } |
4444 | 6117 |
6118 case NFA_ANY: | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6119 /* Any char except '\0', (end of input) does not match. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6120 if (curc > 0) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6121 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6122 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6123 add_off = clen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6124 } |
4444 | 6125 break; |
6126 | |
5901 | 6127 case NFA_ANY_COMPOSING: |
6128 /* On a composing character skip over it. Otherwise do | |
6129 * nothing. Always matches. */ | |
6130 #ifdef FEAT_MBYTE | |
6131 if (enc_utf8 && utf_iscomposing(curc)) | |
6132 { | |
6133 add_off = clen; | |
6134 } | |
6135 else | |
6136 #endif | |
6137 { | |
6138 add_here = TRUE; | |
6139 add_off = 0; | |
6140 } | |
6141 add_state = t->state->out; | |
6142 break; | |
6143 | |
4444 | 6144 /* |
6145 * Character classes like \a for alpha, \d for digit etc. | |
6146 */ | |
6147 case NFA_IDENT: /* \i */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6148 result = vim_isIDc(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6149 ADD_STATE_IF_MATCH(t->state); |
4444 | 6150 break; |
6151 | |
6152 case NFA_SIDENT: /* \I */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6153 result = !VIM_ISDIGIT(curc) && vim_isIDc(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6154 ADD_STATE_IF_MATCH(t->state); |
4444 | 6155 break; |
6156 | |
6157 case NFA_KWORD: /* \k */ | |
4503 | 6158 result = vim_iswordp_buf(reginput, reg_buf); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6159 ADD_STATE_IF_MATCH(t->state); |
4444 | 6160 break; |
6161 | |
6162 case NFA_SKWORD: /* \K */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6163 result = !VIM_ISDIGIT(curc) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6164 && vim_iswordp_buf(reginput, reg_buf); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6165 ADD_STATE_IF_MATCH(t->state); |
4444 | 6166 break; |
6167 | |
6168 case NFA_FNAME: /* \f */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6169 result = vim_isfilec(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6170 ADD_STATE_IF_MATCH(t->state); |
4444 | 6171 break; |
6172 | |
6173 case NFA_SFNAME: /* \F */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6174 result = !VIM_ISDIGIT(curc) && vim_isfilec(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6175 ADD_STATE_IF_MATCH(t->state); |
4444 | 6176 break; |
6177 | |
6178 case NFA_PRINT: /* \p */ | |
5221
9982ec574beb
updated for version 7.4a.036
Bram Moolenaar <bram@vim.org>
parents:
5212
diff
changeset
|
6179 result = vim_isprintc(PTR2CHAR(reginput)); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6180 ADD_STATE_IF_MATCH(t->state); |
4444 | 6181 break; |
6182 | |
6183 case NFA_SPRINT: /* \P */ | |
5221
9982ec574beb
updated for version 7.4a.036
Bram Moolenaar <bram@vim.org>
parents:
5212
diff
changeset
|
6184 result = !VIM_ISDIGIT(curc) && vim_isprintc(PTR2CHAR(reginput)); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6185 ADD_STATE_IF_MATCH(t->state); |
4444 | 6186 break; |
6187 | |
6188 case NFA_WHITE: /* \s */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6189 result = vim_iswhite(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6190 ADD_STATE_IF_MATCH(t->state); |
4444 | 6191 break; |
6192 | |
6193 case NFA_NWHITE: /* \S */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6194 result = curc != NUL && !vim_iswhite(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6195 ADD_STATE_IF_MATCH(t->state); |
4444 | 6196 break; |
6197 | |
6198 case NFA_DIGIT: /* \d */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6199 result = ri_digit(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6200 ADD_STATE_IF_MATCH(t->state); |
4444 | 6201 break; |
6202 | |
6203 case NFA_NDIGIT: /* \D */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6204 result = curc != NUL && !ri_digit(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6205 ADD_STATE_IF_MATCH(t->state); |
4444 | 6206 break; |
6207 | |
6208 case NFA_HEX: /* \x */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6209 result = ri_hex(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6210 ADD_STATE_IF_MATCH(t->state); |
4444 | 6211 break; |
6212 | |
6213 case NFA_NHEX: /* \X */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6214 result = curc != NUL && !ri_hex(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6215 ADD_STATE_IF_MATCH(t->state); |
4444 | 6216 break; |
6217 | |
6218 case NFA_OCTAL: /* \o */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6219 result = ri_octal(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6220 ADD_STATE_IF_MATCH(t->state); |
4444 | 6221 break; |
6222 | |
6223 case NFA_NOCTAL: /* \O */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6224 result = curc != NUL && !ri_octal(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6225 ADD_STATE_IF_MATCH(t->state); |
4444 | 6226 break; |
6227 | |
6228 case NFA_WORD: /* \w */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6229 result = ri_word(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6230 ADD_STATE_IF_MATCH(t->state); |
4444 | 6231 break; |
6232 | |
6233 case NFA_NWORD: /* \W */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6234 result = curc != NUL && !ri_word(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6235 ADD_STATE_IF_MATCH(t->state); |
4444 | 6236 break; |
6237 | |
6238 case NFA_HEAD: /* \h */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6239 result = ri_head(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6240 ADD_STATE_IF_MATCH(t->state); |
4444 | 6241 break; |
6242 | |
6243 case NFA_NHEAD: /* \H */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6244 result = curc != NUL && !ri_head(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6245 ADD_STATE_IF_MATCH(t->state); |
4444 | 6246 break; |
6247 | |
6248 case NFA_ALPHA: /* \a */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6249 result = ri_alpha(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6250 ADD_STATE_IF_MATCH(t->state); |
4444 | 6251 break; |
6252 | |
6253 case NFA_NALPHA: /* \A */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6254 result = curc != NUL && !ri_alpha(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6255 ADD_STATE_IF_MATCH(t->state); |
4444 | 6256 break; |
6257 | |
6258 case NFA_LOWER: /* \l */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6259 result = ri_lower(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6260 ADD_STATE_IF_MATCH(t->state); |
4444 | 6261 break; |
6262 | |
6263 case NFA_NLOWER: /* \L */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6264 result = curc != NUL && !ri_lower(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6265 ADD_STATE_IF_MATCH(t->state); |
4444 | 6266 break; |
6267 | |
6268 case NFA_UPPER: /* \u */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6269 result = ri_upper(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6270 ADD_STATE_IF_MATCH(t->state); |
4444 | 6271 break; |
6272 | |
6273 case NFA_NUPPER: /* \U */ | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6274 result = curc != NUL && !ri_upper(curc); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6275 ADD_STATE_IF_MATCH(t->state); |
4444 | 6276 break; |
6277 | |
5296 | 6278 case NFA_LOWER_IC: /* [a-z] */ |
6279 result = ri_lower(curc) || (ireg_ic && ri_upper(curc)); | |
6280 ADD_STATE_IF_MATCH(t->state); | |
6281 break; | |
6282 | |
6283 case NFA_NLOWER_IC: /* [^a-z] */ | |
6284 result = curc != NUL | |
6285 && !(ri_lower(curc) || (ireg_ic && ri_upper(curc))); | |
6286 ADD_STATE_IF_MATCH(t->state); | |
6287 break; | |
6288 | |
6289 case NFA_UPPER_IC: /* [A-Z] */ | |
6290 result = ri_upper(curc) || (ireg_ic && ri_lower(curc)); | |
6291 ADD_STATE_IF_MATCH(t->state); | |
6292 break; | |
6293 | |
6294 case NFA_NUPPER_IC: /* ^[A-Z] */ | |
6295 result = curc != NUL | |
6296 && !(ri_upper(curc) || (ireg_ic && ri_lower(curc))); | |
6297 ADD_STATE_IF_MATCH(t->state); | |
6298 break; | |
6299 | |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6300 case NFA_BACKREF1: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6301 case NFA_BACKREF2: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6302 case NFA_BACKREF3: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6303 case NFA_BACKREF4: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6304 case NFA_BACKREF5: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6305 case NFA_BACKREF6: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6306 case NFA_BACKREF7: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6307 case NFA_BACKREF8: |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6308 case NFA_BACKREF9: |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6309 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6310 case NFA_ZREF1: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6311 case NFA_ZREF2: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6312 case NFA_ZREF3: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6313 case NFA_ZREF4: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6314 case NFA_ZREF5: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6315 case NFA_ZREF6: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6316 case NFA_ZREF7: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6317 case NFA_ZREF8: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6318 case NFA_ZREF9: |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6319 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6320 /* \1 .. \9 \z1 .. \z9 */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6321 { |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6322 int subidx; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6323 int bytelen; |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6324 |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6325 if (t->state->c <= NFA_BACKREF9) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6326 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6327 subidx = t->state->c - NFA_BACKREF1 + 1; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6328 result = match_backref(&t->subs.norm, subidx, &bytelen); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6329 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6330 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6331 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6332 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6333 subidx = t->state->c - NFA_ZREF1 + 1; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6334 result = match_zref(subidx, &bytelen); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6335 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6336 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6337 |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6338 if (result) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6339 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6340 if (bytelen == 0) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6341 { |
4692
08fbb1ce1bc5
updated for version 7.3.1093
Bram Moolenaar <bram@vim.org>
parents:
4690
diff
changeset
|
6342 /* empty match always works, output of NFA_SKIP to be |
08fbb1ce1bc5
updated for version 7.3.1093
Bram Moolenaar <bram@vim.org>
parents:
4690
diff
changeset
|
6343 * used next */ |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6344 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6345 add_state = t->state->out->out; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6346 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6347 else if (bytelen <= clen) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6348 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6349 /* match current character, jump ahead to out of |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6350 * NFA_SKIP */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6351 add_state = t->state->out->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6352 add_off = clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6353 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6354 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6355 { |
4728
43de4ebbe7ad
updated for version 7.3.1111
Bram Moolenaar <bram@vim.org>
parents:
4726
diff
changeset
|
6356 /* skip over the matched characters, set character |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6357 * count in NFA_SKIP */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6358 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6359 add_off = bytelen; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6360 add_count = bytelen - clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6361 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6362 } |
4482 | 6363 break; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6364 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6365 case NFA_SKIP: |
4748
4b9503f0c7d3
updated for version 7.3.1121
Bram Moolenaar <bram@vim.org>
parents:
4746
diff
changeset
|
6366 /* character of previous matching \1 .. \9 or \@> */ |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6367 if (t->count - clen <= 0) |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6368 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6369 /* end of match, go to what follows */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6370 add_state = t->state->out; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6371 add_off = clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6372 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6373 else |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6374 { |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6375 /* add state again with decremented count */ |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6376 add_state = t->state; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6377 add_off = 0; |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6378 add_count = t->count - clen; |
4571
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6379 } |
b2a8e3a66f8c
updated for version 7.3.1033
Bram Moolenaar <bram@vim.org>
parents:
4569
diff
changeset
|
6380 break; |
4482 | 6381 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6382 case NFA_LNUM: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6383 case NFA_LNUM_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6384 case NFA_LNUM_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6385 result = (REG_MULTI && |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6386 nfa_re_num_cmp(t->state->val, t->state->c - NFA_LNUM, |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6387 (long_u)(reglnum + reg_firstlnum))); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6388 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6389 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6390 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6391 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6392 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6393 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6394 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6395 case NFA_COL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6396 case NFA_COL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6397 case NFA_COL_LT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6398 result = nfa_re_num_cmp(t->state->val, t->state->c - NFA_COL, |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6399 (long_u)(reginput - regline) + 1); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6400 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6401 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6402 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6403 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6404 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6405 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6406 |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6407 case NFA_VCOL: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6408 case NFA_VCOL_GT: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6409 case NFA_VCOL_LT: |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6410 { |
6499 | 6411 int op = t->state->c - NFA_VCOL; |
6412 colnr_T col = (colnr_T)(reginput - regline); | |
6510 | 6413 win_T *wp = reg_win == NULL ? curwin : reg_win; |
6499 | 6414 |
6415 /* Bail out quickly when there can't be a match, avoid the | |
6416 * overhead of win_linetabsize() on long lines. */ | |
6653 | 6417 if (op != 1 && col > t->state->val |
6418 #ifdef FEAT_MBYTE | |
6419 * (has_mbyte ? MB_MAXBYTES : 1) | |
6420 #endif | |
6421 ) | |
6499 | 6422 break; |
6510 | 6423 result = FALSE; |
6424 if (op == 1 && col - 1 > t->state->val && col > 100) | |
6425 { | |
6426 int ts = wp->w_buffer->b_p_ts; | |
6427 | |
6428 /* Guess that a character won't use more columns than | |
6429 * 'tabstop', with a minimum of 4. */ | |
6430 if (ts < 4) | |
6431 ts = 4; | |
6432 result = col > t->state->val * ts; | |
6433 } | |
6434 if (!result) | |
6435 result = nfa_re_num_cmp(t->state->val, op, | |
6436 (long_u)win_linetabsize(wp, regline, col) + 1); | |
6499 | 6437 if (result) |
6438 { | |
6439 add_here = TRUE; | |
6440 add_state = t->state->out; | |
6441 } | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6442 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6443 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6444 |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6445 case NFA_MARK: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6446 case NFA_MARK_GT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6447 case NFA_MARK_LT: |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6448 { |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6449 pos_T *pos = getmark_buf(reg_buf, t->state->val, FALSE); |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6450 |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6451 /* Compare the mark position to the match position. */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6452 result = (pos != NULL /* mark doesn't exist */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6453 && pos->lnum > 0 /* mark isn't set in reg_buf */ |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6454 && (pos->lnum == reglnum + reg_firstlnum |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6455 ? (pos->col == (colnr_T)(reginput - regline) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6456 ? t->state->c == NFA_MARK |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6457 : (pos->col < (colnr_T)(reginput - regline) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6458 ? t->state->c == NFA_MARK_GT |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6459 : t->state->c == NFA_MARK_LT)) |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6460 : (pos->lnum < reglnum + reg_firstlnum |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6461 ? t->state->c == NFA_MARK_GT |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6462 : t->state->c == NFA_MARK_LT))); |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6463 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6464 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6465 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6466 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6467 } |
4732
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6468 break; |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6469 } |
0798b096bab3
updated for version 7.3.1113
Bram Moolenaar <bram@vim.org>
parents:
4730
diff
changeset
|
6470 |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6471 case NFA_CURSOR: |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6472 result = (reg_win != NULL |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6473 && (reglnum + reg_firstlnum == reg_win->w_cursor.lnum) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6474 && ((colnr_T)(reginput - regline) |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6475 == reg_win->w_cursor.col)); |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6476 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6477 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6478 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6479 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6480 } |
4583
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6481 break; |
321cfbef9431
updated for version 7.3.1039
Bram Moolenaar <bram@vim.org>
parents:
4579
diff
changeset
|
6482 |
4756
96f3348f9f11
updated for version 7.3.1125
Bram Moolenaar <bram@vim.org>
parents:
4750
diff
changeset
|
6483 case NFA_VISUAL: |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6484 result = reg_match_visual(); |
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6485 if (result) |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6486 { |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6487 add_here = TRUE; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6488 add_state = t->state->out; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6489 } |
4730
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6490 break; |
749e2b2755d5
updated for version 7.3.1112
Bram Moolenaar <bram@vim.org>
parents:
4728
diff
changeset
|
6491 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6492 case NFA_MOPEN1: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6493 case NFA_MOPEN2: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6494 case NFA_MOPEN3: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6495 case NFA_MOPEN4: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6496 case NFA_MOPEN5: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6497 case NFA_MOPEN6: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6498 case NFA_MOPEN7: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6499 case NFA_MOPEN8: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6500 case NFA_MOPEN9: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6501 #ifdef FEAT_SYN_HL |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6502 case NFA_ZOPEN: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6503 case NFA_ZOPEN1: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6504 case NFA_ZOPEN2: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6505 case NFA_ZOPEN3: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6506 case NFA_ZOPEN4: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6507 case NFA_ZOPEN5: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6508 case NFA_ZOPEN6: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6509 case NFA_ZOPEN7: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6510 case NFA_ZOPEN8: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6511 case NFA_ZOPEN9: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6512 #endif |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6513 case NFA_NOPEN: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6514 case NFA_ZSTART: |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6515 /* These states are only added to be able to bail out when |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6516 * they are added again, nothing is to be done. */ |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6517 break; |
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6518 |
4444 | 6519 default: /* regular character */ |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6520 { |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6521 int c = t->state->c; |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6522 |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6523 #ifdef DEBUG |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6524 if (c < 0) |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6525 EMSGN("INTERNAL: Negative state char: %ld", c); |
5251
2e63b6c763f7
updated for version 7.4b.002
Bram Moolenaar <bram@vim.org>
parents:
5227
diff
changeset
|
6526 #endif |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6527 result = (c == curc); |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6528 |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6529 if (!result && ireg_ic) |
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6530 result = MB_TOLOWER(c) == MB_TOLOWER(curc); |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6531 #ifdef FEAT_MBYTE |
5901 | 6532 /* If ireg_icombine is not set only skip over the character |
6533 * itself. When it is set skip over composing characters. */ | |
6534 if (result && enc_utf8 && !ireg_icombine) | |
6787 | 6535 clen = utf_ptr2len(reginput); |
4527
55bcaa1d2749
updated for version 7.3.1011
Bram Moolenaar <bram@vim.org>
parents:
4525
diff
changeset
|
6536 #endif |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6537 ADD_STATE_IF_MATCH(t->state); |
4444 | 6538 break; |
4559
04086e297563
updated for version 7.3.1027
Bram Moolenaar <bram@vim.org>
parents:
4557
diff
changeset
|
6539 } |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6540 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6541 } /* switch (t->state->c) */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6542 |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6543 if (add_state != NULL) |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6544 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6545 nfa_pim_T *pim; |
5401 | 6546 nfa_pim_T pim_copy; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6547 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6548 if (t->pim.result == NFA_PIM_UNUSED) |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6549 pim = NULL; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6550 else |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6551 pim = &t->pim; |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6552 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6553 /* Handle the postponed invisible match if the match might end |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6554 * without advancing and before the end of the line. */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6555 if (pim != NULL && (clen == 0 || match_follows(add_state, 0))) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6556 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6557 if (pim->result == NFA_PIM_TODO) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6558 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6559 #ifdef ENABLE_LOG |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6560 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6561 fprintf(log_fd, "==================================\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6562 fprintf(log_fd, "Postponed recursive nfa_regmatch()\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6563 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6564 #endif |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6565 result = recursive_regmatch(pim->state, pim, |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6566 prog, submatch, m, &listids); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6567 pim->result = result ? NFA_PIM_MATCH : NFA_PIM_NOMATCH; |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6568 /* for \@! and \@<! it is a match when the result is |
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6569 * FALSE */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6570 if (result != (pim->state->c == NFA_START_INVISIBLE_NEG |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6571 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6572 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6573 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6574 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6575 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6576 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6577 /* Copy submatch info from the recursive call */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6578 copy_sub_off(&pim->subs.norm, &m->norm); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6579 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
6580 if (nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6581 copy_sub_off(&pim->subs.synt, &m->synt); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6582 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6583 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6584 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6585 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6586 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6587 result = (pim->result == NFA_PIM_MATCH); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6588 #ifdef ENABLE_LOG |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6589 fprintf(log_fd, "\n"); |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6590 fprintf(log_fd, "Using previous recursive nfa_regmatch() result, result == %d\n", pim->result); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6591 fprintf(log_fd, "MATCH = %s\n", result == TRUE ? "OK" : "FALSE"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6592 fprintf(log_fd, "\n"); |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6593 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6594 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6595 |
4785
3b5a023a4543
updated for version 7.3.1139
Bram Moolenaar <bram@vim.org>
parents:
4783
diff
changeset
|
6596 /* for \@! and \@<! it is a match when result is FALSE */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6597 if (result != (pim->state->c == NFA_START_INVISIBLE_NEG |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6598 || pim->state->c == NFA_START_INVISIBLE_NEG_FIRST |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6599 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6600 == NFA_START_INVISIBLE_BEFORE_NEG |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6601 || pim->state->c |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
6602 == NFA_START_INVISIBLE_BEFORE_NEG_FIRST)) |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6603 { |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6604 /* Copy submatch info from the recursive call */ |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6605 copy_sub_off(&t->subs.norm, &pim->subs.norm); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6606 #ifdef FEAT_SYN_HL |
4768
82e6588762e4
updated for version 7.3.1131
Bram Moolenaar <bram@vim.org>
parents:
4762
diff
changeset
|
6607 if (nfa_has_zsubexpr) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6608 copy_sub_off(&t->subs.synt, &pim->subs.synt); |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6609 #endif |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6610 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6611 else |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6612 /* look-behind match failed, don't add the state */ |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6613 continue; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6614 |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6615 /* Postponed invisible match was handled, don't add it to |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6616 * following states. */ |
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6617 pim = NULL; |
4726
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6618 } |
3849c811cc0b
updated for version 7.3.1110
Bram Moolenaar <bram@vim.org>
parents:
4720
diff
changeset
|
6619 |
5401 | 6620 /* If "pim" points into l->t it will become invalid when |
6621 * adding the state causes the list to be reallocated. Make a | |
6622 * local copy to avoid that. */ | |
6623 if (pim == &t->pim) | |
6624 { | |
6625 copy_pim(&pim_copy, pim); | |
6626 pim = &pim_copy; | |
6627 } | |
6628 | |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6629 if (add_here) |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6630 addstate_here(thislist, add_state, &t->subs, pim, &listidx); |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6631 else |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6632 { |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6633 addstate(nextlist, add_state, &t->subs, pim, add_off); |
4799
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6634 if (add_count > 0) |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6635 nextlist->t[nextlist->n - 1].count = add_count; |
e3f9e33fb28c
updated for version 7.3.1146
Bram Moolenaar <bram@vim.org>
parents:
4797
diff
changeset
|
6636 } |
4444 | 6637 } |
6638 | |
6639 } /* for (thislist = thislist; thislist->state; thislist++) */ | |
6640 | |
4557
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6641 /* Look for the start of a match in the current position by adding the |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6642 * start state to the list of states. |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6643 * The first found match is the leftmost one, thus the order of states |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6644 * matters! |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6645 * Do not add the start state in recursive calls of nfa_regmatch(), |
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6646 * because recursive calls should only start in the first position. |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6647 * Unless "nfa_endp" is not NULL, then we match the end position. |
4557
888c12c899e5
updated for version 7.3.1026
Bram Moolenaar <bram@vim.org>
parents:
4555
diff
changeset
|
6648 * Also don't start a match past the first line. */ |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6649 if (nfa_match == FALSE |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6650 && ((toplevel |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6651 && reglnum == 0 |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6652 && clen != 0 |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6653 && (ireg_maxcol == 0 |
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6654 || (colnr_T)(reginput - regline) < ireg_maxcol)) |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6655 || (nfa_endp != NULL |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6656 && (REG_MULTI |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6657 ? (reglnum < nfa_endp->se_u.pos.lnum |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6658 || (reglnum == nfa_endp->se_u.pos.lnum |
4682
2f51ee8825db
updated for version 7.3.1088
Bram Moolenaar <bram@vim.org>
parents:
4679
diff
changeset
|
6659 && (int)(reginput - regline) |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6660 < nfa_endp->se_u.pos.col)) |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6661 : reginput < nfa_endp->se_u.ptr)))) |
4444 | 6662 { |
6663 #ifdef ENABLE_LOG | |
6664 fprintf(log_fd, "(---) STARTSTATE\n"); | |
6665 #endif | |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6666 /* Inline optimized code for addstate() if we know the state is |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6667 * the first MOPEN. */ |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6668 if (toplevel) |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6669 { |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6670 int add = TRUE; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6671 int c; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6672 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6673 if (prog->regstart != NUL && clen != 0) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6674 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6675 if (nextlist->n == 0) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6676 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6677 colnr_T col = (colnr_T)(reginput - regline) + clen; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6678 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6679 /* Nextlist is empty, we can skip ahead to the |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6680 * character that must appear at the start. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6681 if (skip_to_start(prog->regstart, &col) == FAIL) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6682 break; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6683 #ifdef ENABLE_LOG |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6684 fprintf(log_fd, " Skipping ahead %d bytes to regstart\n", |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6685 col - ((colnr_T)(reginput - regline) + clen)); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6686 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6687 reginput = regline + col - clen; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6688 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6689 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6690 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6691 /* Checking if the required start character matches is |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6692 * cheaper than adding a state that won't match. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6693 c = PTR2CHAR(reginput + clen); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6694 if (c != prog->regstart && (!ireg_ic || MB_TOLOWER(c) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6695 != MB_TOLOWER(prog->regstart))) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6696 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6697 #ifdef ENABLE_LOG |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6698 fprintf(log_fd, " Skipping start state, regstart does not match\n"); |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6699 #endif |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6700 add = FALSE; |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6701 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6702 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6703 } |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6704 |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6705 if (add) |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6706 { |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6707 if (REG_MULTI) |
6547 | 6708 m->norm.list.multi[0].start_col = |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6709 (colnr_T)(reginput - regline) + clen; |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6710 else |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6711 m->norm.list.line[0].start = reginput + clen; |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6712 addstate(nextlist, start->out, m, NULL, clen); |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6713 } |
4797
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6714 } |
a30e3762957d
updated for version 7.3.1145
Bram Moolenaar <bram@vim.org>
parents:
4787
diff
changeset
|
6715 else |
4813
bc3f4804cf47
updated for version 7.3.1153
Bram Moolenaar <bram@vim.org>
parents:
4811
diff
changeset
|
6716 addstate(nextlist, start, m, NULL, clen); |
4444 | 6717 } |
6718 | |
6719 #ifdef ENABLE_LOG | |
6720 fprintf(log_fd, ">>> Thislist had %d states available: ", thislist->n); | |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6721 { |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6722 int i; |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6723 |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6724 for (i = 0; i < thislist->n; i++) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6725 fprintf(log_fd, "%d ", abs(thislist->t[i].state->id)); |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6726 } |
4444 | 6727 fprintf(log_fd, "\n"); |
6728 #endif | |
6729 | |
6730 nextchar: | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6731 /* Advance to the next character, or advance to the next line, or |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6732 * finish. */ |
4549
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6733 if (clen != 0) |
849180347ac3
updated for version 7.3.1022
Bram Moolenaar <bram@vim.org>
parents:
4547
diff
changeset
|
6734 reginput += clen; |
4694
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6735 else if (go_to_nextline || (nfa_endp != NULL && REG_MULTI |
efc4fb311d5d
updated for version 7.3.1094
Bram Moolenaar <bram@vim.org>
parents:
4692
diff
changeset
|
6736 && reglnum < nfa_endp->se_u.pos.lnum)) |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6737 reg_nextline(); |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6738 else |
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6739 break; |
6499 | 6740 |
6741 /* Allow interrupting with CTRL-C. */ | |
6573 | 6742 line_breakcheck(); |
6499 | 6743 if (got_int) |
6744 break; | |
6573 | 6745 #ifdef FEAT_RELTIME |
6746 /* Check for timeout once in a twenty times to avoid overhead. */ | |
6747 if (nfa_time_limit != NULL && ++nfa_time_count == 20) | |
6748 { | |
6749 nfa_time_count = 0; | |
6750 if (profile_passed_limit(nfa_time_limit)) | |
6751 break; | |
6752 } | |
6753 #endif | |
4515
90e9917d4114
updated for version 7.3.1005
Bram Moolenaar <bram@vim.org>
parents:
4507
diff
changeset
|
6754 } |
4444 | 6755 |
6756 #ifdef ENABLE_LOG | |
6757 if (log_fd != stderr) | |
6758 fclose(log_fd); | |
6759 log_fd = NULL; | |
6760 #endif | |
6761 | |
6762 theend: | |
6763 /* Free memory */ | |
6764 vim_free(list[0].t); | |
6765 vim_free(list[1].t); | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
6766 vim_free(listids); |
4783
47222d8b1e94
updated for version 7.3.1138
Bram Moolenaar <bram@vim.org>
parents:
4781
diff
changeset
|
6767 #undef ADD_STATE_IF_MATCH |
4460 | 6768 #ifdef NFA_REGEXP_DEBUG_LOG |
4444 | 6769 fclose(debug); |
6770 #endif | |
6771 | |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
6772 return nfa_match; |
4444 | 6773 } |
6774 | |
6775 /* | |
6776 * Try match of "prog" with at regline["col"]. | |
6392 | 6777 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 6778 */ |
6779 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6780 nfa_regtry( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6781 nfa_regprog_T *prog, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6782 colnr_T col, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6783 proftime_T *tm UNUSED) /* timeout limit or NULL */ |
4444 | 6784 { |
6785 int i; | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6786 regsubs_T subs, m; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6787 nfa_state_T *start = prog->start; |
6328 | 6788 int result; |
4444 | 6789 #ifdef ENABLE_LOG |
6790 FILE *f; | |
6791 #endif | |
6792 | |
6793 reginput = regline + col; | |
6573 | 6794 #ifdef FEAT_RELTIME |
6795 nfa_time_limit = tm; | |
6796 nfa_time_count = 0; | |
6797 #endif | |
4444 | 6798 |
6799 #ifdef ENABLE_LOG | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
6800 f = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 6801 if (f != NULL) |
6802 { | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6803 fprintf(f, "\n\n\t=======================================================\n"); |
4444 | 6804 #ifdef DEBUG |
6805 fprintf(f, "\tRegexp is \"%s\"\n", nfa_regengine.expr); | |
6806 #endif | |
6807 fprintf(f, "\tInput text is \"%s\" \n", reginput); | |
4750
7793e737ec87
updated for version 7.3.1122
Bram Moolenaar <bram@vim.org>
parents:
4748
diff
changeset
|
6808 fprintf(f, "\t=======================================================\n\n"); |
4533
6a2005efa02b
updated for version 7.3.1014
Bram Moolenaar <bram@vim.org>
parents:
4531
diff
changeset
|
6809 nfa_print_state(f, start); |
4444 | 6810 fprintf(f, "\n\n"); |
6811 fclose(f); | |
6812 } | |
6813 else | |
6814 EMSG(_("Could not open temporary log file for writing ")); | |
6815 #endif | |
6816 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6817 clear_sub(&subs.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6818 clear_sub(&m.norm); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6819 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6820 clear_sub(&subs.synt); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6821 clear_sub(&m.synt); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6822 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6823 |
6328 | 6824 result = nfa_regmatch(prog, start, &subs, &m); |
6825 if (result == FALSE) | |
4444 | 6826 return 0; |
6328 | 6827 else if (result == NFA_TOO_EXPENSIVE) |
6828 return result; | |
4444 | 6829 |
6830 cleanup_subexpr(); | |
6831 if (REG_MULTI) | |
6832 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6833 for (i = 0; i < subs.norm.in_use; i++) |
4444 | 6834 { |
6547 | 6835 reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum; |
6836 reg_startpos[i].col = subs.norm.list.multi[i].start_col; | |
6837 | |
6838 reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum; | |
6839 reg_endpos[i].col = subs.norm.list.multi[i].end_col; | |
4444 | 6840 } |
6841 | |
6842 if (reg_startpos[0].lnum < 0) | |
6843 { | |
6844 reg_startpos[0].lnum = 0; | |
6845 reg_startpos[0].col = col; | |
6846 } | |
6847 if (reg_endpos[0].lnum < 0) | |
6848 { | |
4569
f262fb02889d
updated for version 7.3.1032
Bram Moolenaar <bram@vim.org>
parents:
4567
diff
changeset
|
6849 /* pattern has a \ze but it didn't match, use current end */ |
4444 | 6850 reg_endpos[0].lnum = reglnum; |
6851 reg_endpos[0].col = (int)(reginput - regline); | |
6852 } | |
6853 else | |
6854 /* Use line number of "\ze". */ | |
6855 reglnum = reg_endpos[0].lnum; | |
6856 } | |
6857 else | |
6858 { | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6859 for (i = 0; i < subs.norm.in_use; i++) |
4444 | 6860 { |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6861 reg_startp[i] = subs.norm.list.line[i].start; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6862 reg_endp[i] = subs.norm.list.line[i].end; |
4444 | 6863 } |
6864 | |
6865 if (reg_startp[0] == NULL) | |
6866 reg_startp[0] = regline + col; | |
6867 if (reg_endp[0] == NULL) | |
6868 reg_endp[0] = reginput; | |
6869 } | |
6870 | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6871 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6872 /* Package any found \z(...\) matches for export. Default is none. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6873 unref_extmatch(re_extmatch_out); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6874 re_extmatch_out = NULL; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6875 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6876 if (prog->reghasz == REX_SET) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6877 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6878 cleanup_zsubexpr(); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6879 re_extmatch_out = make_extmatch(); |
7258
7245d8635ac7
commit https://github.com/vim/vim/commit/5ad075c0735d3d8b97708d17c22de8facb15f997
Christian Brabandt <cb@256bit.org>
parents:
7152
diff
changeset
|
6880 /* Loop over \z1, \z2, etc. There is no \z0. */ |
7245d8635ac7
commit https://github.com/vim/vim/commit/5ad075c0735d3d8b97708d17c22de8facb15f997
Christian Brabandt <cb@256bit.org>
parents:
7152
diff
changeset
|
6881 for (i = 1; i < subs.synt.in_use; i++) |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6882 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6883 if (REG_MULTI) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6884 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6885 struct multipos *mpos = &subs.synt.list.multi[i]; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6886 |
5820 | 6887 /* Only accept single line matches that are valid. */ |
6547 | 6888 if (mpos->start_lnum >= 0 |
6889 && mpos->start_lnum == mpos->end_lnum | |
6890 && mpos->end_col >= mpos->start_col) | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6891 re_extmatch_out->matches[i] = |
6547 | 6892 vim_strnsave(reg_getline(mpos->start_lnum) |
6893 + mpos->start_col, | |
6894 mpos->end_col - mpos->start_col); | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6895 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6896 else |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6897 { |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6898 struct linepos *lpos = &subs.synt.list.line[i]; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6899 |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6900 if (lpos->start != NULL && lpos->end != NULL) |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6901 re_extmatch_out->matches[i] = |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6902 vim_strnsave(lpos->start, |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6903 (int)(lpos->end - lpos->start)); |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6904 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6905 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6906 } |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6907 #endif |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
6908 |
4444 | 6909 return 1 + reglnum; |
6910 } | |
6911 | |
6912 /* | |
6913 * Match a regexp against a string ("line" points to the string) or multiple | |
6914 * lines ("line" is NULL, use reg_getline()). | |
6915 * | |
6392 | 6916 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 6917 */ |
6918 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6919 nfa_regexec_both( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6920 char_u *line, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6921 colnr_T startcol, /* column to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
6922 proftime_T *tm) /* timeout limit or NULL */ |
4444 | 6923 { |
6924 nfa_regprog_T *prog; | |
6925 long retval = 0L; | |
6926 int i; | |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6927 colnr_T col = startcol; |
4444 | 6928 |
6929 if (REG_MULTI) | |
6930 { | |
6931 prog = (nfa_regprog_T *)reg_mmatch->regprog; | |
6932 line = reg_getline((linenr_T)0); /* relative to the cursor */ | |
6933 reg_startpos = reg_mmatch->startpos; | |
6934 reg_endpos = reg_mmatch->endpos; | |
6935 } | |
6936 else | |
6937 { | |
6938 prog = (nfa_regprog_T *)reg_match->regprog; | |
6939 reg_startp = reg_match->startp; | |
6940 reg_endp = reg_match->endp; | |
6941 } | |
6942 | |
6943 /* Be paranoid... */ | |
6944 if (prog == NULL || line == NULL) | |
6945 { | |
6946 EMSG(_(e_null)); | |
6947 goto theend; | |
6948 } | |
6949 | |
6950 /* If pattern contains "\c" or "\C": overrule value of ireg_ic */ | |
6951 if (prog->regflags & RF_ICASE) | |
6952 ireg_ic = TRUE; | |
6953 else if (prog->regflags & RF_NOICASE) | |
6954 ireg_ic = FALSE; | |
6955 | |
6956 #ifdef FEAT_MBYTE | |
6957 /* If pattern contains "\Z" overrule value of ireg_icombine */ | |
6958 if (prog->regflags & RF_ICOMBINE) | |
6959 ireg_icombine = TRUE; | |
6960 #endif | |
6961 | |
6962 regline = line; | |
6963 reglnum = 0; /* relative to line */ | |
6964 | |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
6965 nfa_has_zend = prog->has_zend; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
6966 nfa_has_backref = prog->has_backref; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
6967 nfa_nsubexpr = prog->nsubexp; |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
6968 nfa_listid = 1; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
6969 nfa_alt_listid = 2; |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
6970 nfa_regengine.expr = prog->pattern; |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
6971 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6972 if (prog->reganch && col > 0) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6973 return 0L; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6974 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6975 need_clear_subexpr = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6976 #ifdef FEAT_SYN_HL |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6977 /* Clear the external match subpointers if necessary. */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6978 if (prog->reghasz == REX_SET) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6979 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6980 nfa_has_zsubexpr = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6981 need_clear_zsubexpr = TRUE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6982 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6983 else |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6984 nfa_has_zsubexpr = FALSE; |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6985 #endif |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6986 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6987 if (prog->regstart != NUL) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6988 { |
4801
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6989 /* Skip ahead until a character we know the match must start with. |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6990 * When there is none there is no match. */ |
3cd3cc1e9119
updated for version 7.3.1147
Bram Moolenaar <bram@vim.org>
parents:
4799
diff
changeset
|
6991 if (skip_to_start(prog->regstart, &col) == FAIL) |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6992 return 0L; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
6993 |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6994 /* If match_text is set it contains the full text that must match. |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
6995 * Nothing else to try. Doesn't handle combining chars well. */ |
4811
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
6996 if (prog->match_text != NULL |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
6997 #ifdef FEAT_MBYTE |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
6998 && !ireg_icombine |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
6999 #endif |
9909e44879b9
updated for version 7.3.1152
Bram Moolenaar <bram@vim.org>
parents:
4809
diff
changeset
|
7000 ) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7001 return find_match_text(col, prog->regstart, prog->match_text); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7002 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7003 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7004 /* If the start column is past the maximum column: no need to try. */ |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7005 if (ireg_maxcol > 0 && col >= ireg_maxcol) |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7006 goto theend; |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7007 |
4444 | 7008 nstate = prog->nstate; |
7009 for (i = 0; i < nstate; ++i) | |
7010 { | |
7011 prog->state[i].id = i; | |
4718
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7012 prog->state[i].lastlist[0] = 0; |
ec72bb4a0fc2
updated for version 7.3.1106
Bram Moolenaar <bram@vim.org>
parents:
4716
diff
changeset
|
7013 prog->state[i].lastlist[1] = 0; |
4444 | 7014 } |
7015 | |
6573 | 7016 retval = nfa_regtry(prog, col, tm); |
4444 | 7017 |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7018 nfa_regengine.expr = NULL; |
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7019 |
4444 | 7020 theend: |
7021 return retval; | |
7022 } | |
7023 | |
7024 /* | |
7025 * Compile a regular expression into internal code for the NFA matcher. | |
7026 * Returns the program in allocated space. Returns NULL for an error. | |
7027 */ | |
7028 static regprog_T * | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7029 nfa_regcomp(char_u *expr, int re_flags) |
4444 | 7030 { |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7031 nfa_regprog_T *prog = NULL; |
4458 | 7032 size_t prog_size; |
4444 | 7033 int *postfix; |
7034 | |
7035 if (expr == NULL) | |
7036 return NULL; | |
7037 | |
7038 nfa_regengine.expr = expr; | |
6533 | 7039 nfa_re_flags = re_flags; |
4444 | 7040 |
7041 init_class_tab(); | |
7042 | |
7043 if (nfa_regcomp_start(expr, re_flags) == FAIL) | |
7044 return NULL; | |
7045 | |
7046 /* Build postfix form of the regexp. Needed to build the NFA | |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7047 * (and count its size). */ |
4444 | 7048 postfix = re2post(); |
7049 if (postfix == NULL) | |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7050 { |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7051 /* TODO: only give this error for debugging? */ |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7052 if (post_ptr >= post_end) |
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7053 EMSGN("Internal error: estimated max number of states insufficient: %ld", post_end - post_start); |
4444 | 7054 goto fail; /* Cascaded (syntax?) error */ |
4555
b2946c06d1b6
updated for version 7.3.1025
Bram Moolenaar <bram@vim.org>
parents:
4553
diff
changeset
|
7055 } |
4444 | 7056 |
7057 /* | |
7058 * In order to build the NFA, we parse the input regexp twice: | |
7059 * 1. first pass to count size (so we can allocate space) | |
7060 * 2. second to emit code | |
7061 */ | |
7062 #ifdef ENABLE_LOG | |
7063 { | |
4531
1be43c095aff
updated for version 7.3.1013
Bram Moolenaar <bram@vim.org>
parents:
4529
diff
changeset
|
7064 FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a"); |
4444 | 7065 |
7066 if (f != NULL) | |
7067 { | |
7068 fprintf(f, "\n*****************************\n\n\n\n\tCompiling regexp \"%s\" ... hold on !\n", expr); | |
7069 fclose(f); | |
7070 } | |
7071 } | |
7072 #endif | |
7073 | |
7074 /* | |
7075 * PASS 1 | |
7076 * Count number of NFA states in "nstate". Do not build the NFA. | |
7077 */ | |
7078 post2nfa(postfix, post_ptr, TRUE); | |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7079 |
4837
05b8436873d4
updated for version 7.3.1165
Bram Moolenaar <bram@vim.org>
parents:
4821
diff
changeset
|
7080 /* allocate the regprog with space for the compiled regexp */ |
05b8436873d4
updated for version 7.3.1165
Bram Moolenaar <bram@vim.org>
parents:
4821
diff
changeset
|
7081 prog_size = sizeof(nfa_regprog_T) + sizeof(nfa_state_T) * (nstate - 1); |
4541
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7082 prog = (nfa_regprog_T *)lalloc(prog_size, TRUE); |
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7083 if (prog == NULL) |
80170d61a85c
updated for version 7.3.1018
Bram Moolenaar <bram@vim.org>
parents:
4539
diff
changeset
|
7084 goto fail; |
4444 | 7085 state_ptr = prog->state; |
7086 | |
7087 /* | |
7088 * PASS 2 | |
7089 * Build the NFA | |
7090 */ | |
7091 prog->start = post2nfa(postfix, post_ptr, FALSE); | |
7092 if (prog->start == NULL) | |
7093 goto fail; | |
7094 | |
7095 prog->regflags = regflags; | |
7096 prog->engine = &nfa_regengine; | |
7097 prog->nstate = nstate; | |
4553
7b835b2969af
updated for version 7.3.1024
Bram Moolenaar <bram@vim.org>
parents:
4551
diff
changeset
|
7098 prog->has_zend = nfa_has_zend; |
4647
857f6c53f117
updated for version 7.3.1071
Bram Moolenaar <bram@vim.org>
parents:
4615
diff
changeset
|
7099 prog->has_backref = nfa_has_backref; |
4561
4d81fdda8f35
updated for version 7.3.1028
Bram Moolenaar <bram@vim.org>
parents:
4559
diff
changeset
|
7100 prog->nsubexp = regnpar; |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7101 |
4845
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
7102 nfa_postprocess(prog); |
a83fb2bd8c8e
updated for version 7.3.1169
Bram Moolenaar <bram@vim.org>
parents:
4837
diff
changeset
|
7103 |
4772
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7104 prog->reganch = nfa_get_reganch(prog->start, 0); |
03375ccf28a2
updated for version 7.3.1133
Bram Moolenaar <bram@vim.org>
parents:
4770
diff
changeset
|
7105 prog->regstart = nfa_get_regstart(prog->start, 0); |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7106 prog->match_text = nfa_get_match_text(prog->start); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7107 |
4444 | 7108 #ifdef ENABLE_LOG |
7109 nfa_postfix_dump(expr, OK); | |
7110 nfa_dump(prog); | |
7111 #endif | |
4686
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7112 #ifdef FEAT_SYN_HL |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7113 /* Remember whether this pattern has any \z specials in it. */ |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7114 prog->reghasz = re_has_z; |
8db697ae406a
updated for version 7.3.1090
Bram Moolenaar <bram@vim.org>
parents:
4682
diff
changeset
|
7115 #endif |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7116 prog->pattern = vim_strsave(expr); |
4690
9d97a0c045ef
updated for version 7.3.1092
Bram Moolenaar <bram@vim.org>
parents:
4688
diff
changeset
|
7117 nfa_regengine.expr = NULL; |
4444 | 7118 |
7119 out: | |
7120 vim_free(post_start); | |
7121 post_start = post_ptr = post_end = NULL; | |
7122 state_ptr = NULL; | |
7123 return (regprog_T *)prog; | |
7124 | |
7125 fail: | |
7126 vim_free(prog); | |
7127 prog = NULL; | |
7128 #ifdef ENABLE_LOG | |
7129 nfa_postfix_dump(expr, FAIL); | |
7130 #endif | |
7131 nfa_regengine.expr = NULL; | |
7132 goto out; | |
7133 } | |
7134 | |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7135 /* |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7136 * Free a compiled regexp program, returned by nfa_regcomp(). |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7137 */ |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7138 static void |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7139 nfa_regfree(regprog_T *prog) |
4805
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7140 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7141 if (prog != NULL) |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7142 { |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7143 vim_free(((nfa_regprog_T *)prog)->match_text); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7144 vim_free(((nfa_regprog_T *)prog)->pattern); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7145 vim_free(prog); |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7146 } |
66803af09906
updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents:
4801
diff
changeset
|
7147 } |
4444 | 7148 |
7149 /* | |
7150 * Match a regexp against a string. | |
7151 * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp(). | |
7152 * Uses curbuf for line count and 'iskeyword'. | |
5838 | 7153 * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break. |
4444 | 7154 * |
6392 | 7155 * Returns <= 0 for failure, number of lines contained in the match otherwise. |
4444 | 7156 */ |
7157 static int | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7158 nfa_regexec_nl( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7159 regmatch_T *rmp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7160 char_u *line, /* string to match against */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7161 colnr_T col, /* column to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7162 int line_lbr) |
4444 | 7163 { |
7164 reg_match = rmp; | |
7165 reg_mmatch = NULL; | |
7166 reg_maxline = 0; | |
5838 | 7167 reg_line_lbr = line_lbr; |
4444 | 7168 reg_buf = curbuf; |
7169 reg_win = NULL; | |
7170 ireg_ic = rmp->rm_ic; | |
7171 #ifdef FEAT_MBYTE | |
7172 ireg_icombine = FALSE; | |
7173 #endif | |
7174 ireg_maxcol = 0; | |
6573 | 7175 return nfa_regexec_both(line, col, NULL); |
4444 | 7176 } |
7177 | |
7178 | |
7179 /* | |
7180 * Match a regexp against multiple lines. | |
7181 * "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). | |
7182 * Uses curbuf for line count and 'iskeyword'. | |
7183 * | |
6392 | 7184 * Return <= 0 if there is no match. Return number of lines contained in the |
4444 | 7185 * match otherwise. |
7186 * | |
7187 * Note: the body is the same as bt_regexec() except for nfa_regexec_both() | |
7188 * | |
7189 * ! Also NOTE : match may actually be in another line. e.g.: | |
7190 * when r.e. is \nc, cursor is at 'a' and the text buffer looks like | |
7191 * | |
7192 * +-------------------------+ | |
7193 * |a | | |
7194 * |b | | |
7195 * |c | | |
7196 * | | | |
7197 * +-------------------------+ | |
7198 * | |
7199 * then nfa_regexec_multi() returns 3. while the original | |
7200 * vim_regexec_multi() returns 0 and a second call at line 2 will return 2. | |
7201 * | |
7202 * FIXME if this behavior is not compatible. | |
7203 */ | |
7204 static long | |
7833
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7205 nfa_regexec_multi( |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7206 regmmatch_T *rmp, |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7207 win_T *win, /* window in which to search or NULL */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7208 buf_T *buf, /* buffer in which to search */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7209 linenr_T lnum, /* nr of line to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7210 colnr_T col, /* column to start looking for match */ |
c079097365f3
commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents:
7805
diff
changeset
|
7211 proftime_T *tm) /* timeout limit or NULL */ |
4444 | 7212 { |
7213 reg_match = NULL; | |
7214 reg_mmatch = rmp; | |
7215 reg_buf = buf; | |
7216 reg_win = win; | |
7217 reg_firstlnum = lnum; | |
7218 reg_maxline = reg_buf->b_ml.ml_line_count - lnum; | |
7219 reg_line_lbr = FALSE; | |
7220 ireg_ic = rmp->rmm_ic; | |
7221 #ifdef FEAT_MBYTE | |
7222 ireg_icombine = FALSE; | |
7223 #endif | |
7224 ireg_maxcol = rmp->rmm_maxcol; | |
7225 | |
6573 | 7226 return nfa_regexec_both(NULL, col, tm); |
4444 | 7227 } |
7228 | |
7229 #ifdef DEBUG | |
7230 # undef ENABLE_LOG | |
7231 #endif |