Skip to content

Commit 657351e

Browse files
committed
Rename startOfLine/endOfLine -> caretAnchor/dollarAnchor
1 parent 8f8c7d0 commit 657351e

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed

Sources/_RegexParser/Regex/AST/Atom.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ extension AST {
6363
case dot
6464

6565
/// ^
66-
case startOfLine
66+
case caretAnchor
6767

6868
/// $
69-
case endOfLine
69+
case dollarAnchor
7070

7171
// References
7272
case backreference(Reference)
@@ -105,8 +105,8 @@ extension AST.Atom {
105105
case .backtrackingDirective(let v): return v
106106
case .changeMatchingOptions(let v): return v
107107
case .dot: return nil
108-
case .startOfLine: return nil
109-
case .endOfLine: return nil
108+
case .caretAnchor: return nil
109+
case .dollarAnchor: return nil
110110
case .invalid: return nil
111111
}
112112
}
@@ -536,10 +536,10 @@ extension AST.Atom {
536536
case notTextSegment = #"\Y"#
537537

538538
/// ^
539-
case startOfLine = #"^"#
539+
case caretAnchor = #"^"#
540540

541541
/// $
542-
case endOfLine = #"$"#
542+
case dollarAnchor = #"$"#
543543

544544
/// \b (from outside a custom character class)
545545
case wordBoundary = #"\b"#
@@ -551,8 +551,8 @@ extension AST.Atom {
551551

552552
public var assertionKind: AssertionKind? {
553553
switch kind {
554-
case .startOfLine: return .startOfLine
555-
case .endOfLine: return .endOfLine
554+
case .caretAnchor: return .caretAnchor
555+
case .dollarAnchor: return .dollarAnchor
556556

557557
case .escaped(.wordBoundary): return .wordBoundary
558558
case .escaped(.notWordBoundary): return .notWordBoundary
@@ -806,9 +806,9 @@ extension AST.Atom {
806806
// the AST? Or defer for the matching engine?
807807
return nil
808808

809-
case .scalarSequence, .property, .dot, .startOfLine, .endOfLine,
810-
.backreference, .subpattern, .callout, .backtrackingDirective,
811-
.changeMatchingOptions, .invalid:
809+
case .scalarSequence, .property, .dot, .caretAnchor,
810+
.dollarAnchor, .backreference, .subpattern, .callout,
811+
.backtrackingDirective, .changeMatchingOptions, .invalid:
812812
return nil
813813
}
814814
}
@@ -858,7 +858,7 @@ extension AST.Atom {
858858
case .keyboardMetaControl(let x):
859859
return "\\M-\\C-\(x)"
860860

861-
case .property, .escaped, .dot, .startOfLine, .endOfLine,
861+
case .property, .escaped, .dot, .caretAnchor, .dollarAnchor,
862862
.backreference, .subpattern, .namedCharacter, .callout,
863863
.backtrackingDirective, .changeMatchingOptions, .invalid:
864864
return nil
@@ -874,7 +874,7 @@ extension AST.Atom {
874874
// TODO: Are callouts quantifiable?
875875
case .escaped(let esc):
876876
return esc.isQuantifiable
877-
case .startOfLine, .endOfLine:
877+
case .caretAnchor, .dollarAnchor:
878878
return false
879879
default:
880880
return true

Sources/_RegexParser/Regex/Parse/LexicalAnalysis.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,8 +2074,8 @@ extension Parser {
20742074

20752075
// (sometimes) special metacharacters
20762076
case ".": return customCC ? .char(".") : .dot
2077-
case "^": return customCC ? .char("^") : .startOfLine
2078-
case "$": return customCC ? .char("$") : .endOfLine
2077+
case "^": return customCC ? .char("^") : .caretAnchor
2078+
case "$": return customCC ? .char("$") : .dollarAnchor
20792079

20802080
// Escaped
20812081
case "\\": return p.expectEscaped().value

Sources/_RegexParser/Regex/Parse/Sema.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ extension RegexValidator {
288288
at: atom.location)
289289
}
290290

291-
case .char, .scalar, .startOfLine, .endOfLine, .dot:
291+
case .char, .scalar, .caretAnchor, .dollarAnchor, .dot:
292292
break
293293

294294
case .invalid:

Sources/_RegexParser/Regex/Printing/DumpAST.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ extension AST.Atom {
153153
case .keyboardControl, .keyboardMeta, .keyboardMetaControl:
154154
fatalError("TODO")
155155

156-
case .dot: return "."
157-
case .startOfLine: return "^"
158-
case .endOfLine: return "$"
156+
case .dot: return "."
157+
case .caretAnchor: return "^"
158+
case .dollarAnchor: return "$"
159159

160160
case .backreference(let r), .subpattern(let r):
161161
return "\(r._dumpBase)"

Sources/_StringProcessing/ByteCodeGen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fileprivate extension Compiler.ByteCodeGen {
202202
!input.isOnGraphemeClusterBoundary(pos)
203203
}
204204

205-
case .startOfLine:
205+
case .caretAnchor:
206206
// FIXME: Anchor.startOfLine must always use this first branch
207207
// The behavior of `^` should depend on `anchorsMatchNewlines`, but
208208
// the DSL-based `.startOfLine` anchor should always match the start
@@ -224,7 +224,7 @@ fileprivate extension Compiler.ByteCodeGen {
224224
}
225225
}
226226

227-
case .endOfLine:
227+
case .dollarAnchor:
228228
// FIXME: Anchor.endOfLine must always use this first branch
229229
// The behavior of `$` should depend on `anchorsMatchNewlines`, but
230230
// the DSL-based `.endOfLine` anchor should always match the end

Sources/_StringProcessing/ConsumerInterface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ extension AST.Atom {
293293
"Should have been handled by tree conversion")
294294
fatalError(".atom(.dot) is handled in emitDot")
295295

296-
case .startOfLine, .endOfLine:
296+
case .caretAnchor, .dollarAnchor:
297297
// handled in emitAssertion
298298
return nil
299299

Sources/_StringProcessing/PrintAsPattern.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,11 @@ extension AST.Atom.AssertionKind {
651651
// TODO: Some way to integrate this with conversion...
652652
var _patternBase: String {
653653
switch self {
654-
case .startOfLine:
654+
case .caretAnchor:
655+
// FIXME: The DSL doesn't have a way of representing this.
655656
return "Anchor.startOfLine"
656-
case .endOfLine:
657+
case .dollarAnchor:
658+
// FIXME: The DSL doesn't have a way of representing this.
657659
return "Anchor.endOfLine"
658660
case .wordBoundary:
659661
return "Anchor.wordBoundary"
@@ -923,7 +925,7 @@ extension AST.Atom {
923925
// The DSL does not have an equivalent to '.', print as a regex.
924926
return ("/./", false)
925927

926-
case .startOfLine, .endOfLine:
928+
case .caretAnchor, .dollarAnchor:
927929
fatalError("unreachable")
928930

929931
case .backreference:
@@ -978,7 +980,7 @@ extension AST.Atom {
978980
case .dot:
979981
return "."
980982

981-
case .startOfLine, .endOfLine:
983+
case .caretAnchor, .dollarAnchor:
982984
fatalError("unreachable")
983985

984986
case .backreference:

Sources/_StringProcessing/Regex/DSLTree.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,10 @@ extension DSLTree {
721721
: .init(ast: .textSegment)
722722
}
723723
public static func startOfLine(_ inverted: Bool = false) -> Self {
724-
.init(ast: .startOfLine)
724+
.init(ast: .caretAnchor)
725725
}
726726
public static func endOfLine(_ inverted: Bool = false) -> Self {
727-
.init(ast: .endOfLine)
727+
.init(ast: .dollarAnchor)
728728
}
729729
public static func wordBoundary(_ inverted: Bool = false) -> Self {
730730
inverted

0 commit comments

Comments
 (0)