| OLD | NEW |
| 1 | 1 |
| 2 // | 2 // |
| 3 // file: regexcmp.cpp | 3 // file: regexcmp.cpp |
| 4 // | 4 // |
| 5 // Copyright (C) 2002-2007 International Business Machines Corporation and othe
rs. | 5 // Copyright (C) 2002-2008 International Business Machines Corporation and othe
rs. |
| 6 // All Rights Reserved. | 6 // All Rights Reserved. |
| 7 // | 7 // |
| 8 // This file contains the ICU regular expression compiler, which is responsible | 8 // This file contains the ICU regular expression compiler, which is responsible |
| 9 // for processing a regular expression pattern into the compiled form that | 9 // for processing a regular expression pattern into the compiled form that |
| 10 // is used by the match finding engine. | 10 // is used by the match finding engine. |
| 11 // | 11 // |
| 12 | 12 |
| 13 #include "unicode/utypes.h" | 13 #include "unicode/utypes.h" |
| 14 | 14 |
| 15 #if !UCONFIG_NO_REGULAR_EXPRESSIONS | 15 #if !UCONFIG_NO_REGULAR_EXPRESSIONS |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 break; | 1179 break; |
| 1180 } | 1180 } |
| 1181 nextCharLL(); | 1181 nextCharLL(); |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 // Scan of the back reference in the source regexp is complete. Now
generate | 1184 // Scan of the back reference in the source regexp is complete. Now
generate |
| 1185 // the compiled code for it. | 1185 // the compiled code for it. |
| 1186 // Because capture groups can be forward-referenced by back-referenc
es, | 1186 // Because capture groups can be forward-referenced by back-referenc
es, |
| 1187 // we fill the operand with the capture group number. At the end | 1187 // we fill the operand with the capture group number. At the end |
| 1188 // of compilation, it will be changed to the variable's location. | 1188 // of compilation, it will be changed to the variable's location. |
| 1189 U_ASSERT(groupNum > 0); | 1189 if (groupNum < 1) { |
| 1190 int32_t op; | 1190 error(U_REGEX_INVALID_BACK_REF); |
| 1191 if (fModeFlags & UREGEX_CASE_INSENSITIVE) { | |
| 1192 op = URX_BUILD(URX_BACKREF_I, groupNum); | |
| 1193 } else { | 1191 } else { |
| 1194 op = URX_BUILD(URX_BACKREF, groupNum); | 1192 int32_t op; |
| 1193 if (fModeFlags & UREGEX_CASE_INSENSITIVE) { |
| 1194 op = URX_BUILD(URX_BACKREF_I, groupNum); |
| 1195 } else { |
| 1196 op = URX_BUILD(URX_BACKREF, groupNum); |
| 1197 } |
| 1198 fRXPat->fCompiledPat->addElement(op, *fStatus); |
| 1195 } | 1199 } |
| 1196 fRXPat->fCompiledPat->addElement(op, *fStatus); | |
| 1197 } | 1200 } |
| 1198 break; | 1201 break; |
| 1199 | 1202 |
| 1200 | 1203 |
| 1201 case doPossessivePlus: | 1204 case doPossessivePlus: |
| 1202 // Possessive ++ quantifier. | 1205 // Possessive ++ quantifier. |
| 1203 // Compiles to | 1206 // Compiles to |
| 1204 // 1. STO_SP | 1207 // 1. STO_SP |
| 1205 // 2. body of stuff being iterated over | 1208 // 2. body of stuff being iterated over |
| 1206 // 3. STATE_SAVE 5 | 1209 // 3. STATE_SAVE 5 |
| (...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3520 uset = NULL; | 3523 uset = NULL; |
| 3521 } | 3524 } |
| 3522 | 3525 |
| 3523 nextChar(fC); // Continue overall regex pattern processing with char af
ter the '}' | 3526 nextChar(fC); // Continue overall regex pattern processing with char af
ter the '}' |
| 3524 return uset; | 3527 return uset; |
| 3525 } | 3528 } |
| 3526 | 3529 |
| 3527 U_NAMESPACE_END | 3530 U_NAMESPACE_END |
| 3528 #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS | 3531 #endif // !UCONFIG_NO_REGULAR_EXPRESSIONS |
| 3529 | 3532 |
| OLD | NEW |