Documentation
¶
Overview ¶
Package regexpsyntax parses ECMAScript regular expression patterns. It is shared by the regexp engine (package engine), which compiles the tree, and the syntax package, which reports invalid regexp literals as early errors. It depends on the standard library only.
Index ¶
Constants ¶
const MaxCodePoint = 0x10FFFF
MaxCodePoint is the largest Unicode code point.
const UnicodeVersion = unicodeVersion
UnicodeVersion is the UCD version of the generated tables.
Variables ¶
This section is empty.
Functions ¶
func IsIDContinue ¶
Types ¶
type AST ¶
type AST struct {
Root *Node
Names []string // capture names by group number (index 0 unused); "" for unnamed
HasNames bool
DupNames bool // a name is shared by groups in different alternatives
}
AST is a parsed pattern.
type CaseMap ¶
type CaseMap struct {
// contains filtered or unexported fields
}
CaseMap is a decoded code point mapping (identity outside keys).
func Canonicalizer ¶
Canonicalizer returns the Canonicalize map for the flags (u or v select simple case folding).
func (*CaseMap) Canonicalize ¶
Canonicalize is Canonicalize(rer, ch) for an ignoreCase pattern.
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
A Checker validates patterns without building their tree, keeping its buffers from one pattern to the next. The zero value is ready to use.
type Error ¶
type Error struct{ Msg string }
Error reports a malformed pattern; Msg is the V8 wording without the "Invalid regular expression: /.../: " prefix.
type Flags ¶
type Flags struct {
IgnoreCase, Multiline, DotAll, Unicode, UnicodeSets bool
}
Flags are the flags that affect parsing.
type Node ¶
type Node struct {
Op Op
Greedy bool // OpRepeat
Negate bool // OpLook
Behind bool // OpLook
Multiline bool // OpBegin, OpEnd: the m flag
// Icase is the i flag in effect for OpBackref (Canonicalize compare)
// and OpWordB/OpNotWordB (u-mode word characters include U+017F and
// U+212A).
Icase bool
Index int // OpCapture: group number
Min, Max int // OpRepeat
// CapLo and CapHi delimit the groups [CapLo, CapHi) inside a repeated or
// lookaround body.
CapLo, CapHi int
Set Set // OpChar
Refs []int // OpBackref: group numbers
Name string // OpBackref by name, until resolved
Subs []*Node
}
Node is one node of a parsed pattern.
func (*Node) CanBeEmpty ¶
CanBeEmpty reports whether n can match the empty string.
type Op ¶
type Op uint8
Op is the kind of a Node.
const ( OpEmpty Op = iota OpChar // one character in set OpSeq // subs in order OpAlt // subs in priority order OpCapture // group index around subs[0] OpRepeat // subs[0] repeated min..max times (max -1: unbounded) OpLook // lookahead or lookbehind (behind, negate) of subs[0] OpBackref // backreference to the groups in refs OpBegin // ^ OpEnd // $ OpWordB // \b OpNotWordB // \B )
type Set ¶
type Set []rune
Set is a set of characters (code units or code points) as sorted, non-overlapping, non-adjacent inclusive ranges [lo0, hi0, lo1, hi1, ...]. Every constructor below returns a normalized set; the set operations of the regexp parser (classes, v-flag difference and intersection, case closure) work on this form.
func DecodeRanges ¶
DecodeRanges decodes a table in the generator's range encoding, which engine/unicode_norm_tables.go shares.
func (Set) Complement ¶
Complement returns the characters in [0, MaxCodePoint] not in s.
func (Set) ComplementIn ¶
ComplementIn returns the characters in [0, top] not in s.