@@ -27,7 +27,6 @@ RegExpTerm getParsedRegExp(StringLiteral re) { result.getRegex() = re and result
2727// ---------------------------------------------------------------------------
2828// newtype TRegExpParent
2929// ---------------------------------------------------------------------------
30-
3130/**
3231 * An element that is either a regex literal (the root of a parse tree) or a
3332 * regex term (a node in the parse tree).
@@ -48,9 +47,7 @@ private newtype TRegExpParent =
4847 /** An alternation (`a|b`). */
4948 TRegExpAlt ( RegExp re , int start , int end ) {
5049 re .alternation ( start , end ) and
51- exists ( int part_end |
52- re .alternationOption ( start , end , start , part_end ) and part_end < end
53- ) // require at least two alternatives
50+ exists ( int part_end | re .alternationOption ( start , end , start , part_end ) and part_end < end ) // require at least two alternatives
5451 } or
5552 /** A character class (`[...]`). */
5653 TRegExpCharacterClass ( RegExp re , int start , int end ) { re .charSet ( start , end ) } or
@@ -81,7 +78,6 @@ private newtype TRegExpParent =
8178// ---------------------------------------------------------------------------
8279// Helper: sequence children
8380// ---------------------------------------------------------------------------
84-
8581pragma [ nomagic]
8682private int seqChildEnd ( RegExp re , int start , int end , int i ) {
8783 result = seqChild ( re , start , end , i ) .getEnd ( )
@@ -110,13 +106,11 @@ private RegExpTerm seqChild(RegExp re, int start, int end, int i) {
110106// ---------------------------------------------------------------------------
111107// Module Impl (implements RegexTreeViewSig)
112108// ---------------------------------------------------------------------------
113-
114109/** An implementation that satisfies the `RegexTreeViewSig` signature. */
115110module Impl implements RegexTreeViewSig {
116111 // -------------------------------------------------------------------------
117112 // RegExpParent
118113 // -------------------------------------------------------------------------
119-
120114 /**
121115 * An element containing a regular expression term: either the literal itself
122116 * or a term node.
@@ -150,16 +144,13 @@ module Impl implements RegexTreeViewSig {
150144 // -------------------------------------------------------------------------
151145 // RegExpLiteral
152146 // -------------------------------------------------------------------------
153-
154147 /** A string literal used as a regular expression. */
155148 class RegExpLiteral extends TRegExpLiteral , RegExpParent {
156149 RegExp re ;
157150
158151 RegExpLiteral ( ) { this = TRegExpLiteral ( re ) }
159152
160- override RegExpTerm getChild ( int i ) {
161- i = 0 and result .getRegex ( ) = re and result .isRootTerm ( )
162- }
153+ override RegExpTerm getChild ( int i ) { i = 0 and result .getRegex ( ) = re and result .isRootTerm ( ) }
163154
164155 /**
165156 * Holds if dot `.` matches all characters including newlines.
@@ -204,7 +195,6 @@ module Impl implements RegexTreeViewSig {
204195 // -------------------------------------------------------------------------
205196 // RegExpTerm (base class for all parse-tree nodes)
206197 // -------------------------------------------------------------------------
207-
208198 /**
209199 * A regular expression term — a node in the parse tree of a regex literal.
210200 */
@@ -353,7 +343,6 @@ module Impl implements RegexTreeViewSig {
353343 // -------------------------------------------------------------------------
354344 // Quantifiers
355345 // -------------------------------------------------------------------------
356-
357346 /**
358347 * A quantified regular expression term (`a*`, `a+`, `a?`, `a{n,m}`, etc.).
359348 */
@@ -436,7 +425,6 @@ module Impl implements RegexTreeViewSig {
436425 // -------------------------------------------------------------------------
437426 // Sequences and alternations
438427 // -------------------------------------------------------------------------
439-
440428 /**
441429 * A sequence term — two or more items in a row.
442430 *
@@ -492,7 +480,6 @@ module Impl implements RegexTreeViewSig {
492480 // -------------------------------------------------------------------------
493481 // Character escapes and normal characters
494482 // -------------------------------------------------------------------------
495-
496483 /**
497484 * A normal character in a regular expression (including escape sequences).
498485 */
@@ -566,7 +553,6 @@ module Impl implements RegexTreeViewSig {
566553 // -------------------------------------------------------------------------
567554 // Character classes [...]
568555 // -------------------------------------------------------------------------
569-
570556 /**
571557 * A character class in a regular expression (`[a-z]`, `[^0-9]`, etc.).
572558 */
@@ -712,7 +698,6 @@ module Impl implements RegexTreeViewSig {
712698 // -------------------------------------------------------------------------
713699 // Special characters (`.`, `^`, `$`, `\b`, `\B`)
714700 // -------------------------------------------------------------------------
715-
716701 /**
717702 * A special (meta) character in a regular expression.
718703 *
@@ -801,7 +786,6 @@ module Impl implements RegexTreeViewSig {
801786 // -------------------------------------------------------------------------
802787 // Groups (capturing, non-capturing, named, lookahead/lookbehind)
803788 // -------------------------------------------------------------------------
804-
805789 /**
806790 * A grouped regular expression: `(...)`, `(?:...)`, `(?<name>...)`, or an
807791 * assertion group `(?=...)`, etc.
@@ -840,7 +824,6 @@ module Impl implements RegexTreeViewSig {
840824 // -------------------------------------------------------------------------
841825 // Zero-width matches and sub-patterns (lookahead/lookbehind)
842826 // -------------------------------------------------------------------------
843-
844827 /**
845828 * A zero-width match: an empty group or an assertion.
846829 */
@@ -905,7 +888,6 @@ module Impl implements RegexTreeViewSig {
905888 // -------------------------------------------------------------------------
906889 // Back-references
907890 // -------------------------------------------------------------------------
908-
909891 /**
910892 * A back-reference: `\1`, `\k<name>`.
911893 */
@@ -944,7 +926,6 @@ module Impl implements RegexTreeViewSig {
944926 // -------------------------------------------------------------------------
945927 // RegExpConstant
946928 // -------------------------------------------------------------------------
947-
948929 /**
949930 * A constant regular expression term — a sequence of characters that matches
950931 * a fixed string. Currently this is always a single character (or escape
@@ -976,14 +957,12 @@ module Impl implements RegexTreeViewSig {
976957 // -------------------------------------------------------------------------
977958 // Top
978959 // -------------------------------------------------------------------------
979-
980960 /** The common supertype of all regex-related elements. */
981961 class Top = RegExpParent ;
982962
983963 // -------------------------------------------------------------------------
984964 // Signature predicates
985965 // -------------------------------------------------------------------------
986-
987966 /**
988967 * Holds if `term` is an escape class (e.g., `\d`), and `clazz` is the
989968 * character identifying the class (e.g., `"d"`).
0 commit comments