Documentation
¶
Overview ¶
Package ast defines types used by the regex parser.
Index ¶
- func IsValidCharRangeElement(node CharClassElementNode) bool
- type AbsoluteEndOfStringAnchorNode
- type AbsoluteStartOfStringAnchorNode
- type AnyCharClassNode
- type BellEscapeNode
- type CaretEscapeNode
- type CarriageReturnEscapeNode
- type CharClassElementNode
- type CharClassNode
- type CharNode
- type CharRangeNode
- type ConcatenationElementNode
- type ConcatenationNode
- type DigitCharClassNode
- type EndOfStringAnchorNode
- type FormFeedEscapeNode
- type GroupNode
- type HexEscapeNode
- type HorizontalWhitespaceCharClassNode
- type InvalidNode
- type MetaCharEscapeNode
- type NMQuantifierNode
- type NQuantifierNode
- type NamedCharClassNode
- type NewlineEscapeNode
- type Node
- type NodeBase
- type NotDigitCharClassNode
- type NotHorizontalWhitespaceCharClassNode
- type NotVerticalWhitespaceCharClassNode
- type NotWhitespaceCharClassNode
- type NotWordBoundaryAnchorNode
- type NotWordCharClassNode
- type OctalEscapeNode
- type OneOrMoreQuantifierNode
- type PrimaryRegexNode
- type QuotedTextNode
- type StartOfStringAnchorNode
- type TabEscapeNode
- type UnicodeCharClassNode
- type UnicodeEscapeNode
- type UnionNode
- type VerticalWhitespaceCharClassNode
- type WhitespaceCharClassNode
- type WordBoundaryAnchorNode
- type WordCharClassNode
- type ZeroOrMoreQuantifierNode
- type ZeroOrOneQuantifierNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidCharRangeElement ¶
func IsValidCharRangeElement(node CharClassElementNode) bool
Types ¶
type AbsoluteEndOfStringAnchorNode ¶
type AbsoluteEndOfStringAnchorNode struct {
NodeBase
}
Represents the absolute end of text anchor eg. `\z`
func NewAbsoluteEndOfStringAnchorNode ¶
func NewAbsoluteEndOfStringAnchorNode(span *position.Span) *AbsoluteEndOfStringAnchorNode
Create a new absolute end of text anchor node.
type AbsoluteStartOfStringAnchorNode ¶
type AbsoluteStartOfStringAnchorNode struct {
NodeBase
}
Represents the absolute start of text anchor eg. `\A`
func NewAbsoluteStartOfStringAnchorNode ¶
func NewAbsoluteStartOfStringAnchorNode(span *position.Span) *AbsoluteStartOfStringAnchorNode
Create a new absolute start of text anchor node.
type AnyCharClassNode ¶
type AnyCharClassNode struct {
NodeBase
}
Represents the any char class eg. `.`
func NewAnyCharClassNode ¶
func NewAnyCharClassNode(span *position.Span) *AnyCharClassNode
Create a new any char class node.
type BellEscapeNode ¶
type BellEscapeNode struct {
NodeBase
}
Represents a bell escape eg. `\a`
func NewBellEscapeNode ¶
func NewBellEscapeNode(span *position.Span) *BellEscapeNode
Create a new bell escape node.
type CaretEscapeNode ¶
Represents a hex escape eg. `\cK`
func NewCaretEscapeNode ¶
func NewCaretEscapeNode(span *position.Span, value rune) *CaretEscapeNode
Create a new caret escape node.
type CarriageReturnEscapeNode ¶
type CarriageReturnEscapeNode struct {
NodeBase
}
Represents a carriage return escape eg. `\r`
func NewCarriageReturnEscapeNode ¶
func NewCarriageReturnEscapeNode(span *position.Span) *CarriageReturnEscapeNode
Create a new carriage return escape node.
type CharClassElementNode ¶
type CharClassElementNode interface {
Node
// contains filtered or unexported methods
}
Represents a char class element like a char, an escape etc
type CharClassNode ¶
type CharClassNode struct {
NodeBase
Elements []CharClassElementNode
Negated bool
}
Represents a char class eg. `[foa]`, `[^+*.123]`
func NewCharClassNode ¶
func NewCharClassNode(span *position.Span, elements []CharClassElementNode, negated bool) *CharClassNode
Create a new char class node.
type CharRangeNode ¶
type CharRangeNode struct {
NodeBase
Left CharClassElementNode
Right CharClassElementNode
}
Represents a char range eg. `a-z`, `\x22-\x7f`
func NewCharRangeNode ¶
func NewCharRangeNode(span *position.Span, left, right CharClassElementNode) *CharRangeNode
Create a new char range node.
type ConcatenationElementNode ¶
type ConcatenationElementNode interface {
Node
// contains filtered or unexported methods
}
Represents a concatenation element like a quantifier, a char, a char class etc
type ConcatenationNode ¶
type ConcatenationNode struct {
NodeBase
Elements []ConcatenationElementNode
}
Represents concatenated elements eg. `foo`, `\w-\d`
func NewConcatenationNode ¶
func NewConcatenationNode(span *position.Span, elements []ConcatenationElementNode) *ConcatenationNode
Create a new concatenation node.
type DigitCharClassNode ¶
type DigitCharClassNode struct {
NodeBase
}
Represents a digit char class eg. `\d`
func NewDigitCharClassNode ¶
func NewDigitCharClassNode(span *position.Span) *DigitCharClassNode
Create a new digit char class node.
type EndOfStringAnchorNode ¶
type EndOfStringAnchorNode struct {
NodeBase
}
Represents the end of string anchor eg. `$`
func NewEndOfStringAnchorNode ¶
func NewEndOfStringAnchorNode(span *position.Span) *EndOfStringAnchorNode
Create a new end of string anchor node.
type FormFeedEscapeNode ¶
type FormFeedEscapeNode struct {
NodeBase
}
Represents a form feed escape eg. `\f`
func NewFormFeedEscapeNode ¶
func NewFormFeedEscapeNode(span *position.Span) *FormFeedEscapeNode
Create a new form feed escape node.
type GroupNode ¶
type GroupNode struct {
NodeBase
Regex Node
Name string
SetFlags bitfield.BitField8
UnsetFlags bitfield.BitField8
NonCapturing bool
}
Represents groups eg. `(foo)`, `(?:\w|\d)`, `(?<foo>\w|\d)`
func NewGroupNode ¶
func NewGroupNode(span *position.Span, regex Node, name string, setFlags, unsetFlags bitfield.BitField8, nonCapturing bool) *GroupNode
Create a new group node.
func (*GroupNode) IsAnyFlagSet ¶
type HexEscapeNode ¶
Represents a hex escape eg. `\x20`, `\x{357}`
func NewHexEscapeNode ¶
func NewHexEscapeNode(span *position.Span, value string) *HexEscapeNode
Create a new hex escape node.
type HorizontalWhitespaceCharClassNode ¶
type HorizontalWhitespaceCharClassNode struct {
NodeBase
}
Represents a horizontal whitespace char class eg. `\h`
func NewHorizontalWhitespaceCharClassNode ¶
func NewHorizontalWhitespaceCharClassNode(span *position.Span) *HorizontalWhitespaceCharClassNode
Create a new horizontal whitespace char class node.
type InvalidNode ¶
Represents a syntax error.
func NewInvalidNode ¶
func NewInvalidNode(span *position.Span, tok *token.Token) *InvalidNode
Create a new invalid node.
type MetaCharEscapeNode ¶
Represents a meta-char escape eg. `\\`, `\.`, `\+`
func NewMetaCharEscapeNode ¶
func NewMetaCharEscapeNode(span *position.Span, char rune) *MetaCharEscapeNode
Create a new meta-char escape node.
type NMQuantifierNode ¶
Represents an NM quantifier eg. `f{5,}`, `\w{15, 6}?`
func NewNMQuantifierNode ¶
Create a new NM quantifier node.
type NQuantifierNode ¶
Represents an N quantifier eg. `f{5}`, `\w{15}?`
func NewNQuantifierNode ¶
Create a new N quantifier node.
type NamedCharClassNode ¶
Represents a named char class eg. `[:alpha:]`, `[:^digit:]`
func NewNamedCharClassNode ¶
func NewNamedCharClassNode(span *position.Span, name string, negated bool) *NamedCharClassNode
Create a new named char class node.
type NewlineEscapeNode ¶
type NewlineEscapeNode struct {
NodeBase
}
Represents a newline escape eg. `\n`
func NewNewlineEscapeNode ¶
func NewNewlineEscapeNode(span *position.Span) *NewlineEscapeNode
Create a new tab escape node.
type Node ¶
type Node interface {
position.SpanInterface
}
Every node type implements this interface.
type NodeBase ¶
type NodeBase struct {
// contains filtered or unexported fields
}
Base struct of every AST node.
type NotDigitCharClassNode ¶
type NotDigitCharClassNode struct {
NodeBase
}
Represents a not digit char class eg. `\D`
func NewNotDigitCharClassNode ¶
func NewNotDigitCharClassNode(span *position.Span) *NotDigitCharClassNode
Create a new not digit char class node.
type NotHorizontalWhitespaceCharClassNode ¶
type NotHorizontalWhitespaceCharClassNode struct {
NodeBase
}
Represents a not horizontal whitespace char class eg. `\H`
func NewNotHorizontalWhitespaceCharClassNode ¶
func NewNotHorizontalWhitespaceCharClassNode(span *position.Span) *NotHorizontalWhitespaceCharClassNode
Create a new horizontal whitespace char class node.
type NotVerticalWhitespaceCharClassNode ¶
type NotVerticalWhitespaceCharClassNode struct {
NodeBase
}
Represents a not vertical whitespace char class node eg. `\V`
func NewNotVerticalWhitespaceCharClassNode ¶
func NewNotVerticalWhitespaceCharClassNode(span *position.Span) *NotVerticalWhitespaceCharClassNode
Create a new vertical whitespace char class node.
type NotWhitespaceCharClassNode ¶
type NotWhitespaceCharClassNode struct {
NodeBase
}
Represents a not whitespace char class eg. `\S`
func NewNotWhitespaceCharClassNode ¶
func NewNotWhitespaceCharClassNode(span *position.Span) *NotWhitespaceCharClassNode
Create a new not whitespace char class node.
type NotWordBoundaryAnchorNode ¶
type NotWordBoundaryAnchorNode struct {
NodeBase
}
Represents a not word boundary anchor eg. `\B`
func NewNotWordBoundaryAnchorNode ¶
func NewNotWordBoundaryAnchorNode(span *position.Span) *NotWordBoundaryAnchorNode
Create a new not word boundary anchor node.
type NotWordCharClassNode ¶
type NotWordCharClassNode struct {
NodeBase
}
Represents a not word char class eg. `\W`
func NewNotWordCharClassNode ¶
func NewNotWordCharClassNode(span *position.Span) *NotWordCharClassNode
Create a new not word char class node.
type OctalEscapeNode ¶
Represents an octal escape eg. `\20`, `\123`
func NewOctalEscapeNode ¶
func NewOctalEscapeNode(span *position.Span, value string) *OctalEscapeNode
Create a new octal escape node.
type OneOrMoreQuantifierNode ¶
Represents a one or more quantifier eg. `f+`, `f+?`
func NewOneOrMoreQuantifierNode ¶
func NewOneOrMoreQuantifierNode(span *position.Span, regex Node, alt bool) *OneOrMoreQuantifierNode
Create a new one or more quantifier node.
type PrimaryRegexNode ¶
type PrimaryRegexNode interface {
Node
ConcatenationElementNode
// contains filtered or unexported methods
}
Represents a primary regex element like a char, an escape, a char class, a group etc
type QuotedTextNode ¶
Represents a quoted text eg. `\Qfoo.+-bar?\E`, `\Q192.168.0.1\E`
func NewQuotedTextNode ¶
func NewQuotedTextNode(span *position.Span, value string) *QuotedTextNode
Create a new union node.
type StartOfStringAnchorNode ¶
type StartOfStringAnchorNode struct {
NodeBase
}
Represents the start of string anchor eg. `^`
func NewStartOfStringAnchorNode ¶
func NewStartOfStringAnchorNode(span *position.Span) *StartOfStringAnchorNode
Create a new start of string anchor node.
type TabEscapeNode ¶
type TabEscapeNode struct {
NodeBase
}
Represents a tab escape eg. `\t`
func NewTabEscapeNode ¶
func NewTabEscapeNode(span *position.Span) *TabEscapeNode
Create a new tab escape node.
type UnicodeCharClassNode ¶
Represents a unicode char class eg. `\pL`, `\p{Latin}`, `\P{Latin}`
func NewUnicodeCharClassNode ¶
func NewUnicodeCharClassNode(span *position.Span, value string, negated bool) *UnicodeCharClassNode
Create a new unicode char class node.
type UnicodeEscapeNode ¶
Represents a unicode escape eg. `\u0020`, `\u{357}`
func NewUnicodeEscapeNode ¶
func NewUnicodeEscapeNode(span *position.Span, value string) *UnicodeEscapeNode
Create a new unicode escape node.
type VerticalWhitespaceCharClassNode ¶
type VerticalWhitespaceCharClassNode struct {
NodeBase
}
Represents a vertical whitespace char class node eg. `\v`
func NewVerticalWhitespaceCharClassNode ¶
func NewVerticalWhitespaceCharClassNode(span *position.Span) *VerticalWhitespaceCharClassNode
Create a new vertical whitespace char class node.
type WhitespaceCharClassNode ¶
type WhitespaceCharClassNode struct {
NodeBase
}
Represents a whitespace char class eg. `\s`
func NewWhitespaceCharClassNode ¶
func NewWhitespaceCharClassNode(span *position.Span) *WhitespaceCharClassNode
Create a new whitespace char class node.
type WordBoundaryAnchorNode ¶
type WordBoundaryAnchorNode struct {
NodeBase
}
Represents a word boundary anchor eg. `\b`
func NewWordBoundaryAnchorNode ¶
func NewWordBoundaryAnchorNode(span *position.Span) *WordBoundaryAnchorNode
Create a new word boundary anchor node.
type WordCharClassNode ¶
type WordCharClassNode struct {
NodeBase
}
Represents a word char class eg. `\w`
func NewWordCharClassNode ¶
func NewWordCharClassNode(span *position.Span) *WordCharClassNode
Create a new word char class node.
type ZeroOrMoreQuantifierNode ¶
Represents a one or more quantifier eg. `f*`, `f*?`
func NewZeroOrMoreQuantifierNode ¶
func NewZeroOrMoreQuantifierNode(span *position.Span, regex Node, alt bool) *ZeroOrMoreQuantifierNode
Create a new zero or more quantifier node.
type ZeroOrOneQuantifierNode ¶
Represents a zero or one quantifier eg. `f?`, `f??`
func NewZeroOrOneQuantifierNode ¶
func NewZeroOrOneQuantifierNode(span *position.Span, regex Node, alt bool) *ZeroOrOneQuantifierNode
Create a new zero or one quantifier node.