|
|
|
@ -2,7 +2,7 @@ package regex
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
type NodeType int
|
|
|
|
|
type nodeType int
|
|
|
|
|
|
|
|
|
|
// This is a slice containing all escapable characters that have special meaning.
|
|
|
|
|
// Eg. \b is word boundary, \w is word character etc.
|
|
|
|
@ -10,7 +10,7 @@ var escapedChars []rune = []rune("wWdDbBnaftrvsS0")
|
|
|
|
|
|
|
|
|
|
// This is a list of the possible node types
|
|
|
|
|
const (
|
|
|
|
|
characterNode NodeType = iota
|
|
|
|
|
characterNode nodeType = iota
|
|
|
|
|
charclassNode
|
|
|
|
|
pipeNode
|
|
|
|
|
concatenateNode
|
|
|
|
@ -31,7 +31,7 @@ const lookbehind = -1
|
|
|
|
|
var infinite_reps int = -1 // Represents infinite reps eg. the end range in {5,}
|
|
|
|
|
// This represents a node in the postfix representation of the expression
|
|
|
|
|
type postfixNode struct {
|
|
|
|
|
nodetype NodeType
|
|
|
|
|
nodetype nodeType
|
|
|
|
|
contents []rune // Contents of the node
|
|
|
|
|
startReps int // Minimum number of times the node should be repeated - used with numeric specifiers
|
|
|
|
|
endReps int // Maximum number of times the node should be repeated - used with numeric specifiers
|
|
|
|
|