99//
1010//===----------------------------------------------------------------------===//
1111
12- /// A regex abstract syntax tree. This is a top-level type that stores the root
13- /// node.
12+ /// A regex abstract syntax tree.
13+ ///
14+ /// This is a top-level type that stores the root node.
1415public struct AST : Hashable {
1516 public var root : AST . Node
1617 public var globalOptions : GlobalMatchingOptionSequence ?
@@ -22,7 +23,7 @@ public struct AST: Hashable {
2223}
2324
2425extension AST {
25- /// Whether this AST tree has nested somewhere inside it a capture .
26+ /// Whether this AST tree contains at least one capture nested inside of it .
2627 public var hasCapture : Bool { root. hasCapture }
2728
2829 /// The capture structure of this AST tree.
@@ -94,7 +95,9 @@ extension AST.Node {
9495 _associatedValue as? T
9596 }
9697
97- /// If this node is a parent node, access its children
98+ /// The child nodes of this node.
99+ ///
100+ /// If the node isn't a parent node, this value is `nil`.
98101 public var children : [ AST . Node ] ? {
99102 return ( _associatedValue as? _ASTParent ) ? . children
100103 }
@@ -103,15 +106,15 @@ extension AST.Node {
103106 _associatedValue. location
104107 }
105108
106- /// Whether this node is " trivia" or non-semantic, like comments
109+ /// Whether this node is trivia or non-semantic, like comments.
107110 public var isTrivia : Bool {
108111 switch self {
109112 case . trivia: return true
110113 default : return false
111114 }
112115 }
113116
114- /// Whether this node has nested somewhere inside it a capture
117+ /// Whether this node contains at least one capture nested inside of it.
115118 public var hasCapture : Bool {
116119 switch self {
117120 case . group( let g) where g. kind. value. isCapturing:
@@ -122,7 +125,7 @@ extension AST.Node {
122125 return self . children? . any ( \. hasCapture) ?? false
123126 }
124127
125- /// Whether this AST node may be used as the operand of a quantifier such as
128+ /// Whether this node may be used as the operand of a quantifier such as
126129 /// `?`, `+` or `*`.
127130 public var isQuantifiable : Bool {
128131 switch self {
@@ -203,7 +206,9 @@ extension AST {
203206 }
204207 }
205208
206- /// An Oniguruma absent function. This is used to model a pattern which should
209+ /// An Oniguruma absent function.
210+ ///
211+ /// This is used to model a pattern which should
207212 /// not be matched against across varying scopes.
208213 public struct AbsentFunction : Hashable , _ASTNode {
209214 public enum Start : Hashable {
0 commit comments