onigleam/ast
Types
Kind of absence function
pub type AbsenceKind {
Repeater
}
Constructors
-
Repeater(?~…) - absence repeater
Kind of assertion
pub type AssertionKind {
LineStart
LineEnd
StringStart
StringEnd
StringEndNewline
WordBoundary
TextSegmentBoundary
SearchStart
}
Constructors
-
LineStart^ - start of line
-
LineEnd$ - end of line
-
StringStart\A - start of string
-
StringEnd\z - end of string (absolute)
-
StringEndNewline\Z - end of string (allows trailing newline)
-
WordBoundary\b or \B - word boundary
-
TextSegmentBoundary\y or \Y - grapheme cluster boundary
-
SearchStart\G - search start (not supported)
Backreference reference type
pub type BackreferenceRef {
BackrefNumber(Int)
BackrefName(String)
}
Constructors
-
BackrefNumber(Int)Numbered backreference \1, \2, etc.
-
BackrefName(String)Named backreference \k
Callout argument
pub type CalloutArg {
CalloutArgInt(Int)
CalloutArgString(String)
}
Constructors
-
CalloutArgInt(Int) -
CalloutArgString(String)
Element that can appear in a character class
pub type CharacterClassElement {
CCCharacter(value: Int)
CCRange(min: Int, max: Int)
CCNested(
kind: CharacterClassKind,
negate: Bool,
body: List(CharacterClassElement),
)
CCSet(
kind: CharacterSetKind,
value: option.Option(String),
negate: Bool,
)
}
Constructors
-
CCCharacter(value: Int)A single character
-
CCRange(min: Int, max: Int)A character range like a-z
-
CCNested( kind: CharacterClassKind, negate: Bool, body: List(CharacterClassElement), )A nested character class
-
CCSet( kind: CharacterSetKind, value: option.Option(String), negate: Bool, )A character set like \d, \w, \p{…}, [:alpha:]
Kind of character class
pub type CharacterClassKind {
Union
Intersection
}
Constructors
-
UnionNormal union character class [abc]
-
IntersectionIntersection character class [a&&b]
Kind of character set
pub type CharacterSetKind {
Dot
Digit
WordChar
Space
Hex
Newline
NotNewline
Any
TextSegment
Property
Posix
}
Constructors
-
Dot. - any character
-
Digit\d, \D - digit
-
WordChar\w, \W - word character
-
Space\s, \S - whitespace
-
Hex\h, \H - hex digit
-
Newline\R - newline sequence
-
NotNewline\N - not newline
-
Any\O - any (true any including newlines)
-
TextSegment\X - extended grapheme cluster
-
Property\p{…} or \P{…} - Unicode property
-
Posix[:alpha:] etc - POSIX class
Kind of directive
pub type DirectiveKind {
Keep
FlagDirective
}
Constructors
-
Keep\K - keep (reset match start)
-
FlagDirective(?imx) - flag modifier
Flag modifiers for groups
pub type FlagModifiers {
FlagModifiers(
enable: option.Option(FlagSet),
disable: option.Option(FlagSet),
)
}
Constructors
-
FlagModifiers( enable: option.Option(FlagSet), disable: option.Option(FlagSet), )
Set of flags that can be enabled/disabled
pub type FlagSet {
FlagSet(ignore_case: Bool, dot_all: Bool, extended: Bool)
}
Constructors
-
FlagSet(ignore_case: Bool, dot_all: Bool, extended: Bool)
Flags extracted from the pattern
pub type Flags {
Flags(
ignore_case: Bool,
dot_all: Bool,
extended: Bool,
digit_is_ascii: Bool,
posix_is_ascii: Bool,
space_is_ascii: Bool,
word_is_ascii: Bool,
text_segment_mode: option.Option(TextSegmentMode),
)
}
Constructors
-
Flags( ignore_case: Bool, dot_all: Bool, extended: Bool, digit_is_ascii: Bool, posix_is_ascii: Bool, space_is_ascii: Bool, word_is_ascii: Bool, text_segment_mode: option.Option(TextSegmentMode), )
Kind of lookaround assertion
pub type LookaroundKind {
Lookahead
Lookbehind
}
Constructors
-
Lookahead(?=…) or (?!…)
-
Lookbehind(?<=…) or (?<!…)
Named callout kinds
pub type NamedCalloutKind {
CalloutFail
CalloutMismatch
CalloutSkip
CalloutError
CalloutMax
CalloutCount
CalloutTotalCount
CalloutCmp
CalloutCustom(String)
}
Constructors
-
CalloutFail -
CalloutMismatch -
CalloutSkip -
CalloutError -
CalloutMax -
CalloutCount -
CalloutTotalCount -
CalloutCmp -
CalloutCustom(String)
AST node representing any element in a pattern
pub type Node {
AssertionNode(kind: AssertionKind, negate: Bool)
BackreferenceNode(ref: BackreferenceRef, orphan: Bool)
CapturingGroupNode(
number: Int,
name: option.Option(String),
is_subroutined: Bool,
body: List(Alternative),
)
CharacterNode(value: Int)
CharacterClassNode(
kind: CharacterClassKind,
negate: Bool,
body: List(CharacterClassElement),
)
CharacterSetNode(
kind: CharacterSetKind,
value: option.Option(String),
negate: Bool,
)
DirectiveNode(
kind: DirectiveKind,
flags: option.Option(FlagModifiers),
)
GroupNode(
atomic: Bool,
flags: option.Option(FlagModifiers),
body: List(Alternative),
)
LookaroundNode(
kind: LookaroundKind,
negate: Bool,
body: List(Alternative),
)
AbsenceNode(kind: AbsenceKind, body: List(Alternative))
QuantifierNode(
kind: QuantifierKind,
min: Int,
max: option.Option(Int),
body: Node,
)
SubroutineNode(ref: SubroutineRef)
NamedCalloutNode(
kind: NamedCalloutKind,
tag: option.Option(String),
arguments: option.Option(List(CalloutArg)),
)
}
Constructors
-
AssertionNode(kind: AssertionKind, negate: Bool)An assertion like ^, $, \b, \A, etc.
-
BackreferenceNode(ref: BackreferenceRef, orphan: Bool)A backreference like \1 or \k
-
CapturingGroupNode( number: Int, name: option.Option(String), is_subroutined: Bool, body: List(Alternative), )A capturing group (…) or (?
…) -
CharacterNode(value: Int)A single character
-
CharacterClassNode( kind: CharacterClassKind, negate: Bool, body: List(CharacterClassElement), )A character class […] or 1
-
CharacterSetNode( kind: CharacterSetKind, value: option.Option(String), negate: Bool, )A character set like ., \d, \w, \s, \p{…}, [:alpha:]
-
DirectiveNode( kind: DirectiveKind, flags: option.Option(FlagModifiers), )A directive like \K or (?imx)
-
GroupNode( atomic: Bool, flags: option.Option(FlagModifiers), body: List(Alternative), )A non-capturing group (?:…) or atomic group (?>…)
-
LookaroundNode( kind: LookaroundKind, negate: Bool, body: List(Alternative), )A lookaround assertion (?=…), (?!…), (?<=…), (?<!…)
-
AbsenceNode(kind: AbsenceKind, body: List(Alternative))An absence function (?~…)
-
QuantifierNode( kind: QuantifierKind, min: Int, max: option.Option(Int), body: Node, )A quantifier *, +, ?, {n}, {n,}, {n,m}
-
SubroutineNode(ref: SubroutineRef)A subroutine call \g
or \g<0> -
NamedCalloutNode( kind: NamedCalloutKind, tag: option.Option(String), arguments: option.Option(List(CalloutArg)), )Named callout (*FAIL), (*SKIP), etc.
Kind of quantifier
pub type QuantifierKind {
Greedy
Lazy
Possessive
}
Constructors
-
GreedyGreedy quantifier (default)
-
LazyLazy quantifier (?)
-
PossessivePossessive quantifier (+) - not supported in gleam_regexp
The root AST node representing a complete regex pattern
pub type Regex {
Regex(body: List(Alternative), flags: Flags)
}
Constructors
-
Regex(body: List(Alternative), flags: Flags)
Subroutine reference type
pub type SubroutineRef {
Recursion
SubroutineNumber(Int)
SubroutineName(String)
}
Constructors
-
Recursion\g<0> - recursion (whole pattern)
-
SubroutineNumber(Int)\g
- call to numbered group -
SubroutineName(String)\g
- call to named group
Text segment matching mode
pub type TextSegmentMode {
Grapheme
Word
}
Constructors
-
Grapheme -
Word