+bool LangInfo::discardParethesizedInBlock(int start)
+{
+ int depth = 0;
+ int skip = 0;
+ bool isempty = true;
+
+ size_t regex_start, regex_end;
+ if (regexPossible) {
+ regex_start = par.find("\\regexp{", start);
+ if (regex_start == string::npos)
+ regexPossible = false;
+ else if (regex_start >= size_t(_dataEnd))
+ regexPossible = false;
+ else {
+ regex_end = par.find("\\endregexp{}}", regex_start + 8);
+ if (regex_end == string::npos)
+ regexPossible = false;
+ else if (regex_end > size_t(_dataEnd))
+ regexPossible = false;
+ }
+ }
+ if (!regexPossible) {
+ regex_start = _dataEnd;
+ regex_end = _dataEnd;
+ }
+ for (int i = start; i < _dataEnd; i += 1+skip) {
+ char c = par[i];
+ skip = 0;
+ if (c == '\\') {
+ if (size_t(i) == regex_start) {
+ // 12 is correct, even if the length of "\\endregexp{}}" is 13
+ skip = regex_end + 12 - i;
+ }
+ else
+ skip = 1;
+ isempty = false;
+ }
+ else if (c == '{') {
+ if (depth == 0) {
+ addIntervall(i, i+1);
+ // cout << "discard '{' at " << i << "\n";
+ }
+ else
+ isempty = false;
+ depth++;
+ }
+ else if (c == '}') {
+ if (depth == 1) {
+ addIntervall(i, i+1);
+ // cout << "discard '}' at " << i << "\n";
+ }
+ else if (depth < 1)
+ break;
+ depth--;
+ }
+ else
+ isempty = false;
+ }
+ return(isempty);
+}
+
+bool LangInfo::discarSuperfluousParentheses(int start)
+{
+ start = nextNotIgored(start);
+ while ((par[start] == '{') && (start < _dataEnd)) {
+ discardParethesizedInBlock(start);
+ start = nextNotIgored(start+1);
+ }
+ // It is empty if (par[start] == '}')
+ return ((start >= _dataEnd) || (par[start] == '}'));
+}
+