[colorer/Colorer-library] cregexp_refactoring: Remove unused CRegExp ops ReMul/RePlus/ReQuest/ReNG* and ReNEnum. (d17db31)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Aug 16, 2026, 1:46:21 PM (14 hours ago) Aug 16
to farco...@googlegroups.com
Repository : https://github.com/colorer/Colorer-library
On branch : cregexp_refactoring
Link : https://github.com/colorer/Colorer-library/commit/d17db3132f71bd6357638109718c8f01b41a6361

>---------------------------------------------------------------

commit d17db3132f71bd6357638109718c8f01b41a6361
Author: Aleksey Dobrunov <cta...@ctapmex.com>
Date: Sun Aug 16 22:41:13 2026 +0500

Remove unused CRegExp ops ReMul/RePlus/ReQuest/ReNG* and ReNEnum.


>---------------------------------------------------------------

d17db3132f71bd6357638109718c8f01b41a6361
src/colorer/cregexp/cregexp.cpp | 32 +++-----------------------------
src/colorer/cregexp/cregexp.h | 21 +++++++--------------
2 files changed, 10 insertions(+), 43 deletions(-)

diff --git a/src/colorer/cregexp/cregexp.cpp b/src/colorer/cregexp/cregexp.cpp
index 390ac2c..d63a2db 100644
--- a/src/colorer/cregexp/cregexp.cpp
+++ b/src/colorer/cregexp/cregexp.cpp
@@ -40,7 +40,6 @@ SRegInfo::~SRegInfo()
if (un.param)
switch (op) {
case EOps::ReEnum:
- case EOps::ReNEnum:
delete un.charclass;
break;
case EOps::ReWord:
@@ -186,8 +185,7 @@ void CRegExp::optimize()
}
break;
}
- if (next->op == EOps::ReSymb || next->op == EOps::ReWord ||
- next->op == EOps::ReEnum || next->op == EOps::ReNEnum) {
+ if (next->op == EOps::ReSymb || next->op == EOps::ReWord || next->op == EOps::ReEnum) {
firstNode = next;
}
break;
@@ -230,9 +228,8 @@ CRegExp::FirstChars CRegExp::firstCharsForNode(const SRegInfo* re) const
else result.nullable = true;
break;
case EOps::ReEnum:
- case EOps::ReNEnum:
for (uint32_t ch = 0; ch < 128; ch++) {
- if (re->un.charclass->contains(static_cast<wchar>(ch)) == (re->op == EOps::ReEnum)) {
+ if (re->un.charclass->contains(static_cast<wchar>(ch))) {
result.mask[ch >> 6] |= uint64_t(1) << (ch & 63);
}
}
@@ -676,7 +673,6 @@ EError CRegExp::setStructs(SRegInfo*& re, const UnicodeString& expr, int& retPos
auto cc = UStr::createCharClass(expr, i, &endPos, ignoreCase);
if (cc == nullptr)
return EError::EENUM;
- // next->op = (exprn[i] == ReEnumS) ? ReEnum : ReNEnum;
next->op = EOps::ReEnum;
next->un.charclass = cc.release();
i = endPos;
@@ -1053,17 +1049,6 @@ bool CRegExp::lowParse(SRegInfo* re, SRegInfo* prev, int toParse)
}
toParse++;
break;
- case EOps::ReNEnum:
- if (toParse >= end) {
- check_stack(false, &re, &prev, &toParse, &leftenter, &action);
- continue;
- }
- if (re->un.charclass->contains(pattern[toParse])) {
- check_stack(false, &re, &prev, &toParse, &leftenter, &action);
- continue;
- }
- toParse++;
- break;
#ifdef COLORERMODE
case EOps::ReBkTrace:
sv = re->param0;
@@ -1335,12 +1320,6 @@ bool CRegExp::lowParse(SRegInfo* re, SRegInfo* prev, int toParse)
leftenter = true;
continue;
case EOps::ReBlockOps:
- case EOps::ReMul:
- case EOps::RePlus:
- case EOps::ReQuest:
- case EOps::ReNGMul:
- case EOps::ReNGPlus:
- case EOps::ReNGQuest:
case EOps::ReSymbolOps:
break;
}
@@ -1431,8 +1410,6 @@ bool CRegExp::canStartWith(wchar ch) const
return matchChars(ch, (*firstNode->un.word)[0]);
case EOps::ReEnum:
return firstNode->un.charclass->contains(ch);
- case EOps::ReNEnum:
- return !firstNode->un.charclass->contains(ch);
case EOps::ReMetaSymb:
switch (firstNode->un.metaSymbol) {
case EMetaSymbols::ReAnyChr:
@@ -1469,10 +1446,7 @@ inline bool CRegExp::quickCheck(int toParse)
case EOps::ReWord:
return toParse < end && matchChars((*global_pattern)[toParse], (*firstNode->un.word)[0]);
case EOps::ReEnum:
- case EOps::ReNEnum:
- return toParse < end &&
- (firstNode->un.charclass->contains((*global_pattern)[toParse]) ==
- (firstNode->op == EOps::ReEnum));
+ return toParse < end && firstNode->un.charclass->contains((*global_pattern)[toParse]);
case EOps::ReMetaSymb:
switch (firstNode->un.metaSymbol) {
#ifdef COLORERMODE
diff --git a/src/colorer/cregexp/cregexp.h b/src/colorer/cregexp/cregexp.h
index 3a58523..33dc5b5 100644
--- a/src/colorer/cregexp/cregexp.h
+++ b/src/colorer/cregexp/cregexp.h
@@ -21,30 +21,23 @@
#define NAMED_MATCHES_NUM 0x10

enum class EOps {
- ReBlockOps,
- ReMul, // *
- RePlus, // +
- ReQuest, // ?
- ReNGMul, // *?
- ReNGPlus, // +?
- ReNGQuest, // ??
- ReRangeN, // {n,}
- ReRangeNM, // {n,m}
- ReNGRangeN, // {n,}?
- ReNGRangeNM, // {n,m}?
+ ReBlockOps, // sentinel: postfix operators follow
+ ReRangeN, // {n,} * +
+ ReRangeNM, // {n,m} ?
+ ReNGRangeN, // {n,}? *? +?
+ ReNGRangeNM, // {n,m}? ??
ReOr, // |
ReBehind, // ?#n
ReNBehind, // ?~n
ReAhead, // ?=
ReNAhead, // ?!

- ReSymbolOps,
+ ReSymbolOps, // sentinel: atoms follow
ReEmpty,
ReMetaSymb, // \W \s \d ...
ReSymb, // a b c ...
ReWord, // word...
- ReEnum, // []
- ReNEnum, // [^]
+ ReEnum, // [] [^]
ReBrackets, // (...)
ReNamedBrackets, // (?{name} ...)
#ifdef COLORERMODE


Reply all
Reply to author
Forward
0 new messages