From f28d7f50a8b696aca96429b77ce9f13494dad56c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Jul 2026 14:56:42 +0000 Subject: [PATCH] Remove named capture group support from C++ ECMAScript regex parser --- .../semmle/code/cpp/regex/RegexTreeView.qll | 22 +- .../code/cpp/regex/internal/ParseRegExp.qll | 53 +- .../library-tests/regex/locations.expected | 208 ++++---- .../test/library-tests/regex/parse.expected | 337 ++++++------- .../test/library-tests/regex/regexp.expected | 469 +++++++++--------- cpp/ql/test/library-tests/regex/regexp.ql | 2 - cpp/ql/test/library-tests/regex/test.cpp | 5 +- 7 files changed, 490 insertions(+), 606 deletions(-) diff --git a/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll b/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll index 477b953739f..cec907476a7 100644 --- a/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll +++ b/cpp/ql/lib/semmle/code/cpp/regex/RegexTreeView.qll @@ -873,7 +873,6 @@ private module Impl implements RegexTreeViewSig { * ``` * (ECMA|Java) * (?:ECMA|Java) - * (?['"]) * ``` */ class RegExpGroup extends RegExpTerm, TRegExpGroup { @@ -893,12 +892,6 @@ private module Impl implements RegexTreeViewSig { /** Holds if this is a capture group. */ predicate isCapture() { exists(this.getNumber()) } - /** Holds if this is a named capture group. */ - predicate isNamed() { exists(this.getName()) } - - /** Gets the name of this capture group, if any. */ - string getName() { result = re.getGroupName(start, end) } - override RegExpTerm getChild(int i) { result.getRegExp() = re and i = 0 and @@ -1148,14 +1141,13 @@ private module Impl implements RegexTreeViewSig { } /** - * A back reference, that is, a term of the form `\i` or `\k` + * A back reference, that is, a term of the form `\i` * in a regular expression. * - * Examples: + * Example: * * ``` * \1 - * \k * ``` */ class RegExpBackRef extends RegExpTerm, TRegExpBackRef { @@ -1166,18 +1158,10 @@ private module Impl implements RegexTreeViewSig { */ int getNumber() { result = re.getBackRefNumber(start, end) } - /** - * Gets the name of the capture group this back reference refers to, if any. - */ - string getName() { result = re.getBackRefName(start, end) } - /** Gets the capture group this back reference refers to. */ RegExpGroup getGroup() { result.getLiteral() = this.getLiteral() and - ( - result.getNumber() = this.getNumber() or - result.getName() = this.getName() - ) + result.getNumber() = this.getNumber() } override RegExpTerm getChild(int i) { none() } diff --git a/cpp/ql/lib/semmle/code/cpp/regex/internal/ParseRegExp.qll b/cpp/ql/lib/semmle/code/cpp/regex/internal/ParseRegExp.qll index 326b3e7ae15..b786f8e020b 100644 --- a/cpp/ql/lib/semmle/code/cpp/regex/internal/ParseRegExp.qll +++ b/cpp/ql/lib/semmle/code/cpp/regex/internal/ParseRegExp.qll @@ -400,7 +400,6 @@ class RegExp extends StringLiteral { predicate escapedCharacter(int start, int end) { this.escapingChar(start) and not this.numberedBackreference(start, _, _) and - not this.namedBackreference(start, _, _) and ( // hex char \xhh this.getChar(start + 1) = "x" and end = start + 4 @@ -573,15 +572,6 @@ class RegExp extends StringLiteral { count(int i | this.group(i, _) and i < start and not this.nonCapturingGroupStart(i, _)) + 1 } - /** Gets the name, if it has one, of the group in start,end */ - string getGroupName(int start, int end) { - this.group(start, end) and - exists(int nameEnd | - this.namedGroupStart(start, nameEnd) and - result = this.getText().substring(start + 3, nameEnd - 1) - ) - } - /** Whether the text in the range start, end is a group and can match the empty string. */ predicate zeroWidthMatch(int start, int end) { this.emptyGroup(start, end) @@ -658,8 +648,6 @@ class RegExp extends StringLiteral { private predicate groupStart(int start, int end) { this.nonCapturingGroupStart(start, end) or - this.namedGroupStart(start, end) - or this.lookaheadAssertionStart(start, end) or this.negativeLookaheadAssertionStart(start, end) @@ -676,8 +664,8 @@ class RegExp extends StringLiteral { /** * Matches the start of a non-capturing group. * ECMAScript non-capturing groups: `(?:`, lookaheads `(?=`/`(?!`, comments `(?#`. - * Note: `(?<` is intentionally excluded here — it is handled by `namedGroupStart` - * and `lookbehindAssertionStart`. + * Note: `(?<` is intentionally excluded here — it is handled by + * `lookbehindAssertionStart` and `negativeLookbehindAssertionStart`. */ private predicate nonCapturingGroupStart(int start, int end) { this.isGroupStart(start) and @@ -693,23 +681,6 @@ class RegExp extends StringLiteral { end = start + 1 } - /** - * Matches the start of a named group, such as: - * - `(?\w+)` (ECMAScript named group) - * Note: Ruby-only `(?'name'\w+)` single-quote form is removed. - */ - private predicate namedGroupStart(int start, int end) { - this.isGroupStart(start) and - this.getChar(start + 1) = "?" and - this.getChar(start + 2) = "<" and - not this.getChar(start + 3) = "=" and // (?<=foo) is a positive lookbehind assertion - not this.getChar(start + 3) = "!" and // (? start + 3 and this.getChar(i) = ">") and - end = nameEnd + 1 - ) - } - /** Matches the start of a positive lookahead assertion, i.e. `(?=`. */ private predicate lookaheadAssertionStart(int start, int end) { this.isGroupStart(start) and @@ -760,17 +731,6 @@ class RegExp extends StringLiteral { this.isGroupEnd(inEnd) } - /** Matches a named backreference, e.g. `\k`. */ - predicate namedBackreference(int start, int end, string name) { - this.escapingChar(start) and - this.getChar(start + 1) = "k" and - this.getChar(start + 2) = "<" and - exists(int nameEnd | nameEnd = min(int i | i > start + 3 and this.getChar(i) = ">") | - end = nameEnd + 1 and - name = this.getText().substring(start + 3, nameEnd) - ) - } - /** Matches a numbered backreference, e.g. `\1`. */ predicate numberedBackreference(int start, int end, int value) { this.escapingChar(start) and @@ -788,18 +748,11 @@ class RegExp extends StringLiteral { } /** Whether the text in the range `start,end` is a back reference */ - predicate backreference(int start, int end) { - this.numberedBackreference(start, end, _) - or - this.namedBackreference(start, end, _) - } + predicate backreference(int start, int end) { this.numberedBackreference(start, end, _) } /** Gets the number of the back reference in start,end */ int getBackRefNumber(int start, int end) { this.numberedBackreference(start, end, result) } - /** Gets the name, if it has one, of the back reference in start,end */ - string getBackRefName(int start, int end) { this.namedBackreference(start, end, result) } - private predicate baseItem(int start, int end) { this.characterItem(start, end) and not exists(int x, int y | this.charSet(x, y) and x <= start and y >= end) diff --git a/cpp/ql/test/library-tests/regex/locations.expected b/cpp/ql/test/library-tests/regex/locations.expected index 8b3a01df017..3730bc17f50 100644 --- a/cpp/ql/test/library-tests/regex/locations.expected +++ b/cpp/ql/test/library-tests/regex/locations.expected @@ -1,104 +1,104 @@ -| test.cpp:143:24:143:32 | [[:alpha] | 23 | 0 | 9 | 24 | 32 | -| test.cpp:143:25:143:25 | [ | 23 | 1 | 2 | 25 | 25 | -| test.cpp:143:26:143:26 | : | 23 | 2 | 3 | 26 | 26 | -| test.cpp:143:27:143:27 | a | 23 | 3 | 4 | 27 | 27 | -| test.cpp:143:28:143:28 | l | 23 | 4 | 5 | 28 | 28 | -| test.cpp:143:29:143:29 | p | 23 | 5 | 6 | 29 | 29 | -| test.cpp:143:30:143:30 | h | 23 | 6 | 7 | 30 | 30 | -| test.cpp:143:31:143:31 | a | 23 | 7 | 8 | 31 | 31 | -| test.cpp:146:24:146:35 | []a[:alpha:] | 23 | 0 | 12 | 24 | 35 | -| test.cpp:146:24:146:36 | []a[:alpha:]] | 23 | 0 | 13 | 24 | 36 | -| test.cpp:146:25:146:25 | ] | 23 | 1 | 2 | 25 | 25 | -| test.cpp:146:26:146:26 | a | 23 | 2 | 3 | 26 | 26 | -| test.cpp:146:27:146:27 | [ | 23 | 3 | 4 | 27 | 27 | -| test.cpp:146:28:146:28 | : | 23 | 4 | 5 | 28 | 28 | -| test.cpp:146:29:146:29 | a | 23 | 5 | 6 | 29 | 29 | -| test.cpp:146:30:146:30 | l | 23 | 6 | 7 | 30 | 30 | -| test.cpp:146:31:146:31 | p | 23 | 7 | 8 | 31 | 31 | -| test.cpp:146:32:146:32 | h | 23 | 8 | 9 | 32 | 32 | -| test.cpp:146:33:146:33 | a | 23 | 9 | 10 | 33 | 33 | -| test.cpp:146:34:146:34 | : | 23 | 10 | 11 | 34 | 34 | -| test.cpp:146:36:146:36 | ] | 23 | 12 | 13 | 36 | 36 | -| test.cpp:149:25:149:53 | [[:alpha:][:digit:][:space:]] | 24 | 0 | 29 | 25 | 53 | -| test.cpp:149:26:149:34 | [:alpha:] | 24 | 1 | 10 | 26 | 34 | -| test.cpp:149:35:149:43 | [:digit:] | 24 | 10 | 19 | 35 | 43 | -| test.cpp:149:44:149:52 | [:space:] | 24 | 19 | 28 | 44 | 52 | -| test.cpp:152:25:152:36 | [[:xdigit:]] | 24 | 0 | 12 | 25 | 36 | -| test.cpp:152:26:152:35 | [:xdigit:] | 24 | 1 | 11 | 26 | 35 | -| test.cpp:153:25:153:35 | [[:blank:]] | 24 | 0 | 11 | 25 | 35 | -| test.cpp:153:26:153:34 | [:blank:] | 24 | 1 | 10 | 26 | 34 | -| test.cpp:154:25:154:35 | [[:cntrl:]] | 24 | 0 | 11 | 25 | 35 | -| test.cpp:154:26:154:34 | [:cntrl:] | 24 | 1 | 10 | 26 | 34 | -| test.cpp:155:25:155:35 | [[:graph:]] | 24 | 0 | 11 | 25 | 35 | -| test.cpp:155:26:155:34 | [:graph:] | 24 | 1 | 10 | 26 | 34 | -| test.cpp:158:25:158:25 | ^ | 24 | 0 | 1 | 25 | 25 | -| test.cpp:158:25:158:92 | ^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]\|[[:xdigit:]])+$ | 24 | 0 | 68 | 25 | 92 | -| test.cpp:158:26:158:63 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?) | 24 | 1 | 39 | 26 | 63 | -| test.cpp:158:26:158:64 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ | 24 | 1 | 40 | 26 | 64 | -| test.cpp:158:27:158:37 | [[:alpha:]] | 24 | 2 | 13 | 27 | 37 | -| test.cpp:158:27:158:38 | [[:alpha:]]+ | 24 | 2 | 14 | 27 | 38 | -| test.cpp:158:27:158:62 | [[:alpha:]]+[[:digit:]]*[[:space:]]? | 24 | 2 | 38 | 27 | 62 | -| test.cpp:158:28:158:36 | [:alpha:] | 24 | 3 | 12 | 28 | 36 | -| test.cpp:158:39:158:49 | [[:digit:]] | 24 | 14 | 25 | 39 | 49 | -| test.cpp:158:39:158:50 | [[:digit:]]* | 24 | 14 | 26 | 39 | 50 | -| test.cpp:158:40:158:48 | [:digit:] | 24 | 15 | 24 | 40 | 48 | -| test.cpp:158:51:158:61 | [[:space:]] | 24 | 26 | 37 | 51 | 61 | -| test.cpp:158:51:158:62 | [[:space:]]? | 24 | 26 | 38 | 51 | 62 | -| test.cpp:158:52:158:60 | [:space:] | 24 | 27 | 36 | 52 | 60 | -| test.cpp:158:65:158:90 | ([[:punct:]]\|[[:xdigit:]]) | 24 | 40 | 66 | 65 | 90 | -| test.cpp:158:65:158:91 | ([[:punct:]]\|[[:xdigit:]])+ | 24 | 40 | 67 | 65 | 91 | -| test.cpp:158:66:158:76 | [[:punct:]] | 24 | 41 | 52 | 66 | 76 | -| test.cpp:158:66:158:89 | [[:punct:]]\|[[:xdigit:]] | 24 | 41 | 65 | 66 | 89 | -| test.cpp:158:67:158:75 | [:punct:] | 24 | 42 | 51 | 67 | 75 | -| test.cpp:158:78:158:89 | [[:xdigit:]] | 24 | 53 | 65 | 78 | 89 | -| test.cpp:158:79:158:88 | [:xdigit:] | 24 | 54 | 64 | 79 | 88 | -| test.cpp:158:92:158:92 | $ | 24 | 67 | 68 | 92 | 92 | -| test.cpp:163:21:163:26 | \\u9879 | 20 | 0 | 6 | 21 | 26 | -| test.cpp:171:23:171:23 | a | 22 | 0 | 1 | 23 | 23 | -| test.cpp:171:23:171:24 | a+ | 22 | 0 | 2 | 23 | 24 | -| test.cpp:171:23:171:25 | a+b | 22 | 0 | 3 | 23 | 25 | -| test.cpp:171:25:171:25 | b | 22 | 2 | 3 | 25 | 25 | -| test.cpp:174:23:174:23 | a | 20 | 0 | 1 | 23 | 23 | -| test.cpp:174:23:174:24 | a+ | 20 | 0 | 2 | 23 | 24 | -| test.cpp:174:23:174:25 | a+b | 20 | 0 | 3 | 23 | 25 | -| test.cpp:174:25:174:25 | b | 20 | 2 | 3 | 25 | 25 | -| test.cpp:177:24:177:25 | \\s | 21 | 0 | 2 | 24 | 25 | -| test.cpp:177:24:177:26 | \\s+ | 21 | 0 | 3 | 24 | 26 | -| test.cpp:177:24:177:27 | \\s+$ | 21 | 0 | 4 | 24 | 27 | -| test.cpp:177:27:177:27 | $ | 21 | 3 | 4 | 27 | 27 | -| test.cpp:180:24:180:25 | \\( | 21 | 0 | 2 | 24 | 25 | -| test.cpp:180:24:180:37 | \\(([,\\w]+)+\\)$ | 21 | 0 | 14 | 24 | 37 | -| test.cpp:180:26:180:33 | ([,\\w]+) | 21 | 2 | 10 | 26 | 33 | -| test.cpp:180:26:180:34 | ([,\\w]+)+ | 21 | 2 | 11 | 26 | 34 | -| test.cpp:180:27:180:31 | [,\\w] | 21 | 3 | 8 | 27 | 31 | -| test.cpp:180:27:180:32 | [,\\w]+ | 21 | 3 | 9 | 27 | 32 | -| test.cpp:180:28:180:28 | , | 21 | 4 | 5 | 28 | 28 | -| test.cpp:180:29:180:30 | \\w | 21 | 5 | 7 | 29 | 30 | -| test.cpp:180:35:180:36 | \\) | 21 | 11 | 13 | 35 | 36 | -| test.cpp:180:37:180:37 | $ | 21 | 13 | 14 | 37 | 37 | -| test.cpp:183:25:183:25 | a | 21 | 0 | 1 | 25 | 25 | -| test.cpp:183:25:183:26 | a+ | 21 | 0 | 2 | 25 | 26 | -| test.cpp:183:25:183:27 | a+b | 21 | 0 | 3 | 25 | 27 | -| test.cpp:183:27:183:27 | b | 21 | 2 | 3 | 27 | 27 | -| test.cpp:186:24:186:24 | a | 22 | 0 | 1 | 24 | 24 | -| test.cpp:186:24:186:25 | a+ | 22 | 0 | 2 | 24 | 25 | -| test.cpp:186:24:186:26 | a+b | 22 | 0 | 3 | 24 | 26 | -| test.cpp:186:26:186:26 | b | 22 | 2 | 3 | 26 | 26 | -| test.cpp:189:30:189:30 | a | 26 | 0 | 1 | 30 | 30 | -| test.cpp:189:30:189:31 | a+ | 26 | 0 | 2 | 30 | 31 | -| test.cpp:189:30:189:32 | a+b | 26 | 0 | 3 | 30 | 32 | -| test.cpp:189:32:189:32 | b | 26 | 2 | 3 | 32 | 32 | -| test.cpp:193:22:193:23 | \\s | 21 | 0 | 2 | 22 | 23 | -| test.cpp:193:22:193:24 | \\s+ | 21 | 0 | 3 | 22 | 24 | -| test.cpp:196:22:196:22 | a | 21 | 0 | 1 | 22 | 22 | -| test.cpp:196:22:196:25 | a\\.b | 21 | 0 | 4 | 22 | 25 | -| test.cpp:196:23:196:24 | \\. | 21 | 1 | 3 | 23 | 24 | -| test.cpp:196:25:196:25 | b | 21 | 3 | 4 | 25 | 25 | -| test.cpp:200:22:200:22 | a | 19 | 0 | 1 | 22 | 22 | -| test.cpp:200:22:200:23 | a+ | 19 | 0 | 2 | 22 | 23 | -| test.cpp:200:22:200:24 | a+b | 19 | 0 | 3 | 22 | 24 | -| test.cpp:200:24:200:24 | b | 19 | 2 | 3 | 24 | 24 | -| test.cpp:203:28:203:28 | a | 23 | 0 | 1 | 28 | 28 | -| test.cpp:203:28:203:29 | a+ | 23 | 0 | 2 | 28 | 29 | -| test.cpp:203:28:203:30 | a+b | 23 | 0 | 3 | 28 | 30 | -| test.cpp:203:30:203:30 | b | 23 | 2 | 3 | 30 | 30 | +| test.cpp:142:24:142:32 | [[:alpha] | 23 | 0 | 9 | 24 | 32 | +| test.cpp:142:25:142:25 | [ | 23 | 1 | 2 | 25 | 25 | +| test.cpp:142:26:142:26 | : | 23 | 2 | 3 | 26 | 26 | +| test.cpp:142:27:142:27 | a | 23 | 3 | 4 | 27 | 27 | +| test.cpp:142:28:142:28 | l | 23 | 4 | 5 | 28 | 28 | +| test.cpp:142:29:142:29 | p | 23 | 5 | 6 | 29 | 29 | +| test.cpp:142:30:142:30 | h | 23 | 6 | 7 | 30 | 30 | +| test.cpp:142:31:142:31 | a | 23 | 7 | 8 | 31 | 31 | +| test.cpp:145:24:145:35 | []a[:alpha:] | 23 | 0 | 12 | 24 | 35 | +| test.cpp:145:24:145:36 | []a[:alpha:]] | 23 | 0 | 13 | 24 | 36 | +| test.cpp:145:25:145:25 | ] | 23 | 1 | 2 | 25 | 25 | +| test.cpp:145:26:145:26 | a | 23 | 2 | 3 | 26 | 26 | +| test.cpp:145:27:145:27 | [ | 23 | 3 | 4 | 27 | 27 | +| test.cpp:145:28:145:28 | : | 23 | 4 | 5 | 28 | 28 | +| test.cpp:145:29:145:29 | a | 23 | 5 | 6 | 29 | 29 | +| test.cpp:145:30:145:30 | l | 23 | 6 | 7 | 30 | 30 | +| test.cpp:145:31:145:31 | p | 23 | 7 | 8 | 31 | 31 | +| test.cpp:145:32:145:32 | h | 23 | 8 | 9 | 32 | 32 | +| test.cpp:145:33:145:33 | a | 23 | 9 | 10 | 33 | 33 | +| test.cpp:145:34:145:34 | : | 23 | 10 | 11 | 34 | 34 | +| test.cpp:145:36:145:36 | ] | 23 | 12 | 13 | 36 | 36 | +| test.cpp:148:25:148:53 | [[:alpha:][:digit:][:space:]] | 24 | 0 | 29 | 25 | 53 | +| test.cpp:148:26:148:34 | [:alpha:] | 24 | 1 | 10 | 26 | 34 | +| test.cpp:148:35:148:43 | [:digit:] | 24 | 10 | 19 | 35 | 43 | +| test.cpp:148:44:148:52 | [:space:] | 24 | 19 | 28 | 44 | 52 | +| test.cpp:151:25:151:36 | [[:xdigit:]] | 24 | 0 | 12 | 25 | 36 | +| test.cpp:151:26:151:35 | [:xdigit:] | 24 | 1 | 11 | 26 | 35 | +| test.cpp:152:25:152:35 | [[:blank:]] | 24 | 0 | 11 | 25 | 35 | +| test.cpp:152:26:152:34 | [:blank:] | 24 | 1 | 10 | 26 | 34 | +| test.cpp:153:25:153:35 | [[:cntrl:]] | 24 | 0 | 11 | 25 | 35 | +| test.cpp:153:26:153:34 | [:cntrl:] | 24 | 1 | 10 | 26 | 34 | +| test.cpp:154:25:154:35 | [[:graph:]] | 24 | 0 | 11 | 25 | 35 | +| test.cpp:154:26:154:34 | [:graph:] | 24 | 1 | 10 | 26 | 34 | +| test.cpp:157:25:157:25 | ^ | 24 | 0 | 1 | 25 | 25 | +| test.cpp:157:25:157:92 | ^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]\|[[:xdigit:]])+$ | 24 | 0 | 68 | 25 | 92 | +| test.cpp:157:26:157:63 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?) | 24 | 1 | 39 | 26 | 63 | +| test.cpp:157:26:157:64 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ | 24 | 1 | 40 | 26 | 64 | +| test.cpp:157:27:157:37 | [[:alpha:]] | 24 | 2 | 13 | 27 | 37 | +| test.cpp:157:27:157:38 | [[:alpha:]]+ | 24 | 2 | 14 | 27 | 38 | +| test.cpp:157:27:157:62 | [[:alpha:]]+[[:digit:]]*[[:space:]]? | 24 | 2 | 38 | 27 | 62 | +| test.cpp:157:28:157:36 | [:alpha:] | 24 | 3 | 12 | 28 | 36 | +| test.cpp:157:39:157:49 | [[:digit:]] | 24 | 14 | 25 | 39 | 49 | +| test.cpp:157:39:157:50 | [[:digit:]]* | 24 | 14 | 26 | 39 | 50 | +| test.cpp:157:40:157:48 | [:digit:] | 24 | 15 | 24 | 40 | 48 | +| test.cpp:157:51:157:61 | [[:space:]] | 24 | 26 | 37 | 51 | 61 | +| test.cpp:157:51:157:62 | [[:space:]]? | 24 | 26 | 38 | 51 | 62 | +| test.cpp:157:52:157:60 | [:space:] | 24 | 27 | 36 | 52 | 60 | +| test.cpp:157:65:157:90 | ([[:punct:]]\|[[:xdigit:]]) | 24 | 40 | 66 | 65 | 90 | +| test.cpp:157:65:157:91 | ([[:punct:]]\|[[:xdigit:]])+ | 24 | 40 | 67 | 65 | 91 | +| test.cpp:157:66:157:76 | [[:punct:]] | 24 | 41 | 52 | 66 | 76 | +| test.cpp:157:66:157:89 | [[:punct:]]\|[[:xdigit:]] | 24 | 41 | 65 | 66 | 89 | +| test.cpp:157:67:157:75 | [:punct:] | 24 | 42 | 51 | 67 | 75 | +| test.cpp:157:78:157:89 | [[:xdigit:]] | 24 | 53 | 65 | 78 | 89 | +| test.cpp:157:79:157:88 | [:xdigit:] | 24 | 54 | 64 | 79 | 88 | +| test.cpp:157:92:157:92 | $ | 24 | 67 | 68 | 92 | 92 | +| test.cpp:162:21:162:26 | \\u9879 | 20 | 0 | 6 | 21 | 26 | +| test.cpp:170:23:170:23 | a | 22 | 0 | 1 | 23 | 23 | +| test.cpp:170:23:170:24 | a+ | 22 | 0 | 2 | 23 | 24 | +| test.cpp:170:23:170:25 | a+b | 22 | 0 | 3 | 23 | 25 | +| test.cpp:170:25:170:25 | b | 22 | 2 | 3 | 25 | 25 | +| test.cpp:173:23:173:23 | a | 20 | 0 | 1 | 23 | 23 | +| test.cpp:173:23:173:24 | a+ | 20 | 0 | 2 | 23 | 24 | +| test.cpp:173:23:173:25 | a+b | 20 | 0 | 3 | 23 | 25 | +| test.cpp:173:25:173:25 | b | 20 | 2 | 3 | 25 | 25 | +| test.cpp:176:24:176:25 | \\s | 21 | 0 | 2 | 24 | 25 | +| test.cpp:176:24:176:26 | \\s+ | 21 | 0 | 3 | 24 | 26 | +| test.cpp:176:24:176:27 | \\s+$ | 21 | 0 | 4 | 24 | 27 | +| test.cpp:176:27:176:27 | $ | 21 | 3 | 4 | 27 | 27 | +| test.cpp:179:24:179:25 | \\( | 21 | 0 | 2 | 24 | 25 | +| test.cpp:179:24:179:37 | \\(([,\\w]+)+\\)$ | 21 | 0 | 14 | 24 | 37 | +| test.cpp:179:26:179:33 | ([,\\w]+) | 21 | 2 | 10 | 26 | 33 | +| test.cpp:179:26:179:34 | ([,\\w]+)+ | 21 | 2 | 11 | 26 | 34 | +| test.cpp:179:27:179:31 | [,\\w] | 21 | 3 | 8 | 27 | 31 | +| test.cpp:179:27:179:32 | [,\\w]+ | 21 | 3 | 9 | 27 | 32 | +| test.cpp:179:28:179:28 | , | 21 | 4 | 5 | 28 | 28 | +| test.cpp:179:29:179:30 | \\w | 21 | 5 | 7 | 29 | 30 | +| test.cpp:179:35:179:36 | \\) | 21 | 11 | 13 | 35 | 36 | +| test.cpp:179:37:179:37 | $ | 21 | 13 | 14 | 37 | 37 | +| test.cpp:182:25:182:25 | a | 21 | 0 | 1 | 25 | 25 | +| test.cpp:182:25:182:26 | a+ | 21 | 0 | 2 | 25 | 26 | +| test.cpp:182:25:182:27 | a+b | 21 | 0 | 3 | 25 | 27 | +| test.cpp:182:27:182:27 | b | 21 | 2 | 3 | 27 | 27 | +| test.cpp:185:24:185:24 | a | 22 | 0 | 1 | 24 | 24 | +| test.cpp:185:24:185:25 | a+ | 22 | 0 | 2 | 24 | 25 | +| test.cpp:185:24:185:26 | a+b | 22 | 0 | 3 | 24 | 26 | +| test.cpp:185:26:185:26 | b | 22 | 2 | 3 | 26 | 26 | +| test.cpp:188:30:188:30 | a | 26 | 0 | 1 | 30 | 30 | +| test.cpp:188:30:188:31 | a+ | 26 | 0 | 2 | 30 | 31 | +| test.cpp:188:30:188:32 | a+b | 26 | 0 | 3 | 30 | 32 | +| test.cpp:188:32:188:32 | b | 26 | 2 | 3 | 32 | 32 | +| test.cpp:192:22:192:23 | \\s | 21 | 0 | 2 | 22 | 23 | +| test.cpp:192:22:192:24 | \\s+ | 21 | 0 | 3 | 22 | 24 | +| test.cpp:195:22:195:22 | a | 21 | 0 | 1 | 22 | 22 | +| test.cpp:195:22:195:25 | a\\.b | 21 | 0 | 4 | 22 | 25 | +| test.cpp:195:23:195:24 | \\. | 21 | 1 | 3 | 23 | 24 | +| test.cpp:195:25:195:25 | b | 21 | 3 | 4 | 25 | 25 | +| test.cpp:199:22:199:22 | a | 19 | 0 | 1 | 22 | 22 | +| test.cpp:199:22:199:23 | a+ | 19 | 0 | 2 | 22 | 23 | +| test.cpp:199:22:199:24 | a+b | 19 | 0 | 3 | 22 | 24 | +| test.cpp:199:24:199:24 | b | 19 | 2 | 3 | 24 | 24 | +| test.cpp:202:28:202:28 | a | 23 | 0 | 1 | 28 | 28 | +| test.cpp:202:28:202:29 | a+ | 23 | 0 | 2 | 28 | 29 | +| test.cpp:202:28:202:30 | a+b | 23 | 0 | 3 | 28 | 30 | +| test.cpp:202:30:202:30 | b | 23 | 2 | 3 | 30 | 30 | diff --git a/cpp/ql/test/library-tests/regex/parse.expected b/cpp/ql/test/library-tests/regex/parse.expected index f7361ec71c4..3f414bb46ca 100644 --- a/cpp/ql/test/library-tests/regex/parse.expected +++ b/cpp/ql/test/library-tests/regex/parse.expected @@ -402,14 +402,6 @@ test.cpp: # 108| [RegExpCharacterClassEscape] \w -# 111| [RegExpGroup] (?\w+) -#-----| 0 -> [RegExpPlus] \w+ - -# 111| [RegExpCharacterClassEscape] \w - -# 111| [RegExpPlus] \w+ -#-----| 0 -> [RegExpCharacterClassEscape] \w - # 115| [RegExpGroup] (a+) #-----| 0 -> [RegExpPlus] a+ @@ -430,92 +422,69 @@ test.cpp: # 115| [RegExpBackRef] \1 -# 116| [RegExpGroup] (?q+) -#-----| 0 -> [RegExpPlus] q+ - -# 116| [RegExpSequence] (?q+)\s+\k+ -#-----| 0 -> [RegExpGroup] (?q+) -#-----| 1 -> [RegExpPlus] \s+ -#-----| 2 -> [RegExpPlus] \k+ - -# 116| [RegExpConstant, RegExpNormalChar] q - -# 116| [RegExpPlus] q+ -#-----| 0 -> [RegExpConstant, RegExpNormalChar] q - -# 116| [RegExpCharacterClassEscape] \s - -# 116| [RegExpPlus] \s+ -#-----| 0 -> [RegExpCharacterClassEscape] \s - -# 116| [RegExpBackRef] \k - -# 116| [RegExpPlus] \k+ -#-----| 0 -> [RegExpBackRef] \k - -# 119| [RegExpCharacterClass] [a-f\d] +# 118| [RegExpCharacterClass] [a-f\d] #-----| 0 -> [RegExpCharacterRange] a-f #-----| 1 -> [RegExpCharacterClassEscape] \d -# 119| [RegExpPlus] [a-f\d]+ +# 118| [RegExpPlus] [a-f\d]+ #-----| 0 -> [RegExpCharacterClass] [a-f\d] -# 119| [RegExpConstant, RegExpNormalChar] a +# 118| [RegExpConstant, RegExpNormalChar] a -# 119| [RegExpCharacterRange] a-f +# 118| [RegExpCharacterRange] a-f #-----| 0 -> [RegExpConstant, RegExpNormalChar] a #-----| 1 -> [RegExpConstant, RegExpNormalChar] f -# 119| [RegExpConstant, RegExpNormalChar] f +# 118| [RegExpConstant, RegExpNormalChar] f -# 119| [RegExpCharacterClassEscape] \d +# 118| [RegExpCharacterClassEscape] \d -# 122| [RegExpCharacterClass] [[:alpha:]] +# 121| [RegExpCharacterClass] [[:alpha:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:alpha:] -# 122| [RegExpSequence] [[:alpha:]][[:digit:]] +# 121| [RegExpSequence] [[:alpha:]][[:digit:]] #-----| 0 -> [RegExpCharacterClass] [[:alpha:]] #-----| 1 -> [RegExpCharacterClass] [[:digit:]] -# 122| [RegExpNamedCharacterProperty] [:alpha:] +# 121| [RegExpNamedCharacterProperty] [:alpha:] -# 122| [RegExpCharacterClass] [[:digit:]] +# 121| [RegExpCharacterClass] [[:digit:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:digit:] -# 122| [RegExpNamedCharacterProperty] [:digit:] +# 121| [RegExpNamedCharacterProperty] [:digit:] -# 125| [RegExpCharacterClass] [[:alpha:][:digit:]] +# 124| [RegExpCharacterClass] [[:alpha:][:digit:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:alpha:] #-----| 1 -> [RegExpNamedCharacterProperty] [:digit:] -# 125| [RegExpNamedCharacterProperty] [:alpha:] +# 124| [RegExpNamedCharacterProperty] [:alpha:] -# 125| [RegExpNamedCharacterProperty] [:digit:] +# 124| [RegExpNamedCharacterProperty] [:digit:] -# 128| [RegExpCharacterClass] [A-F[:digit:]a-f] +# 127| [RegExpCharacterClass] [A-F[:digit:]a-f] #-----| 0 -> [RegExpCharacterRange] A-F #-----| 1 -> [RegExpNamedCharacterProperty] [:digit:] #-----| 2 -> [RegExpCharacterRange] a-f -# 128| [RegExpConstant, RegExpNormalChar] A +# 127| [RegExpConstant, RegExpNormalChar] A -# 128| [RegExpCharacterRange] A-F +# 127| [RegExpCharacterRange] A-F #-----| 0 -> [RegExpConstant, RegExpNormalChar] A #-----| 1 -> [RegExpConstant, RegExpNormalChar] F -# 128| [RegExpConstant, RegExpNormalChar] F +# 127| [RegExpConstant, RegExpNormalChar] F -# 128| [RegExpNamedCharacterProperty] [:digit:] +# 127| [RegExpNamedCharacterProperty] [:digit:] -# 128| [RegExpConstant, RegExpNormalChar] a +# 127| [RegExpConstant, RegExpNormalChar] a -# 128| [RegExpCharacterRange] a-f +# 127| [RegExpCharacterRange] a-f #-----| 0 -> [RegExpConstant, RegExpNormalChar] a #-----| 1 -> [RegExpConstant, RegExpNormalChar] f -# 128| [RegExpConstant, RegExpNormalChar] f +# 127| [RegExpConstant, RegExpNormalChar] f -# 131| [RegExpCharacterClass] [:digit:] +# 130| [RegExpCharacterClass] [:digit:] #-----| 0 -> [RegExpConstant, RegExpNormalChar] : #-----| 1 -> [RegExpConstant, RegExpNormalChar] d #-----| 2 -> [RegExpConstant, RegExpNormalChar] i @@ -524,21 +493,21 @@ test.cpp: #-----| 5 -> [RegExpConstant, RegExpNormalChar] t #-----| 6 -> [RegExpConstant, RegExpNormalChar] : -# 131| [RegExpConstant, RegExpNormalChar] : +# 130| [RegExpConstant, RegExpNormalChar] : -# 131| [RegExpConstant, RegExpNormalChar] d +# 130| [RegExpConstant, RegExpNormalChar] d -# 131| [RegExpConstant, RegExpNormalChar] i +# 130| [RegExpConstant, RegExpNormalChar] i -# 131| [RegExpConstant, RegExpNormalChar] g +# 130| [RegExpConstant, RegExpNormalChar] g -# 131| [RegExpConstant, RegExpNormalChar] i +# 130| [RegExpConstant, RegExpNormalChar] i -# 131| [RegExpConstant, RegExpNormalChar] t +# 130| [RegExpConstant, RegExpNormalChar] t -# 131| [RegExpConstant, RegExpNormalChar] : +# 130| [RegExpConstant, RegExpNormalChar] : -# 134| [RegExpCharacterClass] [:alpha:] +# 133| [RegExpCharacterClass] [:alpha:] #-----| 0 -> [RegExpConstant, RegExpNormalChar] : #-----| 1 -> [RegExpConstant, RegExpNormalChar] a #-----| 2 -> [RegExpConstant, RegExpNormalChar] l @@ -547,52 +516,52 @@ test.cpp: #-----| 5 -> [RegExpConstant, RegExpNormalChar] a #-----| 6 -> [RegExpConstant, RegExpNormalChar] : -# 134| [RegExpConstant, RegExpNormalChar] : +# 133| [RegExpConstant, RegExpNormalChar] : -# 134| [RegExpConstant, RegExpNormalChar] a +# 133| [RegExpConstant, RegExpNormalChar] a -# 134| [RegExpConstant, RegExpNormalChar] l +# 133| [RegExpConstant, RegExpNormalChar] l -# 134| [RegExpConstant, RegExpNormalChar] p +# 133| [RegExpConstant, RegExpNormalChar] p -# 134| [RegExpConstant, RegExpNormalChar] h +# 133| [RegExpConstant, RegExpNormalChar] h -# 134| [RegExpConstant, RegExpNormalChar] a +# 133| [RegExpConstant, RegExpNormalChar] a -# 134| [RegExpConstant, RegExpNormalChar] : +# 133| [RegExpConstant, RegExpNormalChar] : -# 137| [RegExpConstant, RegExpNormalChar] a +# 136| [RegExpConstant, RegExpNormalChar] a -# 137| [RegExpSequence] a[:b:]c +# 136| [RegExpSequence] a[:b:]c #-----| 0 -> [RegExpConstant, RegExpNormalChar] a #-----| 1 -> [RegExpCharacterClass] [:b:] #-----| 2 -> [RegExpConstant, RegExpNormalChar] c -# 137| [RegExpCharacterClass] [:b:] +# 136| [RegExpCharacterClass] [:b:] #-----| 0 -> [RegExpConstant, RegExpNormalChar] : #-----| 1 -> [RegExpConstant, RegExpNormalChar] b #-----| 2 -> [RegExpConstant, RegExpNormalChar] : -# 137| [RegExpConstant, RegExpNormalChar] : +# 136| [RegExpConstant, RegExpNormalChar] : -# 137| [RegExpConstant, RegExpNormalChar] b +# 136| [RegExpConstant, RegExpNormalChar] b -# 137| [RegExpConstant, RegExpNormalChar] : +# 136| [RegExpConstant, RegExpNormalChar] : -# 137| [RegExpConstant, RegExpNormalChar] c +# 136| [RegExpConstant, RegExpNormalChar] c -# 140| [RegExpCharacterClass] [[:alpha:]-z] +# 139| [RegExpCharacterClass] [[:alpha:]-z] #-----| 0 -> [RegExpCharacterRange] [:alpha:]-z -# 140| [RegExpNamedCharacterProperty] [:alpha:] +# 139| [RegExpNamedCharacterProperty] [:alpha:] -# 140| [RegExpCharacterRange] [:alpha:]-z +# 139| [RegExpCharacterRange] [:alpha:]-z #-----| 0 -> [RegExpNamedCharacterProperty] [:alpha:] #-----| 1 -> [RegExpConstant, RegExpNormalChar] z -# 140| [RegExpConstant, RegExpNormalChar] z +# 139| [RegExpConstant, RegExpNormalChar] z -# 143| [RegExpCharacterClass] [[:alpha] +# 142| [RegExpCharacterClass] [[:alpha] #-----| 0 -> [RegExpConstant, RegExpNormalChar] [ #-----| 1 -> [RegExpConstant, RegExpNormalChar] : #-----| 2 -> [RegExpConstant, RegExpNormalChar] a @@ -601,21 +570,21 @@ test.cpp: #-----| 5 -> [RegExpConstant, RegExpNormalChar] h #-----| 6 -> [RegExpConstant, RegExpNormalChar] a -# 143| [RegExpConstant, RegExpNormalChar] [ +# 142| [RegExpConstant, RegExpNormalChar] [ -# 143| [RegExpConstant, RegExpNormalChar] : +# 142| [RegExpConstant, RegExpNormalChar] : -# 143| [RegExpConstant, RegExpNormalChar] a +# 142| [RegExpConstant, RegExpNormalChar] a -# 143| [RegExpConstant, RegExpNormalChar] l +# 142| [RegExpConstant, RegExpNormalChar] l -# 143| [RegExpConstant, RegExpNormalChar] p +# 142| [RegExpConstant, RegExpNormalChar] p -# 143| [RegExpConstant, RegExpNormalChar] h +# 142| [RegExpConstant, RegExpNormalChar] h -# 143| [RegExpConstant, RegExpNormalChar] a +# 142| [RegExpConstant, RegExpNormalChar] a -# 146| [RegExpCharacterClass] []a[:alpha:] +# 145| [RegExpCharacterClass] []a[:alpha:] #-----| 0 -> [RegExpConstant, RegExpNormalChar] ] #-----| 1 -> [RegExpConstant, RegExpNormalChar] a #-----| 2 -> [RegExpConstant, RegExpNormalChar] [ @@ -627,259 +596,259 @@ test.cpp: #-----| 8 -> [RegExpConstant, RegExpNormalChar] a #-----| 9 -> [RegExpConstant, RegExpNormalChar] : -# 146| [RegExpSequence] []a[:alpha:]] +# 145| [RegExpSequence] []a[:alpha:]] #-----| 0 -> [RegExpCharacterClass] []a[:alpha:] #-----| 1 -> [RegExpConstant, RegExpNormalChar] ] -# 146| [RegExpConstant, RegExpNormalChar] ] +# 145| [RegExpConstant, RegExpNormalChar] ] -# 146| [RegExpConstant, RegExpNormalChar] a +# 145| [RegExpConstant, RegExpNormalChar] a -# 146| [RegExpConstant, RegExpNormalChar] [ +# 145| [RegExpConstant, RegExpNormalChar] [ -# 146| [RegExpConstant, RegExpNormalChar] : +# 145| [RegExpConstant, RegExpNormalChar] : -# 146| [RegExpConstant, RegExpNormalChar] a +# 145| [RegExpConstant, RegExpNormalChar] a -# 146| [RegExpConstant, RegExpNormalChar] l +# 145| [RegExpConstant, RegExpNormalChar] l -# 146| [RegExpConstant, RegExpNormalChar] p +# 145| [RegExpConstant, RegExpNormalChar] p -# 146| [RegExpConstant, RegExpNormalChar] h +# 145| [RegExpConstant, RegExpNormalChar] h -# 146| [RegExpConstant, RegExpNormalChar] a +# 145| [RegExpConstant, RegExpNormalChar] a -# 146| [RegExpConstant, RegExpNormalChar] : +# 145| [RegExpConstant, RegExpNormalChar] : -# 146| [RegExpConstant, RegExpNormalChar] ] +# 145| [RegExpConstant, RegExpNormalChar] ] -# 149| [RegExpCharacterClass] [[:alpha:][:digit:][:space:]] +# 148| [RegExpCharacterClass] [[:alpha:][:digit:][:space:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:alpha:] #-----| 1 -> [RegExpNamedCharacterProperty] [:digit:] #-----| 2 -> [RegExpNamedCharacterProperty] [:space:] -# 149| [RegExpNamedCharacterProperty] [:alpha:] +# 148| [RegExpNamedCharacterProperty] [:alpha:] -# 149| [RegExpNamedCharacterProperty] [:digit:] +# 148| [RegExpNamedCharacterProperty] [:digit:] -# 149| [RegExpNamedCharacterProperty] [:space:] +# 148| [RegExpNamedCharacterProperty] [:space:] -# 152| [RegExpCharacterClass] [[:xdigit:]] +# 151| [RegExpCharacterClass] [[:xdigit:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:xdigit:] -# 152| [RegExpNamedCharacterProperty] [:xdigit:] +# 151| [RegExpNamedCharacterProperty] [:xdigit:] -# 153| [RegExpCharacterClass] [[:blank:]] +# 152| [RegExpCharacterClass] [[:blank:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:blank:] -# 153| [RegExpNamedCharacterProperty] [:blank:] +# 152| [RegExpNamedCharacterProperty] [:blank:] -# 154| [RegExpCharacterClass] [[:cntrl:]] +# 153| [RegExpCharacterClass] [[:cntrl:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:cntrl:] -# 154| [RegExpNamedCharacterProperty] [:cntrl:] +# 153| [RegExpNamedCharacterProperty] [:cntrl:] -# 155| [RegExpCharacterClass] [[:graph:]] +# 154| [RegExpCharacterClass] [[:graph:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:graph:] -# 155| [RegExpNamedCharacterProperty] [:graph:] +# 154| [RegExpNamedCharacterProperty] [:graph:] -# 158| [RegExpCaret] ^ +# 157| [RegExpCaret] ^ -# 158| [RegExpSequence] ^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]|[[:xdigit:]])+$ +# 157| [RegExpSequence] ^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]|[[:xdigit:]])+$ #-----| 0 -> [RegExpCaret] ^ #-----| 1 -> [RegExpPlus] ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ #-----| 2 -> [RegExpPlus] ([[:punct:]]|[[:xdigit:]])+ #-----| 3 -> [RegExpDollar] $ -# 158| [RegExpGroup] ([[:alpha:]]+[[:digit:]]*[[:space:]]?) +# 157| [RegExpGroup] ([[:alpha:]]+[[:digit:]]*[[:space:]]?) #-----| 0 -> [RegExpSequence] [[:alpha:]]+[[:digit:]]*[[:space:]]? -# 158| [RegExpPlus] ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ +# 157| [RegExpPlus] ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ #-----| 0 -> [RegExpGroup] ([[:alpha:]]+[[:digit:]]*[[:space:]]?) -# 158| [RegExpCharacterClass] [[:alpha:]] +# 157| [RegExpCharacterClass] [[:alpha:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:alpha:] -# 158| [RegExpPlus] [[:alpha:]]+ +# 157| [RegExpPlus] [[:alpha:]]+ #-----| 0 -> [RegExpCharacterClass] [[:alpha:]] -# 158| [RegExpSequence] [[:alpha:]]+[[:digit:]]*[[:space:]]? +# 157| [RegExpSequence] [[:alpha:]]+[[:digit:]]*[[:space:]]? #-----| 0 -> [RegExpPlus] [[:alpha:]]+ #-----| 1 -> [RegExpStar] [[:digit:]]* #-----| 2 -> [RegExpOpt] [[:space:]]? -# 158| [RegExpNamedCharacterProperty] [:alpha:] +# 157| [RegExpNamedCharacterProperty] [:alpha:] -# 158| [RegExpCharacterClass] [[:digit:]] +# 157| [RegExpCharacterClass] [[:digit:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:digit:] -# 158| [RegExpStar] [[:digit:]]* +# 157| [RegExpStar] [[:digit:]]* #-----| 0 -> [RegExpCharacterClass] [[:digit:]] -# 158| [RegExpNamedCharacterProperty] [:digit:] +# 157| [RegExpNamedCharacterProperty] [:digit:] -# 158| [RegExpCharacterClass] [[:space:]] +# 157| [RegExpCharacterClass] [[:space:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:space:] -# 158| [RegExpOpt] [[:space:]]? +# 157| [RegExpOpt] [[:space:]]? #-----| 0 -> [RegExpCharacterClass] [[:space:]] -# 158| [RegExpNamedCharacterProperty] [:space:] +# 157| [RegExpNamedCharacterProperty] [:space:] -# 158| [RegExpGroup] ([[:punct:]]|[[:xdigit:]]) +# 157| [RegExpGroup] ([[:punct:]]|[[:xdigit:]]) #-----| 0 -> [RegExpAlt] [[:punct:]]|[[:xdigit:]] -# 158| [RegExpPlus] ([[:punct:]]|[[:xdigit:]])+ +# 157| [RegExpPlus] ([[:punct:]]|[[:xdigit:]])+ #-----| 0 -> [RegExpGroup] ([[:punct:]]|[[:xdigit:]]) -# 158| [RegExpCharacterClass] [[:punct:]] +# 157| [RegExpCharacterClass] [[:punct:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:punct:] -# 158| [RegExpAlt] [[:punct:]]|[[:xdigit:]] +# 157| [RegExpAlt] [[:punct:]]|[[:xdigit:]] #-----| 0 -> [RegExpCharacterClass] [[:punct:]] #-----| 1 -> [RegExpCharacterClass] [[:xdigit:]] -# 158| [RegExpNamedCharacterProperty] [:punct:] +# 157| [RegExpNamedCharacterProperty] [:punct:] -# 158| [RegExpCharacterClass] [[:xdigit:]] +# 157| [RegExpCharacterClass] [[:xdigit:]] #-----| 0 -> [RegExpNamedCharacterProperty] [:xdigit:] -# 158| [RegExpNamedCharacterProperty] [:xdigit:] +# 157| [RegExpNamedCharacterProperty] [:xdigit:] -# 158| [RegExpDollar] $ +# 157| [RegExpDollar] $ -# 163| [RegExpConstant, RegExpEscape] \u9879 +# 162| [RegExpConstant, RegExpEscape] \u9879 -# 171| [RegExpConstant, RegExpNormalChar] a +# 170| [RegExpConstant, RegExpNormalChar] a -# 171| [RegExpPlus] a+ +# 170| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 171| [RegExpSequence] a+b +# 170| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 171| [RegExpConstant, RegExpNormalChar] b +# 170| [RegExpConstant, RegExpNormalChar] b -# 174| [RegExpConstant, RegExpNormalChar] a +# 173| [RegExpConstant, RegExpNormalChar] a -# 174| [RegExpPlus] a+ +# 173| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 174| [RegExpSequence] a+b +# 173| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 174| [RegExpConstant, RegExpNormalChar] b +# 173| [RegExpConstant, RegExpNormalChar] b -# 177| [RegExpCharacterClassEscape] \s +# 176| [RegExpCharacterClassEscape] \s -# 177| [RegExpPlus] \s+ +# 176| [RegExpPlus] \s+ #-----| 0 -> [RegExpCharacterClassEscape] \s -# 177| [RegExpSequence] \s+$ +# 176| [RegExpSequence] \s+$ #-----| 0 -> [RegExpPlus] \s+ #-----| 1 -> [RegExpDollar] $ -# 177| [RegExpDollar] $ +# 176| [RegExpDollar] $ -# 180| [RegExpConstant, RegExpEscape] \( +# 179| [RegExpConstant, RegExpEscape] \( -# 180| [RegExpSequence] \(([,\w]+)+\)$ +# 179| [RegExpSequence] \(([,\w]+)+\)$ #-----| 0 -> [RegExpConstant, RegExpEscape] \( #-----| 1 -> [RegExpPlus] ([,\w]+)+ #-----| 2 -> [RegExpConstant, RegExpEscape] \) #-----| 3 -> [RegExpDollar] $ -# 180| [RegExpGroup] ([,\w]+) +# 179| [RegExpGroup] ([,\w]+) #-----| 0 -> [RegExpPlus] [,\w]+ -# 180| [RegExpPlus] ([,\w]+)+ +# 179| [RegExpPlus] ([,\w]+)+ #-----| 0 -> [RegExpGroup] ([,\w]+) -# 180| [RegExpCharacterClass] [,\w] +# 179| [RegExpCharacterClass] [,\w] #-----| 0 -> [RegExpConstant, RegExpNormalChar] , #-----| 1 -> [RegExpCharacterClassEscape] \w -# 180| [RegExpPlus] [,\w]+ +# 179| [RegExpPlus] [,\w]+ #-----| 0 -> [RegExpCharacterClass] [,\w] -# 180| [RegExpConstant, RegExpNormalChar] , +# 179| [RegExpConstant, RegExpNormalChar] , -# 180| [RegExpCharacterClassEscape] \w +# 179| [RegExpCharacterClassEscape] \w -# 180| [RegExpConstant, RegExpEscape] \) +# 179| [RegExpConstant, RegExpEscape] \) -# 180| [RegExpDollar] $ +# 179| [RegExpDollar] $ -# 183| [RegExpConstant, RegExpNormalChar] a +# 182| [RegExpConstant, RegExpNormalChar] a -# 183| [RegExpPlus] a+ +# 182| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 183| [RegExpSequence] a+b +# 182| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 183| [RegExpConstant, RegExpNormalChar] b +# 182| [RegExpConstant, RegExpNormalChar] b -# 186| [RegExpConstant, RegExpNormalChar] a +# 185| [RegExpConstant, RegExpNormalChar] a -# 186| [RegExpPlus] a+ +# 185| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 186| [RegExpSequence] a+b +# 185| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 186| [RegExpConstant, RegExpNormalChar] b +# 185| [RegExpConstant, RegExpNormalChar] b -# 189| [RegExpConstant, RegExpNormalChar] a +# 188| [RegExpConstant, RegExpNormalChar] a -# 189| [RegExpPlus] a+ +# 188| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 189| [RegExpSequence] a+b +# 188| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 189| [RegExpConstant, RegExpNormalChar] b +# 188| [RegExpConstant, RegExpNormalChar] b -# 193| [RegExpCharacterClassEscape] \s +# 192| [RegExpCharacterClassEscape] \s -# 193| [RegExpPlus] \s+ +# 192| [RegExpPlus] \s+ #-----| 0 -> [RegExpCharacterClassEscape] \s -# 196| [RegExpConstant, RegExpNormalChar] a +# 195| [RegExpConstant, RegExpNormalChar] a -# 196| [RegExpSequence] a\.b +# 195| [RegExpSequence] a\.b #-----| 0 -> [RegExpConstant, RegExpNormalChar] a #-----| 1 -> [RegExpConstant, RegExpEscape] \. #-----| 2 -> [RegExpConstant, RegExpNormalChar] b -# 196| [RegExpConstant, RegExpEscape] \. +# 195| [RegExpConstant, RegExpEscape] \. -# 196| [RegExpConstant, RegExpNormalChar] b +# 195| [RegExpConstant, RegExpNormalChar] b -# 200| [RegExpConstant, RegExpNormalChar] a +# 199| [RegExpConstant, RegExpNormalChar] a -# 200| [RegExpPlus] a+ +# 199| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 200| [RegExpSequence] a+b +# 199| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 200| [RegExpConstant, RegExpNormalChar] b +# 199| [RegExpConstant, RegExpNormalChar] b -# 203| [RegExpConstant, RegExpNormalChar] a +# 202| [RegExpConstant, RegExpNormalChar] a -# 203| [RegExpPlus] a+ +# 202| [RegExpPlus] a+ #-----| 0 -> [RegExpConstant, RegExpNormalChar] a -# 203| [RegExpSequence] a+b +# 202| [RegExpSequence] a+b #-----| 0 -> [RegExpPlus] a+ #-----| 1 -> [RegExpConstant, RegExpNormalChar] b -# 203| [RegExpConstant, RegExpNormalChar] b +# 202| [RegExpConstant, RegExpNormalChar] b diff --git a/cpp/ql/test/library-tests/regex/regexp.expected b/cpp/ql/test/library-tests/regex/regexp.expected index cb83e11287f..03b6bf25765 100644 --- a/cpp/ql/test/library-tests/regex/regexp.expected +++ b/cpp/ql/test/library-tests/regex/regexp.expected @@ -1,16 +1,11 @@ -groupName -| test.cpp:111:21:111:30 | (?\\w+) | id | -| test.cpp:116:23:116:32 | (?q+) | qux | groupNumber | test.cpp:105:22:105:26 | (foo) | 1 | | test.cpp:106:24:106:28 | (o\|b) | 1 | | test.cpp:107:22:107:29 | (a\|b\|cd) | 1 | -| test.cpp:111:21:111:30 | (?\\w+) | 1 | | test.cpp:115:23:115:26 | (a+) | 1 | -| test.cpp:116:23:116:32 | (?q+) | 1 | -| test.cpp:158:26:158:63 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?) | 1 | -| test.cpp:158:65:158:90 | ([[:punct:]]\|[[:xdigit:]]) | 2 | -| test.cpp:180:26:180:33 | ([,\\w]+) | 1 | +| test.cpp:157:26:157:63 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?) | 1 | +| test.cpp:157:65:157:90 | ([[:punct:]]\|[[:xdigit:]]) | 2 | +| test.cpp:179:26:179:33 | ([,\\w]+) | 1 | term | test.cpp:33:21:33:23 | abc | RegExpConstant,RegExpNormalChar | | test.cpp:36:22:36:22 | a | RegExpConstant,RegExpNormalChar | @@ -160,9 +155,6 @@ term | test.cpp:108:25:108:25 | : | RegExpConstant,RegExpNormalChar | | test.cpp:108:25:108:26 | :+ | RegExpPlus | | test.cpp:108:28:108:29 | \\w | RegExpCharacterClassEscape | -| test.cpp:111:21:111:30 | (?\\w+) | RegExpGroup | -| test.cpp:111:27:111:28 | \\w | RegExpCharacterClassEscape | -| test.cpp:111:27:111:29 | \\w+ | RegExpPlus | | test.cpp:115:23:115:26 | (a+) | RegExpGroup | | test.cpp:115:23:115:30 | (a+)b+\\1 | RegExpSequence | | test.cpp:115:24:115:24 | a | RegExpConstant,RegExpNormalChar | @@ -170,167 +162,159 @@ term | test.cpp:115:27:115:27 | b | RegExpConstant,RegExpNormalChar | | test.cpp:115:27:115:28 | b+ | RegExpPlus | | test.cpp:115:29:115:30 | \\1 | RegExpBackRef | -| test.cpp:116:23:116:32 | (?q+) | RegExpGroup | -| test.cpp:116:23:116:43 | (?q+)\\s+\\k+ | RegExpSequence | -| test.cpp:116:30:116:30 | q | RegExpConstant,RegExpNormalChar | -| test.cpp:116:30:116:31 | q+ | RegExpPlus | -| test.cpp:116:33:116:34 | \\s | RegExpCharacterClassEscape | -| test.cpp:116:33:116:35 | \\s+ | RegExpPlus | -| test.cpp:116:36:116:42 | \\k | RegExpBackRef | -| test.cpp:116:36:116:43 | \\k+ | RegExpPlus | -| test.cpp:119:23:119:29 | [a-f\\d] | RegExpCharacterClass | -| test.cpp:119:23:119:30 | [a-f\\d]+ | RegExpPlus | -| test.cpp:119:24:119:24 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:119:24:119:26 | a-f | RegExpCharacterRange | -| test.cpp:119:26:119:26 | f | RegExpConstant,RegExpNormalChar | -| test.cpp:119:27:119:28 | \\d | RegExpCharacterClassEscape | -| test.cpp:122:24:122:34 | [[:alpha:]] | RegExpCharacterClass | -| test.cpp:122:24:122:45 | [[:alpha:]][[:digit:]] | RegExpSequence | -| test.cpp:122:25:122:33 | [:alpha:] | RegExpNamedCharacterProperty | -| test.cpp:122:35:122:45 | [[:digit:]] | RegExpCharacterClass | -| test.cpp:122:36:122:44 | [:digit:] | RegExpNamedCharacterProperty | -| test.cpp:125:24:125:43 | [[:alpha:][:digit:]] | RegExpCharacterClass | -| test.cpp:125:25:125:33 | [:alpha:] | RegExpNamedCharacterProperty | -| test.cpp:125:34:125:42 | [:digit:] | RegExpNamedCharacterProperty | -| test.cpp:128:24:128:40 | [A-F[:digit:]a-f] | RegExpCharacterClass | -| test.cpp:128:25:128:25 | A | RegExpConstant,RegExpNormalChar | -| test.cpp:128:25:128:27 | A-F | RegExpCharacterRange | -| test.cpp:128:27:128:27 | F | RegExpConstant,RegExpNormalChar | -| test.cpp:128:28:128:36 | [:digit:] | RegExpNamedCharacterProperty | -| test.cpp:128:37:128:37 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:128:37:128:39 | a-f | RegExpCharacterRange | -| test.cpp:128:39:128:39 | f | RegExpConstant,RegExpNormalChar | -| test.cpp:131:24:131:32 | [:digit:] | RegExpCharacterClass | -| test.cpp:131:25:131:25 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:131:26:131:26 | d | RegExpConstant,RegExpNormalChar | -| test.cpp:131:27:131:27 | i | RegExpConstant,RegExpNormalChar | -| test.cpp:131:28:131:28 | g | RegExpConstant,RegExpNormalChar | -| test.cpp:131:29:131:29 | i | RegExpConstant,RegExpNormalChar | -| test.cpp:131:30:131:30 | t | RegExpConstant,RegExpNormalChar | -| test.cpp:131:31:131:31 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:134:24:134:32 | [:alpha:] | RegExpCharacterClass | -| test.cpp:134:25:134:25 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:134:26:134:26 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:134:27:134:27 | l | RegExpConstant,RegExpNormalChar | -| test.cpp:134:28:134:28 | p | RegExpConstant,RegExpNormalChar | -| test.cpp:134:29:134:29 | h | RegExpConstant,RegExpNormalChar | -| test.cpp:134:30:134:30 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:134:31:134:31 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:137:24:137:24 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:137:24:137:30 | a[:b:]c | RegExpSequence | -| test.cpp:137:25:137:29 | [:b:] | RegExpCharacterClass | -| test.cpp:137:26:137:26 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:137:27:137:27 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:137:28:137:28 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:137:30:137:30 | c | RegExpConstant,RegExpNormalChar | -| test.cpp:140:24:140:36 | [[:alpha:]-z] | RegExpCharacterClass | -| test.cpp:140:25:140:33 | [:alpha:] | RegExpNamedCharacterProperty | -| test.cpp:140:25:140:35 | [:alpha:]-z | RegExpCharacterRange | -| test.cpp:140:35:140:35 | z | RegExpConstant,RegExpNormalChar | -| test.cpp:143:24:143:32 | [[:alpha] | RegExpCharacterClass | -| test.cpp:143:25:143:25 | [ | RegExpConstant,RegExpNormalChar | -| test.cpp:143:26:143:26 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:143:27:143:27 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:143:28:143:28 | l | RegExpConstant,RegExpNormalChar | -| test.cpp:143:29:143:29 | p | RegExpConstant,RegExpNormalChar | -| test.cpp:143:30:143:30 | h | RegExpConstant,RegExpNormalChar | -| test.cpp:143:31:143:31 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:146:24:146:35 | []a[:alpha:] | RegExpCharacterClass | -| test.cpp:146:24:146:36 | []a[:alpha:]] | RegExpSequence | -| test.cpp:146:25:146:25 | ] | RegExpConstant,RegExpNormalChar | -| test.cpp:146:26:146:26 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:146:27:146:27 | [ | RegExpConstant,RegExpNormalChar | -| test.cpp:146:28:146:28 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:146:29:146:29 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:146:30:146:30 | l | RegExpConstant,RegExpNormalChar | -| test.cpp:146:31:146:31 | p | RegExpConstant,RegExpNormalChar | -| test.cpp:146:32:146:32 | h | RegExpConstant,RegExpNormalChar | -| test.cpp:146:33:146:33 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:146:34:146:34 | : | RegExpConstant,RegExpNormalChar | -| test.cpp:146:36:146:36 | ] | RegExpConstant,RegExpNormalChar | -| test.cpp:149:25:149:53 | [[:alpha:][:digit:][:space:]] | RegExpCharacterClass | -| test.cpp:149:26:149:34 | [:alpha:] | RegExpNamedCharacterProperty | -| test.cpp:149:35:149:43 | [:digit:] | RegExpNamedCharacterProperty | -| test.cpp:149:44:149:52 | [:space:] | RegExpNamedCharacterProperty | -| test.cpp:152:25:152:36 | [[:xdigit:]] | RegExpCharacterClass | -| test.cpp:152:26:152:35 | [:xdigit:] | RegExpNamedCharacterProperty | -| test.cpp:153:25:153:35 | [[:blank:]] | RegExpCharacterClass | -| test.cpp:153:26:153:34 | [:blank:] | RegExpNamedCharacterProperty | -| test.cpp:154:25:154:35 | [[:cntrl:]] | RegExpCharacterClass | -| test.cpp:154:26:154:34 | [:cntrl:] | RegExpNamedCharacterProperty | -| test.cpp:155:25:155:35 | [[:graph:]] | RegExpCharacterClass | -| test.cpp:155:26:155:34 | [:graph:] | RegExpNamedCharacterProperty | -| test.cpp:158:25:158:25 | ^ | RegExpCaret | -| test.cpp:158:25:158:92 | ^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]\|[[:xdigit:]])+$ | RegExpSequence | -| test.cpp:158:26:158:63 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?) | RegExpGroup | -| test.cpp:158:26:158:64 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ | RegExpPlus | -| test.cpp:158:27:158:37 | [[:alpha:]] | RegExpCharacterClass | -| test.cpp:158:27:158:38 | [[:alpha:]]+ | RegExpPlus | -| test.cpp:158:27:158:62 | [[:alpha:]]+[[:digit:]]*[[:space:]]? | RegExpSequence | -| test.cpp:158:28:158:36 | [:alpha:] | RegExpNamedCharacterProperty | -| test.cpp:158:39:158:49 | [[:digit:]] | RegExpCharacterClass | -| test.cpp:158:39:158:50 | [[:digit:]]* | RegExpStar | -| test.cpp:158:40:158:48 | [:digit:] | RegExpNamedCharacterProperty | -| test.cpp:158:51:158:61 | [[:space:]] | RegExpCharacterClass | -| test.cpp:158:51:158:62 | [[:space:]]? | RegExpOpt | -| test.cpp:158:52:158:60 | [:space:] | RegExpNamedCharacterProperty | -| test.cpp:158:65:158:90 | ([[:punct:]]\|[[:xdigit:]]) | RegExpGroup | -| test.cpp:158:65:158:91 | ([[:punct:]]\|[[:xdigit:]])+ | RegExpPlus | -| test.cpp:158:66:158:76 | [[:punct:]] | RegExpCharacterClass | -| test.cpp:158:66:158:89 | [[:punct:]]\|[[:xdigit:]] | RegExpAlt | -| test.cpp:158:67:158:75 | [:punct:] | RegExpNamedCharacterProperty | -| test.cpp:158:78:158:89 | [[:xdigit:]] | RegExpCharacterClass | -| test.cpp:158:79:158:88 | [:xdigit:] | RegExpNamedCharacterProperty | -| test.cpp:158:92:158:92 | $ | RegExpDollar | -| test.cpp:163:21:163:26 | \\u9879 | RegExpConstant,RegExpEscape | -| test.cpp:171:23:171:23 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:171:23:171:24 | a+ | RegExpPlus | -| test.cpp:171:23:171:25 | a+b | RegExpSequence | -| test.cpp:171:25:171:25 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:174:23:174:23 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:174:23:174:24 | a+ | RegExpPlus | -| test.cpp:174:23:174:25 | a+b | RegExpSequence | -| test.cpp:174:25:174:25 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:177:24:177:25 | \\s | RegExpCharacterClassEscape | -| test.cpp:177:24:177:26 | \\s+ | RegExpPlus | -| test.cpp:177:24:177:27 | \\s+$ | RegExpSequence | -| test.cpp:177:27:177:27 | $ | RegExpDollar | -| test.cpp:180:24:180:25 | \\( | RegExpConstant,RegExpEscape | -| test.cpp:180:24:180:37 | \\(([,\\w]+)+\\)$ | RegExpSequence | -| test.cpp:180:26:180:33 | ([,\\w]+) | RegExpGroup | -| test.cpp:180:26:180:34 | ([,\\w]+)+ | RegExpPlus | -| test.cpp:180:27:180:31 | [,\\w] | RegExpCharacterClass | -| test.cpp:180:27:180:32 | [,\\w]+ | RegExpPlus | -| test.cpp:180:28:180:28 | , | RegExpConstant,RegExpNormalChar | -| test.cpp:180:29:180:30 | \\w | RegExpCharacterClassEscape | -| test.cpp:180:35:180:36 | \\) | RegExpConstant,RegExpEscape | -| test.cpp:180:37:180:37 | $ | RegExpDollar | -| test.cpp:183:25:183:25 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:183:25:183:26 | a+ | RegExpPlus | -| test.cpp:183:25:183:27 | a+b | RegExpSequence | -| test.cpp:183:27:183:27 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:186:24:186:24 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:186:24:186:25 | a+ | RegExpPlus | -| test.cpp:186:24:186:26 | a+b | RegExpSequence | -| test.cpp:186:26:186:26 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:189:30:189:30 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:189:30:189:31 | a+ | RegExpPlus | -| test.cpp:189:30:189:32 | a+b | RegExpSequence | -| test.cpp:189:32:189:32 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:193:22:193:23 | \\s | RegExpCharacterClassEscape | -| test.cpp:193:22:193:24 | \\s+ | RegExpPlus | -| test.cpp:196:22:196:22 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:196:22:196:25 | a\\.b | RegExpSequence | -| test.cpp:196:23:196:24 | \\. | RegExpConstant,RegExpEscape | -| test.cpp:196:25:196:25 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:200:22:200:22 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:200:22:200:23 | a+ | RegExpPlus | -| test.cpp:200:22:200:24 | a+b | RegExpSequence | -| test.cpp:200:24:200:24 | b | RegExpConstant,RegExpNormalChar | -| test.cpp:203:28:203:28 | a | RegExpConstant,RegExpNormalChar | -| test.cpp:203:28:203:29 | a+ | RegExpPlus | -| test.cpp:203:28:203:30 | a+b | RegExpSequence | -| test.cpp:203:30:203:30 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:118:23:118:29 | [a-f\\d] | RegExpCharacterClass | +| test.cpp:118:23:118:30 | [a-f\\d]+ | RegExpPlus | +| test.cpp:118:24:118:24 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:118:24:118:26 | a-f | RegExpCharacterRange | +| test.cpp:118:26:118:26 | f | RegExpConstant,RegExpNormalChar | +| test.cpp:118:27:118:28 | \\d | RegExpCharacterClassEscape | +| test.cpp:121:24:121:34 | [[:alpha:]] | RegExpCharacterClass | +| test.cpp:121:24:121:45 | [[:alpha:]][[:digit:]] | RegExpSequence | +| test.cpp:121:25:121:33 | [:alpha:] | RegExpNamedCharacterProperty | +| test.cpp:121:35:121:45 | [[:digit:]] | RegExpCharacterClass | +| test.cpp:121:36:121:44 | [:digit:] | RegExpNamedCharacterProperty | +| test.cpp:124:24:124:43 | [[:alpha:][:digit:]] | RegExpCharacterClass | +| test.cpp:124:25:124:33 | [:alpha:] | RegExpNamedCharacterProperty | +| test.cpp:124:34:124:42 | [:digit:] | RegExpNamedCharacterProperty | +| test.cpp:127:24:127:40 | [A-F[:digit:]a-f] | RegExpCharacterClass | +| test.cpp:127:25:127:25 | A | RegExpConstant,RegExpNormalChar | +| test.cpp:127:25:127:27 | A-F | RegExpCharacterRange | +| test.cpp:127:27:127:27 | F | RegExpConstant,RegExpNormalChar | +| test.cpp:127:28:127:36 | [:digit:] | RegExpNamedCharacterProperty | +| test.cpp:127:37:127:37 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:127:37:127:39 | a-f | RegExpCharacterRange | +| test.cpp:127:39:127:39 | f | RegExpConstant,RegExpNormalChar | +| test.cpp:130:24:130:32 | [:digit:] | RegExpCharacterClass | +| test.cpp:130:25:130:25 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:130:26:130:26 | d | RegExpConstant,RegExpNormalChar | +| test.cpp:130:27:130:27 | i | RegExpConstant,RegExpNormalChar | +| test.cpp:130:28:130:28 | g | RegExpConstant,RegExpNormalChar | +| test.cpp:130:29:130:29 | i | RegExpConstant,RegExpNormalChar | +| test.cpp:130:30:130:30 | t | RegExpConstant,RegExpNormalChar | +| test.cpp:130:31:130:31 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:133:24:133:32 | [:alpha:] | RegExpCharacterClass | +| test.cpp:133:25:133:25 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:133:26:133:26 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:133:27:133:27 | l | RegExpConstant,RegExpNormalChar | +| test.cpp:133:28:133:28 | p | RegExpConstant,RegExpNormalChar | +| test.cpp:133:29:133:29 | h | RegExpConstant,RegExpNormalChar | +| test.cpp:133:30:133:30 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:133:31:133:31 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:136:24:136:24 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:136:24:136:30 | a[:b:]c | RegExpSequence | +| test.cpp:136:25:136:29 | [:b:] | RegExpCharacterClass | +| test.cpp:136:26:136:26 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:136:27:136:27 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:136:28:136:28 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:136:30:136:30 | c | RegExpConstant,RegExpNormalChar | +| test.cpp:139:24:139:36 | [[:alpha:]-z] | RegExpCharacterClass | +| test.cpp:139:25:139:33 | [:alpha:] | RegExpNamedCharacterProperty | +| test.cpp:139:25:139:35 | [:alpha:]-z | RegExpCharacterRange | +| test.cpp:139:35:139:35 | z | RegExpConstant,RegExpNormalChar | +| test.cpp:142:24:142:32 | [[:alpha] | RegExpCharacterClass | +| test.cpp:142:25:142:25 | [ | RegExpConstant,RegExpNormalChar | +| test.cpp:142:26:142:26 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:142:27:142:27 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:142:28:142:28 | l | RegExpConstant,RegExpNormalChar | +| test.cpp:142:29:142:29 | p | RegExpConstant,RegExpNormalChar | +| test.cpp:142:30:142:30 | h | RegExpConstant,RegExpNormalChar | +| test.cpp:142:31:142:31 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:145:24:145:35 | []a[:alpha:] | RegExpCharacterClass | +| test.cpp:145:24:145:36 | []a[:alpha:]] | RegExpSequence | +| test.cpp:145:25:145:25 | ] | RegExpConstant,RegExpNormalChar | +| test.cpp:145:26:145:26 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:145:27:145:27 | [ | RegExpConstant,RegExpNormalChar | +| test.cpp:145:28:145:28 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:145:29:145:29 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:145:30:145:30 | l | RegExpConstant,RegExpNormalChar | +| test.cpp:145:31:145:31 | p | RegExpConstant,RegExpNormalChar | +| test.cpp:145:32:145:32 | h | RegExpConstant,RegExpNormalChar | +| test.cpp:145:33:145:33 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:145:34:145:34 | : | RegExpConstant,RegExpNormalChar | +| test.cpp:145:36:145:36 | ] | RegExpConstant,RegExpNormalChar | +| test.cpp:148:25:148:53 | [[:alpha:][:digit:][:space:]] | RegExpCharacterClass | +| test.cpp:148:26:148:34 | [:alpha:] | RegExpNamedCharacterProperty | +| test.cpp:148:35:148:43 | [:digit:] | RegExpNamedCharacterProperty | +| test.cpp:148:44:148:52 | [:space:] | RegExpNamedCharacterProperty | +| test.cpp:151:25:151:36 | [[:xdigit:]] | RegExpCharacterClass | +| test.cpp:151:26:151:35 | [:xdigit:] | RegExpNamedCharacterProperty | +| test.cpp:152:25:152:35 | [[:blank:]] | RegExpCharacterClass | +| test.cpp:152:26:152:34 | [:blank:] | RegExpNamedCharacterProperty | +| test.cpp:153:25:153:35 | [[:cntrl:]] | RegExpCharacterClass | +| test.cpp:153:26:153:34 | [:cntrl:] | RegExpNamedCharacterProperty | +| test.cpp:154:25:154:35 | [[:graph:]] | RegExpCharacterClass | +| test.cpp:154:26:154:34 | [:graph:] | RegExpNamedCharacterProperty | +| test.cpp:157:25:157:25 | ^ | RegExpCaret | +| test.cpp:157:25:157:92 | ^([[:alpha:]]+[[:digit:]]*[[:space:]]?)+([[:punct:]]\|[[:xdigit:]])+$ | RegExpSequence | +| test.cpp:157:26:157:63 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?) | RegExpGroup | +| test.cpp:157:26:157:64 | ([[:alpha:]]+[[:digit:]]*[[:space:]]?)+ | RegExpPlus | +| test.cpp:157:27:157:37 | [[:alpha:]] | RegExpCharacterClass | +| test.cpp:157:27:157:38 | [[:alpha:]]+ | RegExpPlus | +| test.cpp:157:27:157:62 | [[:alpha:]]+[[:digit:]]*[[:space:]]? | RegExpSequence | +| test.cpp:157:28:157:36 | [:alpha:] | RegExpNamedCharacterProperty | +| test.cpp:157:39:157:49 | [[:digit:]] | RegExpCharacterClass | +| test.cpp:157:39:157:50 | [[:digit:]]* | RegExpStar | +| test.cpp:157:40:157:48 | [:digit:] | RegExpNamedCharacterProperty | +| test.cpp:157:51:157:61 | [[:space:]] | RegExpCharacterClass | +| test.cpp:157:51:157:62 | [[:space:]]? | RegExpOpt | +| test.cpp:157:52:157:60 | [:space:] | RegExpNamedCharacterProperty | +| test.cpp:157:65:157:90 | ([[:punct:]]\|[[:xdigit:]]) | RegExpGroup | +| test.cpp:157:65:157:91 | ([[:punct:]]\|[[:xdigit:]])+ | RegExpPlus | +| test.cpp:157:66:157:76 | [[:punct:]] | RegExpCharacterClass | +| test.cpp:157:66:157:89 | [[:punct:]]\|[[:xdigit:]] | RegExpAlt | +| test.cpp:157:67:157:75 | [:punct:] | RegExpNamedCharacterProperty | +| test.cpp:157:78:157:89 | [[:xdigit:]] | RegExpCharacterClass | +| test.cpp:157:79:157:88 | [:xdigit:] | RegExpNamedCharacterProperty | +| test.cpp:157:92:157:92 | $ | RegExpDollar | +| test.cpp:162:21:162:26 | \\u9879 | RegExpConstant,RegExpEscape | +| test.cpp:170:23:170:23 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:170:23:170:24 | a+ | RegExpPlus | +| test.cpp:170:23:170:25 | a+b | RegExpSequence | +| test.cpp:170:25:170:25 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:173:23:173:23 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:173:23:173:24 | a+ | RegExpPlus | +| test.cpp:173:23:173:25 | a+b | RegExpSequence | +| test.cpp:173:25:173:25 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:176:24:176:25 | \\s | RegExpCharacterClassEscape | +| test.cpp:176:24:176:26 | \\s+ | RegExpPlus | +| test.cpp:176:24:176:27 | \\s+$ | RegExpSequence | +| test.cpp:176:27:176:27 | $ | RegExpDollar | +| test.cpp:179:24:179:25 | \\( | RegExpConstant,RegExpEscape | +| test.cpp:179:24:179:37 | \\(([,\\w]+)+\\)$ | RegExpSequence | +| test.cpp:179:26:179:33 | ([,\\w]+) | RegExpGroup | +| test.cpp:179:26:179:34 | ([,\\w]+)+ | RegExpPlus | +| test.cpp:179:27:179:31 | [,\\w] | RegExpCharacterClass | +| test.cpp:179:27:179:32 | [,\\w]+ | RegExpPlus | +| test.cpp:179:28:179:28 | , | RegExpConstant,RegExpNormalChar | +| test.cpp:179:29:179:30 | \\w | RegExpCharacterClassEscape | +| test.cpp:179:35:179:36 | \\) | RegExpConstant,RegExpEscape | +| test.cpp:179:37:179:37 | $ | RegExpDollar | +| test.cpp:182:25:182:25 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:182:25:182:26 | a+ | RegExpPlus | +| test.cpp:182:25:182:27 | a+b | RegExpSequence | +| test.cpp:182:27:182:27 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:185:24:185:24 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:185:24:185:25 | a+ | RegExpPlus | +| test.cpp:185:24:185:26 | a+b | RegExpSequence | +| test.cpp:185:26:185:26 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:188:30:188:30 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:188:30:188:31 | a+ | RegExpPlus | +| test.cpp:188:30:188:32 | a+b | RegExpSequence | +| test.cpp:188:32:188:32 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:192:22:192:23 | \\s | RegExpCharacterClassEscape | +| test.cpp:192:22:192:24 | \\s+ | RegExpPlus | +| test.cpp:195:22:195:22 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:195:22:195:25 | a\\.b | RegExpSequence | +| test.cpp:195:23:195:24 | \\. | RegExpConstant,RegExpEscape | +| test.cpp:195:25:195:25 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:199:22:199:22 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:199:22:199:23 | a+ | RegExpPlus | +| test.cpp:199:22:199:24 | a+b | RegExpSequence | +| test.cpp:199:24:199:24 | b | RegExpConstant,RegExpNormalChar | +| test.cpp:202:28:202:28 | a | RegExpConstant,RegExpNormalChar | +| test.cpp:202:28:202:29 | a+ | RegExpPlus | +| test.cpp:202:28:202:30 | a+b | RegExpSequence | +| test.cpp:202:30:202:30 | b | RegExpConstant,RegExpNormalChar | regExpNormalCharValue | test.cpp:33:21:33:23 | abc | abc | | test.cpp:36:22:36:22 | a | a | @@ -399,77 +383,74 @@ regExpNormalCharValue | test.cpp:107:30:107:30 | e | e | | test.cpp:108:25:108:25 | : | : | | test.cpp:108:28:108:29 | \\w | w | -| test.cpp:111:27:111:28 | \\w | w | | test.cpp:115:24:115:24 | a | a | | test.cpp:115:27:115:27 | b | b | -| test.cpp:116:30:116:30 | q | q | -| test.cpp:116:33:116:34 | \\s | s | -| test.cpp:119:24:119:24 | a | a | -| test.cpp:119:26:119:26 | f | f | -| test.cpp:119:27:119:28 | \\d | d | -| test.cpp:128:25:128:25 | A | A | -| test.cpp:128:27:128:27 | F | F | -| test.cpp:128:37:128:37 | a | a | -| test.cpp:128:39:128:39 | f | f | -| test.cpp:131:25:131:25 | : | : | -| test.cpp:131:26:131:26 | d | d | -| test.cpp:131:27:131:27 | i | i | -| test.cpp:131:28:131:28 | g | g | -| test.cpp:131:29:131:29 | i | i | -| test.cpp:131:30:131:30 | t | t | -| test.cpp:131:31:131:31 | : | : | -| test.cpp:134:25:134:25 | : | : | -| test.cpp:134:26:134:26 | a | a | -| test.cpp:134:27:134:27 | l | l | -| test.cpp:134:28:134:28 | p | p | -| test.cpp:134:29:134:29 | h | h | -| test.cpp:134:30:134:30 | a | a | -| test.cpp:134:31:134:31 | : | : | -| test.cpp:137:24:137:24 | a | a | -| test.cpp:137:26:137:26 | : | : | -| test.cpp:137:27:137:27 | b | b | -| test.cpp:137:28:137:28 | : | : | -| test.cpp:137:30:137:30 | c | c | -| test.cpp:140:35:140:35 | z | z | -| test.cpp:143:25:143:25 | [ | [ | -| test.cpp:143:26:143:26 | : | : | -| test.cpp:143:27:143:27 | a | a | -| test.cpp:143:28:143:28 | l | l | -| test.cpp:143:29:143:29 | p | p | -| test.cpp:143:30:143:30 | h | h | -| test.cpp:143:31:143:31 | a | a | -| test.cpp:146:25:146:25 | ] | ] | -| test.cpp:146:26:146:26 | a | a | -| test.cpp:146:27:146:27 | [ | [ | -| test.cpp:146:28:146:28 | : | : | -| test.cpp:146:29:146:29 | a | a | -| test.cpp:146:30:146:30 | l | l | -| test.cpp:146:31:146:31 | p | p | -| test.cpp:146:32:146:32 | h | h | -| test.cpp:146:33:146:33 | a | a | -| test.cpp:146:34:146:34 | : | : | -| test.cpp:146:36:146:36 | ] | ] | -| test.cpp:163:21:163:26 | \\u9879 | \u9879 | -| test.cpp:171:23:171:23 | a | a | -| test.cpp:171:25:171:25 | b | b | -| test.cpp:174:23:174:23 | a | a | -| test.cpp:174:25:174:25 | b | b | -| test.cpp:177:24:177:25 | \\s | s | -| test.cpp:180:24:180:25 | \\( | ( | -| test.cpp:180:28:180:28 | , | , | -| test.cpp:180:29:180:30 | \\w | w | -| test.cpp:180:35:180:36 | \\) | ) | -| test.cpp:183:25:183:25 | a | a | -| test.cpp:183:27:183:27 | b | b | -| test.cpp:186:24:186:24 | a | a | -| test.cpp:186:26:186:26 | b | b | -| test.cpp:189:30:189:30 | a | a | -| test.cpp:189:32:189:32 | b | b | -| test.cpp:193:22:193:23 | \\s | s | -| test.cpp:196:22:196:22 | a | a | -| test.cpp:196:23:196:24 | \\. | . | -| test.cpp:196:25:196:25 | b | b | -| test.cpp:200:22:200:22 | a | a | -| test.cpp:200:24:200:24 | b | b | -| test.cpp:203:28:203:28 | a | a | -| test.cpp:203:30:203:30 | b | b | +| test.cpp:118:24:118:24 | a | a | +| test.cpp:118:26:118:26 | f | f | +| test.cpp:118:27:118:28 | \\d | d | +| test.cpp:127:25:127:25 | A | A | +| test.cpp:127:27:127:27 | F | F | +| test.cpp:127:37:127:37 | a | a | +| test.cpp:127:39:127:39 | f | f | +| test.cpp:130:25:130:25 | : | : | +| test.cpp:130:26:130:26 | d | d | +| test.cpp:130:27:130:27 | i | i | +| test.cpp:130:28:130:28 | g | g | +| test.cpp:130:29:130:29 | i | i | +| test.cpp:130:30:130:30 | t | t | +| test.cpp:130:31:130:31 | : | : | +| test.cpp:133:25:133:25 | : | : | +| test.cpp:133:26:133:26 | a | a | +| test.cpp:133:27:133:27 | l | l | +| test.cpp:133:28:133:28 | p | p | +| test.cpp:133:29:133:29 | h | h | +| test.cpp:133:30:133:30 | a | a | +| test.cpp:133:31:133:31 | : | : | +| test.cpp:136:24:136:24 | a | a | +| test.cpp:136:26:136:26 | : | : | +| test.cpp:136:27:136:27 | b | b | +| test.cpp:136:28:136:28 | : | : | +| test.cpp:136:30:136:30 | c | c | +| test.cpp:139:35:139:35 | z | z | +| test.cpp:142:25:142:25 | [ | [ | +| test.cpp:142:26:142:26 | : | : | +| test.cpp:142:27:142:27 | a | a | +| test.cpp:142:28:142:28 | l | l | +| test.cpp:142:29:142:29 | p | p | +| test.cpp:142:30:142:30 | h | h | +| test.cpp:142:31:142:31 | a | a | +| test.cpp:145:25:145:25 | ] | ] | +| test.cpp:145:26:145:26 | a | a | +| test.cpp:145:27:145:27 | [ | [ | +| test.cpp:145:28:145:28 | : | : | +| test.cpp:145:29:145:29 | a | a | +| test.cpp:145:30:145:30 | l | l | +| test.cpp:145:31:145:31 | p | p | +| test.cpp:145:32:145:32 | h | h | +| test.cpp:145:33:145:33 | a | a | +| test.cpp:145:34:145:34 | : | : | +| test.cpp:145:36:145:36 | ] | ] | +| test.cpp:162:21:162:26 | \\u9879 | \u9879 | +| test.cpp:170:23:170:23 | a | a | +| test.cpp:170:25:170:25 | b | b | +| test.cpp:173:23:173:23 | a | a | +| test.cpp:173:25:173:25 | b | b | +| test.cpp:176:24:176:25 | \\s | s | +| test.cpp:179:24:179:25 | \\( | ( | +| test.cpp:179:28:179:28 | , | , | +| test.cpp:179:29:179:30 | \\w | w | +| test.cpp:179:35:179:36 | \\) | ) | +| test.cpp:182:25:182:25 | a | a | +| test.cpp:182:27:182:27 | b | b | +| test.cpp:185:24:185:24 | a | a | +| test.cpp:185:26:185:26 | b | b | +| test.cpp:188:30:188:30 | a | a | +| test.cpp:188:32:188:32 | b | b | +| test.cpp:192:22:192:23 | \\s | s | +| test.cpp:195:22:195:22 | a | a | +| test.cpp:195:23:195:24 | \\. | . | +| test.cpp:195:25:195:25 | b | b | +| test.cpp:199:22:199:22 | a | a | +| test.cpp:199:24:199:24 | b | b | +| test.cpp:202:28:202:28 | a | a | +| test.cpp:202:30:202:30 | b | b | diff --git a/cpp/ql/test/library-tests/regex/regexp.ql b/cpp/ql/test/library-tests/regex/regexp.ql index 0b56d2f10b8..119a4b28c3c 100644 --- a/cpp/ql/test/library-tests/regex/regexp.ql +++ b/cpp/ql/test/library-tests/regex/regexp.ql @@ -1,8 +1,6 @@ import cpp import semmle.code.cpp.regex.RegexTreeView as RE -query predicate groupName(RE::RegExpGroup g, string name) { name = g.getName() } - query predicate groupNumber(RE::RegExpGroup g, int number) { number = g.getNumber() } query predicate term(RE::RegExpTerm term, string c) { c = term.getPrimaryQlClasses() } diff --git a/cpp/ql/test/library-tests/regex/test.cpp b/cpp/ql/test/library-tests/regex/test.cpp index 9cbb31b4ace..ea81639a4c8 100644 --- a/cpp/ql/test/library-tests/regex/test.cpp +++ b/cpp/ql/test/library-tests/regex/test.cpp @@ -107,13 +107,12 @@ void test() { std::regex r_grp3("(a|b|cd)e"); std::regex r_grp4("(?::+)\\w"); // Non-capturing group matching colons - // Named groups - std::regex r_ng1("(?\\w+)"); + // Named groups are not supported by the ECMAScript grammar used by + // `std::regex`, so the parser does not recognise `(?...)`. // Backreferences std::regex r_bref1("(a+)b+\\1"); - std::regex r_bref2("(?q+)\\s+\\k+"); // A character class combining a range with an escape class std::regex r_prop1("[a-f\\d]+");